perf(web): dedupe terminal mouse motion reports - #7845
Conversation
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5bcb285. Configure here.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This performance optimization changes terminal mouse event handling by filtering duplicate motion reports. While well-tested, it modifies what data is sent to the terminal, which is a behavioral change to core input handling that warrants human review. You can add or adjust custom eligibility rules. Learn more. |
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
## What's Changed * feat(web): cmd+enter to create thread in background by @extoci in pingdotgg/t3code#7821 * fix(web): launcher shortcuts no longer hijack the empty composer by @Lucenx9 in pingdotgg/t3code#7794 * feat(desktop): choose external project icons by @Bil0000 in pingdotgg/t3code#7823 * perf(web): dedupe terminal mouse motion reports by @t3-code[bot] in pingdotgg/t3code#7845 **Full Changelog**: pingdotgg/t3code@v0.0.34-nightly.20260821.1154...v0.0.34-nightly.20260822.1155 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.34-nightly.20260822.1155

summary
root cause
OpenCode v2 enables DEC 1003 any-event mouse tracking. Browser pointer events use pixel coordinates, while the terminal protocol reports cell coordinates. A normal pointer sweep therefore produced several byte-identical SGR motion packets per cell, and T3 Code sent every duplicate through the websocket and PTY.
The fix drops only consecutive byte-identical
motionpackets. Absolute cell changes still send, while press/release events always send and reset the motion baseline.benchmark
OpenCode v2
0.0.0-beta-17823running in T3 Code's real in-app terminal, with 1,000 pointer events over the same sweep path. Values are medians from five runs.tested in the real app
OpenCode v2 running in the isolated T3 Code dev client's terminal after the fix. Its full-screen TUI, mouse tracking, input, and rendering remained intact.
verification
built with gpt-5.6-sol via hermes agent.
request provenance
Note
Medium Risk
Changes what mouse sequences reach the PTY for apps using any-event tracking. Duplicate same-cell motion is dropped by design; incorrect baseline resets could skip a legitimate first motion after a mode change.
Overview
Stops forwarding duplicate SGR mouse-motion packets when the pointer stays in the same terminal cell under DEC 1003 any-event tracking. Press/release still always send, and they (plus pointer leave, non-reporting motion, session reset, and DEC 1003 mode flips) reset the motion baseline so the next cell report is not dropped.
sendMousenow gatesonDatathroughresolveTerminalMouseData. Writes and pointer moves also sync cached any-event tracking so a mode change without pointer movement starts a fresh session. Unit tests cover the dedupe and tracking-reset helpers.Reviewed by Cursor Bugbot for commit 9782d0f. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Dedupe terminal mouse motion reports in
GhosttyTerminalSurfaceresolveTerminalMouseDatato suppress outgoing motion reports when the encoded mouse data matches the previous motion baseline; non-motion actions (press/release) reset the baselineresolveTerminalMouseTrackingStateto clear the stored motion baseline when the any-event tracking mode togglesonPointerMove,onPointerLeave,write, andresetAndWritenow synchronize the cached tracking mode and clear the motion baseline at the appropriate pointssendMouseonly emits data whenresolveTerminalMouseData.sendis true, so duplicate same-cell motion events are no longer forwarded to the terminal;lastMouseMotionDatais the new private field controlling this dedup stateMacroscope summarized 9782d0f.