feat: answer terminal capability queries (OSC 10/11, DSR)#163
Merged
Conversation
agent-tty owns the PTY master but never replied to the terminal-capability queries programs emit at startup, so TUIs like Neovim 0.12+ timed out and printed "E1568: Terminal did not respond to DSR request for 'background' color" into the captured output. Add a stateful VT scanner (src/pty/terminalQueryResponder.ts) that answers the common startup probes — OSC 11 (background) and OSC 10 (foreground) color queries, plus the DSR sentinel ESC[5n — and wire it into the host's live PTY read loop, writing replies back to the child. The advertised colors mirror the default render profile so a program's light/dark choice matches a default-profile capture. Replies are written as child input only and are not appended to the event log, so snapshots and recordings are unaffected. Covered by unit tests (split-chunk handling, BEL/ST terminators, non-query inputs, C1 ST recovery) and an end-to-end integration test that confirms a child receives the reply on stdin. Verified against real nvim 0.12.3: E1568 is gone. Change-Id: Ib647e0c33003711108f73d9bd33491227f380d7b Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Kosiewski <tk@coder.com>
16aa4e2 to
ff3cdaa
Compare
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
agent-tty owns the PTY master and is the terminal that programs in a session talk to, but it never replied to the terminal-capability queries programs emit at startup. So TUIs like Neovim 0.12+ time out probing for the background color and print:
That warning then lands in the very PNG/WebM captures agent-tty exists to produce. (Reported while using agent-tty with Neovim.)
Fix
Add a small, stateful VT scanner —
src/pty/terminalQueryResponder.ts— that answers the handful of startup probes that matter and wire it into the host's livepty.onDataloop, writing replies back to the child:ESC[5n(status) → repliesESC[0n(the sentinel programs use to learn the terminal answers queries at all)Details:
ESCbyte.Testing
test/unit/pty/terminalQueryResponder.test.ts): OSC 10/11 with BEL & ST terminators, the OSC 11 + DSR startup handshake, split-across-chunk queries, embedded/multiple queries, non-query inputs (SGR, title sets, color sets, DA1, CPR), recovery after aborted sequences and after an 8-bit C1 ST, rgb conversion, constructor validation.test/integration/terminal-query-responder.test.ts): a child sets raw mode, emits the OSC 11 query, and reports what it received on stdin — proving the full loop (child query → host reply → child stdin).nvim --cleanv0.12.3 via the agent-tty CLI: with the responder the warning is gone; disabling it reproduces the exactE1568line.🤖 Generated with Claude Code