Skip to content

fix(open): Ignore mouse reports in the rename gate - #116

Merged
4ndreello merged 2 commits into
mainfrom
fix/rename-gate-mouse-reports
Sep 24, 2026
Merged

4ndreello merged 2 commits into
mainfrom
fix/rename-gate-mouse-reports

Conversation

@4ndreello

Copy link
Copy Markdown
Owner

Since #105, sessions opened by codedeck open stopped renaming themselves. The title hook still writes the name sidecar, but the input gate never types the /rename. In the transcripts, 10 of the 11 sessions opened after the #105 build kept CodeDeck · <project> · orchestrator as their custom-title, including sessions with dozens of prompts.

The cause is mouse tracking. Launched from a trusted directory, Claude Code 2.1.281 enters the alternate screen and enables ESC[?1003h (any-event tracking) with ESC[?1006h (SGR encoding). From then on, every pointer move over the window sends a report such as ESC[<35;40;12M on stdin. The gate read those reports as unrecognised escapes, so each one marked the box dirty and guarded the next Enter. The pointer crosses the window between prompts, so the held name was never released. Through the built gate, a move before typing, a move after Enter, a wheel scroll, and a move before each of five prompts all left the rename held.

createInputGate now recognises SGR mouse reports (ESC[< + three numeric fields + M or m) in its byte parser and drops them. A report does not dirty the box, does not guard the next Enter, and does not reset the 300 ms quiet timer, because with any-event tracking a moving pointer would otherwise keep postponing the rename. Text in the same chunk as a report is still processed, and a report split across two chunks is still recognised. A sequence that starts with ESC[< and breaks the grammar falls back to the unknown-escape path, and arrows keep guarding Enter.

Spec: .specs/features/pty-session-rename/spec.md, Block B. The measured modes are recorded in docs/harness-behaviour.md.

A keyboard capture in Alacritty, with the modes Claude enables (ESC[>5u, ESC[>4;2m), showed Enter as a plain \r and accented text as plain bytes, so the keyboard protocol is not involved.

Not covered: scripts/pty-gate.sh and scripts/rename-gate.sh were not rerun, and no live codedeck open session has run on this build yet. Legacy X10 and urxvt mouse encodings are out of scope, because Claude requests SGR.

Tests

  • npx vitest run tests/open-pty.test.ts: 71 passed (65 before the change)
  • npx tsc --noEmit -p .: clean
  • Six new gate tests: a complete report is neutral, Enter after a report still submits, typed text beside a report stays dirty, a split report is neutral, a malformed ESC[< sequence guards Enter, and the Up arrow still guards Enter
  • The five held scenarios above, replayed against this branch, all type the rename, and typed text after a submit still holds it
  • Mutation probes, both killed: routing valid reports through the unknown-escape path (3 tests fail), and dropping any chunk that contains a report (the typed-text test fails)

4ndreello and others added 2 commits September 24, 2026 15:43
Ignore SGR mouse reports without resetting the rename gate, so terminal
pointer events cannot hold a queued rename. Preserve unknown escapes and
process adjacent typed text normally.

Co-Authored-By: Codex <noreply@anthropic.com>
Keep the six gate scenarios together without changing their timing or assertions.

Co-Authored-By: Codex <noreply@openai.com>
@sonarqubecloud

Copy link
Copy Markdown

@4ndreello
4ndreello merged commit db529b3 into main Sep 24, 2026
4 checks passed
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