fix(tui): preserve scroll position when tasks complete and scroll faster#31898
Merged
AgentEnder merged 3 commits intomasterfrom Jul 16, 2025
Merged
fix(tui): preserve scroll position when tasks complete and scroll faster#31898AgentEnder merged 3 commits intomasterfrom
AgentEnder merged 3 commits intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
7ed67ee to
bbd4466
Compare
Contributor
|
View your CI Pipeline Execution ↗ for commit 8203d47
☁️ Nx Cloud last updated this comment at |
FrozenPandaz
approved these changes
Jul 15, 2025
bbd4466 to
12af492
Compare
When a task completes, the TUI would trigger a resize operation on all PTY instances, causing the scroll position of the currently viewed task to reset to the bottom. This was particularly jarring when viewing long task output while other tasks completed in the background. The root cause was two-fold: 1. `print_task_terminal_output` would create new PTY instances for completed tasks, losing any existing scroll state 2. The `resize` method would always recreate the parser and reset scroll position, even when dimensions hadn't changed Fixed by: - Preserving existing PTY instances when appending final task output - Skipping resize operations when dimensions haven't actually changed - Intelligently preserving scroll position during necessary resize operations This ensures that users can scroll through task output without having their view position disrupted by unrelated task completions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Refactored scrolling logic to provide momentum-based scrolling across all terminal interactions. When users scroll rapidly (keyboard or mouse), the scroll speed increases progressively, making it much faster to navigate through long task output. Key changes: - Created reusable `ScrollMomentum` struct that tracks timing and direction - Momentum builds when scrolling within 150ms intervals (max 20 lines/scroll) - Resets when direction changes or 150ms timeout is exceeded - Applied to both terminal pane scrolling and PTY interactive arrow keys - Unified scroll behavior across keyboard (arrows, j/k, ctrl+u/d) and mouse This provides a much smoother experience when reviewing long build logs or test output, allowing users to quickly scroll to different sections while maintaining fine control for precise navigation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
12af492 to
8203d47
Compare
Contributor
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Current Behavior
Scroll position gets reset when unrelated tasks finish. Additionally, scrolling is just really slow.
Expected Behavior
This pull request introduces momentum-based scrolling and improves scroll position preservation across terminal panes and pseudo-terminal instances (
PtyInstance). It also adds a newScrollMomentummodule to manage scrolling behavior dynamically based on user input patterns. The changes enhance user experience by making scrolling smoother and more intuitive, especially during rapid or sustained scrolling.Scroll Momentum Enhancements:
ScrollMomentummodule to calculate dynamic scrolling behavior based on time intervals and direction changes, allowing for accelerated scrolling during sustained input. (packages/nx/src/native/tui/scroll_momentum.rs, packages/nx/src/native/tui/scroll_momentum.rsR1-R101)TerminalPaneDataandPtyInstance, replacing static scroll methods with dynamic ones (scroll_upandscroll_down) that use calculated momentum values. (packages/nx/src/native/tui/components/terminal_pane.rs, [1];packages/nx/src/native/tui/pty.rs, [2] [3] [4]Scroll Position Preservation:
PtyInstanceto preserve scroll position during terminal resize operations, ensuring better continuity when dimensions change. (packages/nx/src/native/tui/pty.rs, [1] [2]Code Improvements:
packages/nx/src/native/tui/components/terminal_pane.rs, [1];packages/nx/src/native/tui/scroll_momentum.rs, [2]TerminalPaneDataandPtyInstanceconstructors to initializeScrollMomentuminstances for consistent scrolling state management. (packages/nx/src/native/tui/components/terminal_pane.rs, [1];packages/nx/src/native/tui/pty.rs, [2] [3]These changes collectively improve the usability of terminal panes and pseudo-terminal instances by making scrolling more responsive and preserving user context during resize events.
Related Issue(s)
Fixes #