Skip to content

fix(tui): bound inbox delivery verification loop and stop duplicate pastes#204

Merged
HonestMajority merged 2 commits into
mainfrom
fix-pm-inbox-delivery-verification-loop
Jun 10, 2026
Merged

fix(tui): bound inbox delivery verification loop and stop duplicate pastes#204
HonestMajority merged 2 commits into
mainfrom
fix-pm-inbox-delivery-verification-loop

Conversation

@HonestMajority

Copy link
Copy Markdown
Owner

What

Gives inbox delivery verification a terminal state and stops duplicate message pastes.

  • After 3 consecutive poll cycles where a delivered message cannot be verified in the target pane, the cursor force-advances past it with a loud warning. The inbox.jsonl row remains the durable record. Only cycles where the message actually reached the pane count — a pure tmux/inject failure can never skip an undelivered message.
  • Within one delivery cycle, once the message is pasted (or observed in the pane), retries only press Enter and re-verify — the full message is never pasted twice.
  • Verification captures use capture-pane -J and a whitespace-insensitive snippet match, so delivery tags split by pane or composer line-wrapping still match.

Why

Claude Code now runs in the tmux alternate screen, so capture-pane verification only sees the visible viewport, and long bracketed pastes collapse in the composer — the [msg:from:seq] delivery tag can be permanently invisible to verification even though the message arrived. With no terminal state, the poll loop re-pasted the same head message up to 3× per cycle forever: real duplicate deliveries to the PM, and every later message blocked behind the unverifiable head. This reproduced live (a PM stuck redelivering a 5.6KB reviewer message) and required manual cursor surgery to clear.

🤖 Generated with Claude Code

HonestMajority and others added 2 commits June 10, 2026 10:10
…astes

Claude Code now runs in the tmux alternate screen, so capture-pane
verification only sees the visible viewport; long bracketed pastes also
collapse in the composer, so the [msg:from:seq] snippet may never be
visible. The inbox poll had no terminal state for verification failure:
the head seq was re-pasted up to 3 times per cycle, every cycle, forever,
duplicating deliveries and blocking all later seqs.

- Track consecutive verification-failure cycles per (target, head seq),
  carried across cycles like stuck_skip_counts and reset on head-seq
  change or successful delivery. After 3 failed cycles, log a loud WARN
  and force-advance the cursor via inbox::mark_delivered; the inbox.jsonl
  row remains the durable record. Only cycles where the message actually
  reached the pane count — pure inject failures never force-advance.
- Within one delivery cycle, once inject_message_to succeeds (or the
  snippet is observed in the pane), later attempts only send Enter and
  re-verify; the full message is never pasted twice in a cycle.
- Add -J to the verification capture-pane call and match snippets via a
  newline-stripping snippet_in_capture helper so pane-wrapped delivery
  tags still match.

Verified with a scratch tmux smoke (alt-screen, echo-suppressed pane
emulating the collapsed-paste failure): a 5.4KB/30-line message pasted
exactly once per cycle, force-advanced after 3 cycles with a WARN, and
the next seq was unblocked; a short message in an echoing pane still
verified normally with a single paste.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- snippet_in_capture now strips all whitespace (not just newlines): Claude's
  renderer hard-wraps long lines at its layout width with an indented
  continuation margin, which tmux -J cannot join. Delivery tags contain no
  meaningful whitespace, so false-positive risk is negligible. Adds a
  Claude-style wrapped-capture test case.
- Skip the generic "delivery failed after N attempts" error on the cycle
  where force-advance fires — the force-advance WARN already tells the
  whole story and the generic error was being logged after it.

Review: researcher agman-improvements--pm-inbox-delivery-verification-loop
approved ef2ac98; these are their two optional non-blocking findings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@HonestMajority HonestMajority merged commit 1b3ac58 into main Jun 10, 2026
1 check passed
@HonestMajority HonestMajority deleted the fix-pm-inbox-delivery-verification-loop branch June 10, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant