Repository navigation
Conversation
…oll reports NSH coalesces scroll reports to one per frame, so the report of an automatic scrollToEnd can arrive after the next output batch already grew the grid. Terminal.tsx re-derived atBottom from that stale offset against the current frame, stopping following without user input. Compute the distance from the geometry the report itself carries (contentSize/size on the ScrollEvent), and let only user scrolling (onScrollIntent/onScrollDragStart) stop or resume following; programmatic reports no longer rewrite the reading state. The decision lives in terminalFollow.ts with a controlled-replay regression. Generated-by: Claude Code
This branch has not been deployed
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.
Summary
The Desktop terminal can stop following output while the viewport is at the bottom and the user has not scrolled: a later output batch grows the grid before the automatic scroll report of an earlier batch is delivered, and the stale report re-derives
atBottomagainst the newer geometry. The pane then stays on an earlier batch (or renders blank) while output continues.The follow decision now reads the geometry each scroll report carries itself, and only user scrolling stops or resumes following.
Fixes #7158
Root cause
third-party/nsh/crates/nsh-core/src/scroll.rsmodule docs), so the report of the follow effect'sscrollToEndfor batch N can arrive after batch N+1 already updated the grid.Terminal.tsx'sonScrollcomputeddistance = frame().totalRows - rows() - floor(event.offset.y / LINE)— the report's old offset against the current frame. With batch N at 30 rows (viewport 24, offset at row 6) and batch N+1 grown to 40 rows, the delayed report yields distance 10 →model.atBottom = false→ the follow effect (Terminal.tsx,effect(() => { … if (model.atBottom) scrollToEnd … })) never scrolls again. This matches the controlled replay in the issue (baseline4cb1415525, viewport stops at the second batch).ScrollEventpayload already snapshots the geometry at report time (contentSize/size, captured innsh-engine'sMessage::Scrollhandling), andTurnPanel/Conversationalready compute their follow distance from that self-consistent geometry. The terminal was the only scroll surface comparing a reported offset against live external state.Fix
app/terminalFollow.ts(pure module, nonshimports, same pattern ascomposerToolbar.ts): distance is computed from the report's owncontentSize/size, so a delayed report is self-consistent by construction.onScrollIntent/onScrollDragStartmark user scrolling (NSH contract: programmatic scrolls emit neither; verified across the macOS, Windows, Linux and TUI backends for wheel, drag, scrollbar-thumb and key scrolls). Programmatic reports no longer rewriteatBottom, so they can neither stop following nor resume it after the user scrolled away. The user returning to the bottom (within one row, as before) resumes following.shift+pageuproutes through the same decision (pageUp()), and a remounted pane restores its reading state frommodel.atBottom.TurnPanelandConversationalready use event-local geometry and user-input gating;QuickQuestionPanelhas no follow logic. No other surface compares scroll offsets against live grid state.Verification
products/maka/workbench/tests/terminal-follow.test.mjs: 6 tests, all passing. The first test inlines the previous decision formula and reproduces the failure on the delayed-report interleaving from the issue (30-row batch, report delivered after the grid grew to 40 rows → following stops, offset 10); the remaining tests cover the fixed behavior: delayed automatic reports keep following, user scroll-away preserves the reading position across later batches, returning to the bottom resumes following, shift+pageup only resumes on user input, and a viewport taller than the output stays at the bottom.node --test products/maka/workbench/tests/*.test.mjs— 255 passed, 0 failed (249 existing + 6 new).biome checkon the three changed files: clean.tsc -p products/maka/bundle/tsconfig.jsonand a standalone stricttscofterminalFollow.ts: pass. ASF header audit andgit diff --check: pass.windows-desktop/nativeCI suites exercise the real renderer. Happy to add a recording once a desktop build is available — opening as draft until the UI evidence is settled.AI use
Select exactly one:
Tool(s) and scope: Claude Code assisted with root-cause analysis (including the NSH scroll-report contract), implementation, regression tests, and PR preparation. The commit carries a
Generated-by: Claude Codetrailer.Checklist
Does this PR entail a breaking change or persisted-data migration?
upgrade_compat.rscoverage under Summary aboveDoes this PR entail a change in behavior?