feat(cli): scroll the transcript three lines per wheel notch - #1274
Open
kavish-19 wants to merge 1 commit into
Open
feat(cli): scroll the transcript three lines per wheel notch#1274kavish-19 wants to merge 1 commit into
kavish-19 wants to merge 1 commit into
Conversation
Closes CodebuffAI#1268. OpenTUI's ScrollBox multiplies each wheel event's notch delta by whatever its ScrollAcceleration returns, and defaults to LinearScrollAccel, whose tick() returns 1. A terminal reports one notch as a delta of 1, so the transcript moves a single line per notch -- far slower than the three lines terminals and desktop apps use. ScrollBox already accepts a scrollAcceleration option, so this needs no upstream change: the React reconciler spreads JSX props straight into the renderable's constructor, which assigns the field the wheel handler reads. Neither shipped accelerator gives a flat multiplier -- LinearScrollAccel is fixed at 1, MacOSScrollAccel ramps with scroll velocity -- so this adds a small stateless one. Being stateless, a single shared instance is enough, which also keeps the prop's identity stable across renders. Scoped to the chat transcript on purpose. The prompt editor's scrollbox is a few rows tall, where three lines a notch would skip most of its content, so it keeps the one-line default; a test pins that split. Claude-Session: https://claude.ai/code/session_018vPhyqaaoKa8cgs7GEnyq5
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.
Closes #1268.
The cause
The CLI never handles wheel events itself — OpenTUI's
ScrollBoxRenderabledoes:and the constructor defaults to
LinearScrollAccel:A terminal reports one wheel notch as a delta of 1, so
1 × 1moves the transcript a single line. That is the reported behaviour, and it's a default rather than a bug.The change
ScrollBoxalready accepts ascrollAccelerationoption (and exposes a setter), so nothing upstream needs changing — it's a prop on the existing<scrollbox>inchat.tsx. The React reconciler spreads JSX props straight into the renderable's constructor (createInstancein@opentui/react), which assigns the field the wheel handler reads.Neither shipped accelerator gives a flat multiplier:
LinearScrollAccelis fixed at 1, andMacOSScrollAccelramps with scroll velocity, which would make a fast flick jump much further than the three lines the issue asks for. So this adds a small statelessConstantScrollAccel. Because it's stateless there is nothing to accumulate or reset, so one shared instance serves it — which also keeps the prop's identity stable across renders instead of allocating per render.Two decisions worth flagging
Scoped to the chat transcript. There are other scrollboxes — the prompt editor (
multiline-input.tsx) and the landing screen. The editor is a few rows tall, where three lines a notch would skip most of its content, so it keeps the one-line default. A test pins that split so it isn't "fixed" later by accident.Hardcoded, not configurable. The issue asks for 3 to match standard terminal and desktop behaviour, so that's what this does. Happy to put it behind a setting if you'd rather, but that seemed like unrequested surface area.
Verification
mainbaseline — no new ones.tsc --noEmitclean on both touched files.chat.tsxstill failsprettier --check, but only at lines 279 and 931, both of which fail on unmodifiedmaintoo. My lines (100 and 1668) are clean, so I've left it rather than bury the diff in an unrelated reformat.One thing I could not verify locally: I checked the delta→multiplier→
scrollToppath by reading OpenTUI's source rather than by driving a real wheel event, sinceonMouseEventlives in the dependency. Worth a quick manual scroll on your side before porting.