mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-24 20:45:56 +03:00
[PR #749] [CLOSED] fix(core): prevent input starvation from high-frequency mouse scroll events #755
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#755
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/749
Author: @androolloyd
Created: 2/27/2026
Status: ❌ Closed
Base:
main← Head:fix/mouse-scroll-flood-input-starvation📝 Commits (1)
2c83eb5fix(core): prevent input starvation from high-frequency mouse scroll events📊 Changes
4 files changed (+133 additions, -30 deletions)
View changed files
📝
packages/core/src/lib/parse.mouse.test.ts(+67 -13)📝
packages/core/src/lib/parse.mouse.ts(+7 -2)📝
packages/core/src/renderer.ts(+58 -13)📝
packages/core/src/testing/integration.test.ts(+1 -2)📄 Description
Summary
Fixes #748 — high-frequency scroll wheels (Logitech MX Master 3 free-spin) cause keyboard input loss and event loop starvation.
Changes
1. Forward remaining non-mouse data from mixed stdin chunks
stdinListenerpreviously returned early afterhandleMouseDatafound any mouse events, silently dropping non-mouse data (keyboard input, focus-in/out sequences) that arrived in the same OS read. NowhandleMouseDatareturns the consumed byte count andstdinListenerforwards the remainder toStdinBuffer.2. Coalesce consecutive scroll events within a chunk
Added
coalesceScrollEvents()that merges adjacent same-direction scroll events at the same coordinates into a single event with accumulateddelta. This reduces the number of hit tests, MouseEvent constructions, and renderable dispatches from O(n) to O(1) per direction per chunk.3. Return consumed offset from
parseAllMouseEventsChanged
parseAllMouseEventsreturn type fromRawMouseEvent[]to{ events: RawMouseEvent[], consumed: number }so callers know exactly how many bytes were consumed and can handle the remainder appropriately.Testing
parseAllMouseEventstests for new return typeintegration.test.tsfor new return type🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.