fix(app): a cursor key before Enter ends codex's paste classification, so injected messages actually submit under load - #620
Open
ebigunso wants to merge 1 commit into
Conversation
…, so injected messages submit under load pty_inject wrote text, slept 300ms, then wrote \r — but codex's paste heuristic runs on its own read timeline, so any event-loop stall spanning the gap batches text+Enter into one read, classifies it as a paste, and swallows the Enter as a newline; the kickoff sits in the composer unsubmitted. Measured on a real Windows machine: 2/5 submitted under full CPU load, 0/5 with the gap widened to 1000ms, and Enters that land while the stall persists are accumulated into the burst (text + 6 Enters in one wake batch: six newlines, nothing submitted). Submission is now text -> 300ms -> Right-arrow -> 50ms -> Enter (write_submit): a non-char key makes codex force-flush the burst buffer and clear the Enter-suppress window before the key is handled, so the Enter submits even when the whole sequence arrives in one batched read — 11/11 across the stalled/loaded/one-batch reproductions that failed 0-for-all before, verified on codex-cli 0.145.0 and 0.146.0. Also serializes concurrent injections per pane (interleaved text/Enter writes from two near-simultaneous messages) and adds a state-watching backstop: re-submit at spaced checkpoints while the pane never leaves Idle; never touch a Blocked pane (an approval dialog owns the keyboard). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #619. On a stalled or loaded machine, Codex reads
pty_inject's text and trailing\rin one batch, classifies the run as a paste, and swallows the Enter — the kickoff sits in the composer unsubmitted. The old fixed 300ms gap is open-loop and cannot survive a stall that spans it (measured: 2/5 under full CPU load; 0/5 with the gap widened to 1000ms). Retries sent while the stall persists coalesce into the same wake batch and are absorbed too (text + 6 Enters in one read: six newlines, nothing submitted) — only a writer-side sequence that is safe within a single batch can be deterministic.Fix
Submission becomes
text → 300ms → Right-arrow → 50ms → Enter(write_submit). A non-char key makes codex force-flush the burst buffer and clear the Enter-suppress window before the key is handled, so the Enter that follows submits even when the whole sequence arrives in one batched read. A Right-arrow at the end of composer text is a cursor no-op in every TUI the app spawns. Result on the failing reproductions: 11/11 submitted (stall / full load / gap-0 single-batch) with no idle or mid-task regression.Two guards ride along, both motivated by the same investigation:
inject_lock): two messages arriving close together no longer interleave their text/Enter writes.Validation
cmd /d /c codex), against npm codex-cli 0.145.0 and 0.146.0; burst logic unchanged on openai/codexmain. Full matrix in app (Windows): messages injected into a Codex pane frequently fail to submit — Enter is swallowed as a pasted newline whenever the machine stalls across the inject gap #619.cargo test(src-tauri): 62 passed, including 4 new unit tests on the verify decision.pnpm test(vitest): 179 passed. Frontend untouched.app/README.mddelivery paragraph updated to describe the new sequence.Files
app/src-tauri/src/pty.rs—write_submit,verify_action,inject_lock, doc comments recording the mechanismapp/README.md— delivery description🤖 Generated with Claude Code