Repository navigation
Submit a composer message with its own Enter, after the text - #15
Conversation
devswha
left a comment
There was a problem hiding this comment.
The ordering is sound: text and Enter share the socket and the server writes frames in order. Three things before merge:
- Regression: an armed Ctrl turns a one-letter message into a control key. Outside bracketed paste, "c" is now sent as the single character
c. On main it wasc\r. If Ctrl is still armed from the terminal key bar (arming survives a lens or pane switch),onDataturns it into Ctrl+C, and then Enter follows. Please send composer text withsocket.sendInputdirectly, bypassing the modifier. - The 120ms gap exists only in the browser. On a jittery phone connection both frames can arrive together and be written back to back, which is the combined chunk this PR is trying to avoid. And the original failure wasn't reproduced. Please put the gap on the server side instead, for example through the existing
keys/paneSendKeyspath. - The Enter can be dropped silently. If iOS freezes the timer (phone locked or app backgrounded right after sending), or the socket is gone when it fires, the Enter is skipped. The composer has already cleared and reported success, so the text sits unsent in the agent's input box. Please surface this, or do the whole send on the server.
Minor: two sends within 120ms paste both texts before either Enter.
5f8de37 to
329bd1f
Compare
|
Thanks. Reworked in 329bd1f (rebased onto main):
Compatibility. The server lists Tests. I still haven't reproduced the original failure on demand. This change makes the gap hold regardless of the connection. |
329bd1f to
749a0a4
Compare
devswha
left a comment
There was a problem hiding this comment.
Thanks. Ctrl bypass, the server-side gap and back-to-back sends are all fixed. One ordering regression before merge:
- Other input can land between the text and its Enter.
submitgoes through the per-pane queue with a 120ms server sleep, butinputframes still go straight to the pty (server/index.ts~854), and prompt answers (prompt.ts) skip the queue too. Scenario: tap Send, then Stop within about 120ms. The Escape fromabortTurnreaches the pane between the text and the Enter, or before the text. On main, everything reached the pty in order. Please sendinputframes and prompt answers through the same per-pane queue while a submit is in flight. - A server-side failure is still silent. If the pane closes during the gap or the RPC times out, the error only goes to
term.writeln, which the chat lens hides, and the composer has already cleared. Please acksubmitback to the client and restore the draft on failure. - Question: herdr already has an
agent.promptRPC. It handles bracketed paste, sends a delayed Enter and refuses withagent_blocked. Could the bridge use it instead of re-implementing the same thing?
Minor: right after a reconnect, connected is true before the snapshot arrives, so a Send in that window takes the old single-frame path. A Send while an observe switch waits for its ack is rejected without notice.
749a0a4 to
7046df5
Compare
|
Thanks. Addressed in 7046df5, rebased onto main:
Minor. After a reconnect, a Send waits up to 2s for the snapshot before it picks a path. Checked live:
|
|
One more commit (03f523c), found while testing this together with #6 on a live Codex 0.156.1 pane. herdr reports Codex as blocked while questions asked with |
|
Note on merge order: #6 and #15 both touch |
devswha
left a comment
There was a problem hiding this comment.
Thanks. Ordering, failure reporting and agent.prompt are all in, and older bridges stay compatible. One blocker from 03f523c, plus a few smaller issues:
- A message can be typed into a Codex approval menu (
server/prompt.ts~393,server/index.ts~205).codexQuestionsCollapsedonly looks for the collapsed queue text and the absence of the "enter submit … skip" hint. It never checks for another open prompt. Async questions don't stop the turn, so a collapsed queue can sit above "Would you like to run the following command? … Press enter to confirm". On that screen it returnstrue, the message goes out throughsend_text+ Enter, letters likeyorpact as approval shortcuts, and Enter confirms "Yes, proceed". It also never checks that the pane runs Codex. Please also requireparseInteractivePrompt("codex", screen) === nulland a Codex agent. - Flaky test (
server/submit.contract.test.ts:123). It assumes the first frame issnapshot, but apane-statusoften arrives first. It failed in 3 of 6 solo runs and once in the full suite. Please wait for the snapshot frame by type. - A late submit after the client gives up. A fallback submit can make up to four 10s RPCs, about 40s, but the client stops waiting at 30s and keeps the text. The server can still send the Enter later, so a resend goes twice. Please cap the server side below the client timeout, or have the client wait for the final
submit-result. - "Send now" can be double-tapped (
PaneTerminal.tsx~594). It is only disabled while disconnected, not while a submit is in flight. - Edits made while sending are lost. The box stays editable while waiting, and
okclears whatever was typed in the meantime. Please lock the box, or clear only the text that was sent.
Nits: queued input skips the attached-pane check, submit doesn't validate pane_id, and lastTyped is never pruned. The 200ms wait after the last keystroke is only 50ms above herdr's measured ~150ms ESC hold.
From a phone the chat now and then left a message sitting in the agent's input box with a newline instead of sending it, and it had to be sent with Enter from the terminal. The text and the submitting CR went in one chunk, so how the CR was read depended on how the TUI parsed that chunk while still busy with the paste (turning an image path into an attachment, redrawing after the phone keyboard closed). chatmux, which never showed this, pastes and then sends tmux a separate Enter. The composer now types the text, then 120ms later the CR on its own, and only into the pane that got the text. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Review follow-up. The composer's text and its Enter are now sent by the server, not timed in the browser: - New "submit" frame: the server types the text with herdr's send_text, waits SUBMIT_DELAY_MS, then sends Enter with send_keys. Both calls return once the pane has the bytes, so the pane sees the full 120ms gap even on a jittery connection (writing through the attach pty shrank it to 54ms in one run). Messages to one pane queue, so a quick second send cannot land before the first one's Enter. - The send completes even if the phone locks or the socket drops right after the tap. The browser no longer holds a timer that can be frozen. - The composer goes straight to the socket, not through onData, so an armed key-bar Ctrl can no longer turn a one-letter message into ^C. - The server lists "submit" in its first snapshot (features). An older bridge lists nothing, and the client falls back to main's single input frame (text plus CR). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ort how it went Review follow-ups: - Ordering. While a composer message is in flight, the pane's other input waits behind it: keystrokes, keys frames and prompt answers go through the same per-pane queue. Queued keystrokes go through send_text, like the message: herdr holds a lone ESC typed through the attach pty ~150ms to tell it from Alt+key (measured), so a Stop tapped right after Send still arrived after the next message. For the same reason a message waits 200ms after the pane's last keystroke, so a Stop tapped just before Send reaches the pane first. Tests cover both orders; each fails without its part of the change. - Every submit is answered with a submit-result. The composer keeps the text until the pane has the message and its Enter. If the message did not go (read-only view, the pane gone, the connection dropped before the answer, no answer in 30s), the text stays with the reason. An old bridge without the "submit" feature still gets the single frame. - herdr's agent.prompt now sends to an agent: the paste, then Enter 300ms later, returning after the Enter. It also refuses with agent_blocked while the agent waits for an answer, so a message is never typed into a question or approval menu. Checked live: the text stays in the chat box with "the agent is waiting for an answer". A pane without an agent in front (agent_not_found / agent_not_ready) still gets send_text, the gap, then Enter. - Right after a reconnect, a Send waits (up to 2s) for the snapshot that says whether the server takes "submit", instead of taking the old path. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… queue herdr reports Codex blocked while questions asked with request_user_input_async wait collapsed above its main prompt, so agent.prompt refused a message the TUI would take (Codex then drops the questions). When agent.prompt answers agent_blocked and the screen shows only that collapsed queue, the message goes through send_text and its own Enter. An open question, whose "enter submit … skip" hint means it holds the input, is still refused. Found while checking this with devswha#6's queue cards on a live Codex 0.156.1 pane. A contract test runs a stand-in `codex` reported blocked that shows the collapsed queue, and fails without this change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Review follow-ups: - Blocker from 03f523c: a Codex blocked only by its collapsed question queue got the message through send_text, but the check looked only at the queue text. With an approval under the queue, "y" or Enter would have answered it. The fallback now requires a Codex agent, no prompt parsed on screen, and the main prompt (›) right under the queue's "alt+↑ to answer" line. A contract test with an approval under the queue, and one with a non-Codex agent showing the same text, types nothing. It fails without this change. - The snapshot test finds the snapshot by type: a pane-status can arrive first (6/6 runs pass now). - The client waits 60s for a submit-result, longer than the server can take (four 10s RPCs), so a message it gave up on is never submitted later. - "Send now" is disabled while its send is in flight. - Text typed while a message was on its way stays in the box: only what was sent leaves it (checked in a browser). - Nits: queued keystrokes also require an attached pane, a submit's pane_id is validated, lastTyped is pruned, and the wait after the pane's last keystroke is 300ms (herdr holds a lone ESC ~150ms). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…a time
Review follow-ups:
- The queue is never left open by the chat. When it opens on another
question than the card's, or does not open within 2s, it is closed
again (alt+↓), and the question it opened on is remembered, so the next
card shows that one instead of the rollout's newest-first guess (a
skipped question leaves that guess wrong). After an answer, the queue
closes only once a different question shows, never on the stale screen
of the one just answered. Checked on Codex 0.156.1: alt+↓ on the main
prompt or an approval changes nothing.
- An open queue is card-only too (`queued: "open"`). It holds the
terminal's input, so the composer sends nothing while it shows and
says why, rather than typing the message into the question. A
collapsed queue (`queued: "collapsed"`) still leaves the composer
talking to Codex.
- Concurrent polls of one rollout share a single scan, and the scan is
built on a copy and kept only once complete. Two viewers, or a poll
overlapping an answer, no longer push the same questions twice. There is
a test that fails with the old scanner.
- An MCP call ("● server - tool (MCP)(…)") anchors a Claude approval's
panel like any tool call.
- Text typed in the composer while a message was on its way stays: only
what was sent leaves the box (as in devswha#15).
Checked live on Codex 0.156.1:
- With the queue opened in the terminal, a chat message was held with the
reason and nothing reached the question. The card answered it.
- With the second of two questions skipped, the card's guess (Beta?)
answered nothing, the queue closed, and the next card showed Alpha?,
which the card then answered.
- The earlier flows (tap, free-form, message box to Codex) still pass.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
03f523c to
2b2ae07
Compare
|
Thanks. Addressed in 2b2ae07, rebased onto main:
Nits.
|
|
Merged. Thanks. The approval fallback holds for every question, approval and menu screen I could come up with, and the submit contract test passed 8/8 solo runs. Follow-ups for a separate PR:
|
Since #15 a composer message goes out as a "submit" frame on servers that list it, not as "input". The regression only counted "input" frames, so its two hold checks passed without checking anything and the explicit send timed out. It now counts both. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…a time
Review follow-ups:
- The queue is never left open by the chat. When it opens on another
question than the card's, or does not open within 2s, it is closed
again (alt+↓), and the question it opened on is remembered, so the next
card shows that one instead of the rollout's newest-first guess (a
skipped question leaves that guess wrong). After an answer, the queue
closes only once a different question shows, never on the stale screen
of the one just answered. Checked on Codex 0.156.1: alt+↓ on the main
prompt or an approval changes nothing.
- An open queue is card-only too (`queued: "open"`). It holds the
terminal's input, so the composer sends nothing while it shows and
says why, rather than typing the message into the question. A
collapsed queue (`queued: "collapsed"`) still leaves the composer
talking to Codex.
- Concurrent polls of one rollout share a single scan, and the scan is
built on a copy and kept only once complete. Two viewers, or a poll
overlapping an answer, no longer push the same questions twice. There is
a test that fails with the old scanner.
- An MCP call ("● server - tool (MCP)(…)") anchors a Claude approval's
panel like any tool call.
- Text typed in the composer while a message was on its way stays: only
what was sent leaves the box (as in devswha#15).
Checked live on Codex 0.156.1:
- With the queue opened in the terminal, a chat message was held with the
reason and nothing reached the question. The card answered it.
- With the second of two questions skipped, the card's guess (Beta?)
answered nothing, the queue closed, and the next card showed Alpha?,
which the card then answered.
- The earlier flows (tap, free-form, message box to Codex) still pass.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Rebased onto main (devswha#15 and devswha#20 merged). The whole answer runs inside devswha#15's per-pane serialize: read, open the queue, keys, close. A composer submit can't land between them. Review follow-ups: - "Send now" on a held message goes through the same check as the composer. It is disabled, with the reason as its title, while Codex's queue is open in the terminal. - The remembered question (the one the queue really opened on) is matched by title and options, the newest such one. It is dropped when the pane's rollout changes. An older skipped question with the same title no longer takes its place. - closeQueue tells the question just answered from its twin by prompt id, and after 600ms treats an identical question still open as the next one (Codex takes the Enter at once). Two questions with the same title and options no longer leave the queue open. Checked live on Codex 0.156.1: two identical queued questions, each answered from its card, with the queue folded back to "? 1 question" in between. The earlier queue flows still pass. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks. The follow-ups are in #23:
|
From the merge reviews. #15 (composer submit): - A submit is stamped when it reaches the server. Nothing of it is typed once 45s have passed, whether it waited behind a stalled message in the pane's queue or not: it answers submit_timeout ("nothing was typed"). A send that starts in time ends within two more 10s RPCs, and the client now waits 90s, so a message it gave up on never reaches the pane later. A contract test with a 50ms deadline fails without the check. - The collapsed-queue fallback no longer takes a numbered menu row (`› 1. …`) under the queue for the main prompt. - Text typed after the sent part keeps its leading whitespace. An edit inside the sent part while it was on its way stays in the box with a note that it was not sent, rather than silently waiting for a resend that would duplicate it (checked in a browser). #20 (Codex bindings): - The claim trade-off is written down where it lives: the other pane's first message must still be in its last 400 lines and read as 8+ letters or digits, otherwise this pane stays unsure. It never shows another conversation. - A contract test covers the uniqueness rule (a pane whose screen also matches this pane's thread claims nothing) and pruning (a closed pane's binding stops counting). Each part fails without its code. - codexHistorySegments' doc comment is back above it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Summary
On a phone, the chat sometimes left a sent message sitting unsent in the agent's input box, followed by a newline, and the user had to press Enter in the terminal to send it. The cause: the composer sent the text and the submitting CR in one chunk. How the TUI read that CR depended on whether it was still handling the paste, for example turning an image path into an attachment or redrawing after the phone keyboard closed. chatmux, which has never shown this problem, pastes the text and then sends tmux a separate
Enter.The whole send now happens on the server:
submitframe. An agent pane gets the message through herdr'sagent.prompt: the paste, then Enter 300ms later, returning after the Enter.agent.promptalso refuses (agent_blocked) while the agent waits for an answer, so a message is never typed into a question or approval menu. The exception is a Codex that herdr calls blocked only because questions wait collapsed in its queue: its main prompt still takes the message. That exception applies only for a Codex agent, with no prompt parsed on screen and the main prompt right under the queue, so an approval never gets the message. A pane without an agent in front (agent_not_found/agent_not_ready) gets the paste-mode payload throughsend_text, then Enter 120ms later. Both paths return once the pane has the bytes, so the pane sees the whole gap even on a jittery connection.submit-resultfor every submit. The composer keeps its text until the pane has the message and its Enter. On failure the text stays, with the reason: agent waiting for an answer, read-only view, pane gone, connection dropped, or no answer in 30s.send_text, because herdr holds a lone ESC typed through the attach pty for about 150ms (to tell it from Alt+key). Otherwise a Stop tapped right after Send would still arrive after the next message. For the same reason a message waits 200ms after the pane's last keystroke, so a Stop tapped just before Send lands first.onData, so an armed key-bar Ctrl can't turn a one-letter message into a control key.features: ["submit"]in its first snapshot. An older remote bridge lists nothing, and the client falls back to main's single input frame (text plus CR). Right after a reconnect, a Send waits up to 2s for that snapshot.Testing
bun run typecheckis clean;bun test: 292 pass.server/submit.contract.test.tsruns raw-mode input recorders in real herdr panes: a plain program, and one run asclaudeso thatagent.promptapplies. It checks:agent_blockedtypes nothingread_only🤖 Generated with Claude Code