fix(ui): pane follows the bottom and scrolls back (cursor-line model)#10
Merged
Conversation
The chat pane stuck to the top: a FormattedTextControl with no cursor defaults to (0,0), and prompt_toolkit scrolls every render to keep that point visible — overriding any manual vertical_scroll, so PageUp/PageDown did nothing and a response taller than the pane hid its newest lines. Drive the pane by exposing its cursor line instead. Following (the default) puts the cursor on the last line, so pt keeps the bottom in view and the pane auto-scrolls as a response streams in. PageUp pins an earlier line (leaving follow mode, so a reader is not yanked down when output appends); PageDown moves back toward the bottom and resumes following once it gets there. The pure _scroll_up/_scroll_down helpers carry the state math and are unit-tested; the live behavior (auto-follow + scroll-back) was verified against a real streaming turn. Mouse-wheel scroll-back is deferred to branch 9 (the wheel's vertical_scroll is re-derived by the cursor-follow each render). DESIGN.md §31.12 updated.
lavindeep
added a commit
that referenced
this pull request
Jul 2, 2026
fix(ui): pane follows the bottom and scrolls back (cursor-line model)
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.
Found by the branch-4 live gate: a response taller than the pane stuck at the top — the newest streamed lines were hidden below the fold, and PageUp/PageDown did nothing.
Cause
The pane's
FormattedTextControlhas no cursor, so prompt_toolkit defaultsUIContent.cursor_positionto(0,0)and_scroll_without_linewrappingsnapsvertical_scrollto keep that point visible every render — overriding any manualvertical_scrollthe old_scroll_paneset.Fix — cursor-line model
Expose the pane's intended line as the FTC cursor (
get_cursor_position); pt scrolls to keep it visible regardless of focus:Pure
_scroll_up/_scroll_downhelpers hold the state math (5 new unit tests). Mouse-wheel scroll-back deferred to branch 9 (NOTE in code + DESIGN).Verification
mypy --strict, 1339 passed.