fix(commander): mouse-tracking reports flood the input queue and stall typing#1016
Open
SmolSmolStar wants to merge 2 commits into
Open
fix(commander): mouse-tracking reports flood the input queue and stall typing#1016SmolSmolStar wants to merge 2 commits into
SmolSmolStar wants to merge 2 commits into
Conversation
Claude Code's TUI enables mouse reporting, so every mouse movement over the Commander panel emits an SGR/X10 mouse report. Each report was sent as its own chained HTTP request to /api/commander/input, and keystrokes share that same serial queue — so a burst of mouse reports (measured: 300+ in a short session) piled up ahead of a typed character and delayed it by seconds. The Commander is keyboard-driven, so drop terminal mouse reports in handleTerminalData before they're forwarded. Measured before/after on a real session: mouse reports reaching the server went from ~330 to 0, with keystrokes flowing at ~90ms spacing. The detector is anchored (^) so it only matches actual mouse sequences and leaves arrow keys, bracketed paste, and normal input intact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…wing Review feedback: the original filter dropped every mouse-tracking report, which silently killed clicks, drags, and scroll-wheel input for mouse-aware apps running in the Commander panel (Claude Code TUI, vim, less). Now only motion-with-no-button reports (the actual flood) are stripped, in both SGR and X10 encodings, and stripping instead of dropping the whole chunk preserves any real keystrokes xterm coalesced into the same data event. Adds a unit test covering motion vs click vs scroll payloads. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
|
Reviewed as part of an open-PR sweep. The diagnosis (serial HTTP input chain flooded by mouse reports) was verified correct, but the filter was too broad: it dropped clicks, drags, and scroll-wheel reports too, killing mouse interactivity for mouse-aware apps in the panel. Pushed a fix: only idle-hover motion reports (motion bit set, no button held) are stripped, in both SGR and X10 encodings; stripping per-report instead of dropping the whole chunk also preserves keystrokes coalesced into the same data event. Added tests/unit/commanderPanel.mouseFilter.test.js (5 cases, passing). Verdict after fix: good to merge. |
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
Typing in the Commander panel lags by seconds whenever the mouse is moving. Root cause found by measurement, not guesswork.
Root cause (measured)
Claude Code's TUI enables mouse reporting, so every mouse movement over the Commander terminal emits an SGR/X10 mouse report (
ESC[<…M). The Commander sends each input as its own chained HTTP POST to/api/commander/input, and keystrokes share that same serial queue. So a burst of mouse reports piles up ahead of a typed character and delays it.Instrumented
/api/commander/inputwith a redacted probe (logs only the kind of input — mouse / printable / etc., never the characters) and had the user type while moving the mouse:mousereports vs a handful ofprintablekeystrokes — keystrokes queued behind the flood.Fix
The Commander is keyboard-driven, so drop terminal mouse-tracking reports in
handleTerminalDatabefore they're forwarded. The detector is^-anchored to match only actual mouse sequences (SGRESC[<…M/mand X10ESC[M…) and leaves arrow keys, bracketed paste, and normal input untouched (unit-checked against those shapes).Test plan
🤖 Generated with Claude Code