Skip to content

fix(tmux): look for a dialog before pressing Enter on a delivered paste - #309

Open
tfyl wants to merge 1 commit into
mainfrom
feat/gate-inbox-submit-guard
Open

tfyl wants to merge 1 commit into
mainfrom
feat/gate-inbox-submit-guard

Conversation

@tfyl

@tfyl tfyl commented Oct 10, 2026

Copy link
Copy Markdown
Member

Why

Gate Inbox sometimes answers a Claude Code question on its own, ticking a multi-select box, picking a single-select option, or submitting a stepper's review page, when no one chose anything. Each time, the agent then carries on with an answer the user never gave.

Summary

  • The poll pass decides a pane may take a message from a capture taken before the paste. Up to a second later it presses Enter without looking at the pane again. Claude Code takes messages mid-turn, so the agent can put a question up in between. The dialog swallows the paste, the echo never arrives, the paste window runs out, and the Enter lands on the row under the dialog's cursor.
  • SendTextAsync now takes a hold check that the driver runs on a fresh capture just before the Enter. When it reports a dialog, the Enter is not pressed and the send settles with ErrSubmitHeld. The message is then dropped the way any failed send is, and its sender is told.
  • The poller's check is the same rule test safeToInterrupt already uses: the session's rules match a waiting state. All three async senders (queued messages, pending inputs, the usage-limit continuation) get it. The synchronous SendText is unchanged.
  • Trade-off: a message whose own pasted lines quote a dialog legend can trip the hold and be dropped. A dropped message is reported to its sender; an answered dialog is not reported to anyone.
  • This complements fix(status): hold queued messages on a Claude question whose legend wraps #308, which makes the rules recognise a question whose legend or review line wraps in a narrow pane. This PR covers a dialog that appears after the check.

Test plan

  • TestSendTextAsyncLeavesTheEnterUnpressedOnADialog: against a real tmux pane showing a legend with echo off, the paste arrives, the submit settles with ErrSubmitHeld, and no carriage return reaches the pane. It fails with the guard disabled (submit = <nil>).
  • The existing SendTextAsync tests pass with a nil hold.
  • go vet ./... clean. The full suite passes all 68 packages on a scratch TMUX_TMPDIR.

🤖 Generated with Claude Code

The poll pass decides a pane may take a message from a capture taken
before the paste, then presses Enter up to a second later without looking
again. Claude takes messages mid-turn, so an agent can put a question up
in between. The dialog swallows the paste and takes the Enter as its
answer: a multi-select ticks the box under its cursor, a single-select
picks its first option, and a review page submits.

The submit now captures the pane once more and, when the session's rules
read a dialog there, leaves the Enter unpressed and reports
ErrSubmitHeld, which drops the message the way any failed send does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tfyl tfyl added the claude PR primarily authored by Claude label Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR primarily authored by Claude

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant