fix: gate scroll-sync workarounds to normal buffer so alt-screen TUIs own scroll#132
Merged
Merged
Conversation
… own scroll xterm 5.5 viewport scroll-sync workarounds (wheelPreSync/recovery/clamp, manualSync, syncBufferToScrollbar, jump-to-bottom arrow) target the normal scrollback buffer but ran unconditionally. Full-screen TUIs (vim, less, htop, Copilot CLI's full-screen scrollbar) run in the alternate buffer with no scrollback and own their scrolling, so the workarounds had nothing useful to do there and could fight the app's own scrollbar. Add isNormalBuffer(term) and early-return from each workaround in alt-screen. Wheel->PTY forwarding (attachCustomWheelEventHandler) is untouched, so the app's scrollbar still receives wheel input. Adds e2e coverage for alt-screen gating. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
CI note: the red E2E check is pre-existing on
|
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.
Related to #130 (scrolling occasionally disabled / scrollbar disappears mid-session). This PR addresses the alt-screen/full-screen-TUI manifestation; see Follow-ups for the normal-buffer cases that may also contribute to #130.
Problem
Scrolling sometimes "gets stuck" in tmax. The file
TerminalPanel.tsxcarries a battery of xterm 5.5 Viewport scroll-sync workarounds (wheelPreSyncHandler,wheelRecoveryHandler,wheelClampHandler,manualSyncHandler,syncBufferToScrollbar, and thecomputeScrolledAwayjump-to-bottom arrow). These are all written for the normal scrollback buffer, but they ran unconditionally.When a full-screen TUI runs in a pane — vim, less, htop, and notably GitHub Copilot CLI v1.0.61, which just added its own full-screen scrollbar — the terminal switches to the alternate buffer, which has no scrollback and where the app owns its own scrolling. The workarounds had nothing useful to do there and could interfere with the app''s own scrollbar.
Fix
isNormalBuffer(term) => term.buffer.active.type === 'normal'.Wheel-to-PTY forwarding (
attachCustomWheelEventHandler, gated onmouseTrackingMode !== 'none' && baseY === 0) is untouched, so the app''s scrollbar still receives wheel input. The change is public-API only (buffer.active.type) — it touches no xterm internals.Tests
tests/e2e/task-altscreen-scroll-gating.spec.ts(2 tests, both green):tsc --noEmit: no new errors.Review
Reviewed by a 10-agent model fleet (Opus 4.8 / 4.7 / 4.7-xhigh, Sonnet 4.6, GPT-5.5, MAI). Code-review verdicts: 5/5 approve.
Follow-ups (not in this PR)
SmoothScrollableElementand removed the private fields this workaround pile depends on — upgrading would let most of these handlers be deleted outright. This is the durable fix for the bug class (and likely the remaining normal-buffer part of Tmax scrolling is occasionally disabled #130).onBinary-> PTY forwarding (TASK-184) is currently reverted onmain, so this gating is sufficient for SGR apps (Copilot CLI / Ink) but not for default-encoded mouse reports after a pane split. Tracked separately.