Skip to content

fix(terminal): do not read the terminal's query replies as a draft - #898

Merged
omartelo merged 2 commits into
mainfrom
fix/terminal-replies-not-a-draft
Oct 21, 2026
Merged

omartelo merged 2 commits into
mainfrom
fix/terminal-replies-not-a-draft

Conversation

@omartelo

@omartelo omartelo commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

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 (gioterm replies → /ws → noteInput). escapeSpan only knew CSI and SS3, so each reply was read as Alt+key followed by printable text. drafting then held the prompt for draftIdle (one minute), Ready stayed false, and the window's awaitPrompt waited. 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

escapeSpan skips 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 builtin cc-plugin-sec-default sends classic.Stop on past user-installed plugins, so a worker's mod answers from turn.complete alone (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 new TestEscapeSpan cases fail before the fix and pass after
  • gofmt -l ., go vet ./..., go test ./...

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.
@omartelo
omartelo merged commit 9eab246 into main Oct 21, 2026
7 checks passed
@omartelo
omartelo deleted the fix/terminal-replies-not-a-draft branch October 21, 2026 17:56
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