Skip to content

Terminal: don't type replies to replayed queries into the shell - #2022

Merged
currentbits merged 1 commit into
mainfrom
coder/terminal-restore-must-not-answer-replaye-ba36eb
Nov 13, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/terminal-restore-must-not-answer-replaye-ba36eb

Conversation

@currentbits

Copy link
Copy Markdown
Owner

When a terminal is restored, Solenta replays the saved output from the previous session. That output can contain terminal queries: Device Attributes ESC[c, cursor position ESC[6n, OSC color queries 11;?, and DCS XTGETTCAP. xterm answers them through onData, so those answers went into the live shell as typed junk like ^[[?1;2c.

The fix ignores onData while the replay is being parsed:

  • An empty term.write("", cb) turns the flag on just before the replay is parsed.
  • The replay write's own callback turns it off again.

xterm processes writes in order, so keystrokes queued before the replay still go through.

Tradeoffs:

  • A keystroke typed during the few milliseconds of replay parsing is dropped.
  • The query codes stay in the saved log, but they're harmless now that replay answers are ignored.

Tests: a terminalPane.test.tsx case where a replayed DA query produces no PTY write, while live typing still does. 35 of 35 pass.

🤖 Generated with Claude Code

Restored and re-attached terminals replay their saved raw output into a
fresh xterm. Old output can contain terminal queries (Device Attributes
ESC[c, cursor position ESC[6n, OSC 11;?, DCS XTGETTCAP, ...); xterm
answered them through onData and the replies were typed into the live
shell as junk like ^[[?1;2c.

The pane now drops onData while a replay parses. An empty write's
callback switches forwarding off just before the replay chunk parses,
and the replay's own callback switches it back on. xterm runs each
chunk's callback before parsing the next, so live output queued behind
the replay is still answered and keystrokes typed before it go through.

Why not strip queries from the saved log: replay isn't only the
restart path. Remounting the pane on a running terminal (switching
threads, splits) replays the whole in-memory buffer too, so stripping
the log alone would leave that path broken. With replies muted, queries
left in the log are harmless and nothing builds up across restores, so
an escape-sequence stripper (DCS/OSC/C1/split-chunk parsing) would add
risk for no gain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T17:58:40.397082Z 31c5246 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits merged commit ae19700 into main Nov 13, 2026
14 checks passed
@currentbits
currentbits deleted the coder/terminal-restore-must-not-answer-replaye-ba36eb branch November 13, 2026 19:20
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