Repository navigation
fix(terminal): do not read the terminal's query replies as a draft - #898
Merged
Merged
Conversation
The window's terminal answers a TUI's startup queries (OSC 11, XTVERSION, kitty graphics) through the same input path as the keyboard. escapeSpan read each control string as Alt+key followed by typed text, so a fresh Claude Code session looked drafted for up to a minute and a handoff (Resolve conflicts, Fix CI errors, issue worktree) waited for an Enter.
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
Resolve conflicts, Fix CI errors and a worktree started from an issue could leave their message unsent at a new Claude Code session for up to a minute, until the user pressed Enter.
The cause is on lich's side. At startup Claude Code queries the terminal: background colour (OSC 11), terminal name (XTVERSION) and kitty graphics support. The native window answers through the same input path as the keyboard (
giotermreplies →/ws→noteInput).escapeSpanonly knew CSI and SS3, so each reply was read as Alt+key followed by printable text.draftingthen held the prompt fordraftIdle(one minute),Readystayed false, and the window'sawaitPromptwaited. An Enter cleared the draft and the handoff went out.In the reported session the handoff reached Claude Code's queue 65s after startup, at the moment of the user's Enter.
Change
escapeSpanskips control strings (OSC, DCS, APC, PM, SOS) through their ST or BEL. A reply arrives in one write, so a string with no terminator in the write is still read as Alt and a key, which keeps Alt+P and Alt+] as before.Also in
docs/ceilings.md, found while tracing this: on a machine with managed settings, Claude Code's builtincc-plugin-sec-defaultsendsclassic.Stopon past user-installed plugins, so a worker's mod answers fromturn.completealone (lichdotdev/lich-plugin#93), and a turn that handed background work off answers early.Test plan
TestTerminalRepliesAreNotADraft(OSC 11 with ST and BEL, XTVERSION, kitty graphics reply) and newTestEscapeSpancases fail before the fix and pass aftergofmt -l .,go vet ./...,go test ./...