mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[PR #779] [CLOSED] fix(core): prevent mouse escape sequences from leaking into keyboard input #1556
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#1556
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/779
Author: @Jerwand
Created: 3/5/2026
Status: ❌ Closed
Base:
main← Head:fix/mouse-tracking-leak📝 Commits (1)
4bd8cccfix(core): prevent mouse escape sequences from leaking into keyboard input📊 Changes
4 files changed (+223 additions, -15 deletions)
View changed files
📝
packages/core/src/lib/parse.mouse.test.ts(+109 -1)📝
packages/core/src/lib/parse.mouse.ts(+70 -6)📝
packages/core/src/renderer.ts(+39 -6)📝
packages/core/src/tests/renderer.mouse.test.ts(+5 -2)📄 Description
Summary
Fixes the root cause of mouse escape sequences (e.g.
[555;129;29M) appearing as typed text in input fields during normal use. This happens when stdin delivers mouse data split across chunk boundaries, which occurs regularly under high mouse activity.parseAllMouseEventsWithOffset()toMouseParser— returns consumed byte count and partial-sequence detection so callers know exactly what was parsed and what remainsisPartialMouseSequence()to detect truncated SGR/Basic mouse sequences at chunk boundaries (e.g.\x1b[<35;20missing the terminatingM)_mousePartialBuffertoCliRendererthat preserves incomplete mouse sequences between stdin chunksstdinListenerto properly route unconsumed non-mouse data toStdinBufferinstead of silently dropping itRoot cause
The old
stdinListenerhad an all-or-nothing design:When a mouse sequence was split across two stdin chunks (e.g.
\x1b[<35;20;5M\x1b[<35followed by;21;5M), the partial tail was dropped and its completion in the next chunk leaked into the keyboard handler as literal text.Three scenarios this fixes
\x1b[<35;20;5M\x1b[<35+;21;5M;21;5Mappears as typed text\x1b[<35;20;5Mhellohellosilently losthello→ keyboardTest plan
parseAllMouseEventsWithOffsetcovering split sequences, partial detection, mixed data, and chunk reassemblyFixes https://github.com/anomalyco/opencode/issues/8614
Related: https://github.com/anomalyco/opencode/issues/7316, https://github.com/anomalyco/opencode/issues/11636
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.