Skip to content

fix: submit typed messages with a separate Enter - #384

Merged
brtkwr merged 1 commit into
mainfrom
fix/typed-message-submit
Nov 23, 2026
Merged

brtkwr merged 1 commit into
mainfrom
fix/typed-message-submit

Conversation

@brtkwr

@brtkwr brtkwr commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Opus 5.5 ✨

Messages sent from ccs's message box often didn't send: the text landed in the session's prompt with the cursor on a new empty line, and nothing was submitted. This started with #381 (v0.187.0), which types messages into the session's terminal first.

Cause

Claude Code reads a burst of 64 bytes or more as a paste, and an Enter inside a paste is a newline, not submit. iTerm's write text "…" newline true sends the text and its \r in one write, so any message of 63 characters or more became a pasted line plus a newline, left in the prompt.

Evidence, from throwaway Claude Code 2.1.330 sessions (made-up names, closed afterwards):

  • Bytes iTerm delivers for write text "hello world one line" newline true, read raw from the tty: b'hello world one line\r', one write, no bracketed paste.
  • Same typing as ccs into an idle session: 30, 40, 50, 60 and 62 characters submitted; 63, 64, 66, 70 and 90 did not. In each case a lone \r sent afterwards submitted the message that was waiting.
  • The screenshot's two lines were two separate sends, each left in the prompt with a trailing newline.

tmux already sent Enter as a second send-keys call. That worked in testing, but nothing kept the two from reaching Claude Code in one read.

Fix

  • sessions.SendKeys types the text with no Enter, waits SubmitDelay (300ms), then presses Enter on its own (iTerm: write text "" newline true, which sends \r alone; tmux: send-keys Enter). This covers Claude Code, Codex, agy and typed slash commands.
  • If Enter fails after the text went in, the error is ErrEnterNotSent, never ErrNoTerminal, so deliverMessage doesn't also send the message over the socket. A message is never delivered twice.
  • ccs now follows a typed message until the transcript shows it: a user line, or the queue-operation enqueue a busy session logs at once. Typed text is plain text, so Conversation.PeerQueued became Queued and records every enqueue. If neither appears within 5s, the status line says in red ✗ not arrived … it may be sitting unsent in its prompt, press Enter in its tab. ccs doesn't press Enter again by itself, because by then you may be typing in that tab. Once the message arrives, the note says ✓ Delivered to <name> (typed, as you).
  • The existing refusals are kept: control characters (newlines included) are never typed, and nor is text starting with / or !. Multi-line text keeps going over the message socket, as one message.

Testing

  • New unit tests: TestSendKeysPressesEnterApart (tmux and iTerm: the text call, then a separate Enter at least SubmitDelay later; a menu digit stays one call), TestSendKeysEnterFailureIsNotNoTerminal, TestTypedMessageDelivery (tracking, the not arrived warning, enqueue and user line as arrival) and an extended TestMidTurnAndPrefixedPeerMessagesParsed.
  • End to end, through the real sessions.TypeKeys and the socket path deliverMessage uses, against throwaway sessions in iTerm and in a private tmux server. Every case arrived exactly once, in both terminals:
case iTerm tmux
one line, short arrived ×1 arrived ×1
one line, 250 chars, idle arrived ×1 arrived ×1
one line, 250 chars, while busy (queued) arrived ×1 arrived ×1
three lines (socket) arrived ×1 arrived ×1

🤖 Generated with Claude Code

@brtkwr
brtkwr enabled auto-merge November 23, 2026 04:05
Since ccs types message-box text into a session's terminal first, a
message of 63 characters or more sat in Claude Code's prompt unsent.
iTerm's write text sends the text and its \r in one write, and Claude
Code reads a burst of 64 bytes or more as a paste, whose Enter is a
newline. Measured on a throwaway session: 62 characters + \r submits,
63 + \r stays in the prompt, and a lone \r afterwards submits it.

SendKeys now types the text, waits SubmitDelay (300ms), then presses
Enter on its own, in tmux and iTerm alike. A failed Enter after the text
went in is ErrEnterNotSent, never ErrNoTerminal, so the message is
never also sent over the socket.

ccs now tracks a typed message until the transcript shows it (a user
line, or the queue-operation enqueue a busy session logs at once, now
recorded for typed text too as Conversation.Queued), and says plainly
when it hasn't arrived after 5s, so it can't silently sit in a prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brtkwr
brtkwr force-pushed the fix/typed-message-submit branch from 2347a76 to 1e8e5dd Compare November 23, 2026 04:06
@brtkwr
brtkwr merged commit 01577c7 into main Nov 23, 2026
1 check passed
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