Answer OSC 10/11 terminal-color queries from the live PTY emulator - #861
Open
drn wants to merge 1 commit into
Open
Answer OSC 10/11 terminal-color queries from the live PTY emulator#861drn wants to merge 1 commit into
drn wants to merge 1 commit into
Conversation
Argus's live x/vt emulator discards any response to terminal capability queries (a deliberate hang-avoidance drain), which means an agent CLI's OSC 10/11 background/foreground queries never get an answer. Codex sends this at every session start and, per a captured session, never draws its composer/history highlight background when it goes unanswered — matching the reported "codex agent view text input background is missing" bug. The live emulator now reports an assumed dark-terminal fg/bg and forwards its generated query responses into the agent process's stdin via the existing TerminalAdapter.WriteInput, instead of discarding them. Replay and preview emulators are unchanged (still discard-only), since they reconstruct historical output for a process that may not be live. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Merging this branch will decrease overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
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.
Summary
x/vtemulator that backs each agent pane discards any response it generates to terminal capability queries (NewDrainedEmulatordrains toio.Discard— a deliberate fix for a hang bug where the emulator's internal pipe blocks forever if nobody reads it). That means an agent CLI'sOSC 10/OSC 11("what's your foreground/background color?") queries never get an answer.newTrackedEmulatorWithCallback) now uses a newNewLiveEmulatorconstructor: it reports an assumed dark-terminal background/foreground color viaSetBackgroundColor/SetForegroundColor, and forwards the emulator's generated query responses into the agent process's stdin via the existingTerminalAdapter.WriteInput, instead of discarding them. Responses are still drained asynchronously (same hang-avoidance guarantee), just routed to the real PTY instead of/dev/null.Root cause
Confirmed via a real Codex v0.144.5 session log captured from a live Argus task in
~/.argus/sessions/: Codex sendsOSC 10/OSC 11queries at every session start, and across every occurrence of its idle composer/placeholder text in that session, it draws zero background/reverse-video styling — it only ever colors the submitted-prompt history box unconditionally (bare\x1b[7m). That's consistent with Codex conservatively skipping a background-dependent highlight it can't safely draw without knowing the terminal's background, which lines up with the reported symptom: a real terminal (which answers OSC 11) shows the highlight; Argus (which didn't) doesn't.internal/tui/terminal/terminalpane.go:35-54(NewDrainedEmulator) already documents the hang-avoidance drain but there was no path forwarding the emulator's auto-generated replies back into the PTY — this PR adds one for the live emulator only.Test plan
internal/tui/terminal/terminalpane_test.go:NewLiveEmulatoranswersOSC 11/OSC 10queries via the forward callback with the expected response bytes;forwardEmulatorResponseno-ops with no session and forwards viaWriteInputwhen one is attached; the pane's live-emulator constructor end-to-end forwards a query response to an attached mock session; the replay-emulator constructor is confirmed to remain discard-only even with a live session attached.make pre-pris green (build, vet, fmt-check, lint-pr, test-cover-gate at 89.2% filtered coverage — above the 88% floor).govulncheckreports only pre-existing Go-stdlib-toolchain CVEs, confirmed identical on a cleanorigin/mastercheckout (continue-on-error in CI pergotchas/ci-gates.md).fix-codex-terminal-query-responseauthored, implemented, and archived intoopenspec/specs/terminal-rendering/spec.mdin this same branch.🤖 Generated with Claude Code