Repository navigation
fix(cli): preserve scroll position and partition pending height budget - #29520
DavidAPierce merged 5 commits into
Conversation
|
📊 PR Size: size/L
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves the stability and predictability of the Gemini CLI user interface. By refining how the terminal handles scroll positions, layout height budgets, and keyboard navigation, it ensures that users can interact with tools and review conversation history without the viewport unexpectedly resetting or collapsing. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic height partitioning between pending history items and the tool confirmation queue in standard buffer mode, improves scroll position preservation, and ensures unconstrained height only collapses on Escape or 'show more lines' commands. The review feedback highlights a potential performance regression where the entire pendingItems element tree and virtualized list are re-created on every render due to the highly dynamic uiState object in the dependency array. To resolve this, the reviewer suggests extracting the UIStateContext.Provider wrapper into a separate helper component to keep the dependency array stable.
- Guard scrollToEnd() in MainContent when confirmingTool updates so it only auto-scrolls if the virtualized list is already pinned to the bottom.
- Partition availableTerminalHeight between visible pendingHistoryItems (40%) and ToolConfirmationQueue (60%) in standard buffer mode to keep combined dynamic output within terminal rows.
- Restrict unconstrained height auto-collapse in AppContainer.handleGlobalKeypress to explicit SHOW_MORE_LINES and ESCAPE commands instead of arbitrary keypresses.
05bc634 to
2870eb7
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic height partitioning and scroll position preservation in the CLI's MainContent component, preventing terminal overflows in standard buffer mode when tool confirmations are active. It also refactors key matching in AppContainer to only collapse unconstrained height on Escape or show-more-lines keys. A critical issue was identified in the height partitioning calculation: because perPendingItemHeight has a minimum constraint of 4, the actual total height allocated to pending items can exceed rawPendingBudget, which can still cause terminal overflows. It is recommended to calculate confirmationQueueBudget using the actual allocated pending height instead.
Note: Security Review did not run due to the size of the PR.
9ff502c to
6c1d608
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic height partitioning and scroll position preservation in the terminal UI. Specifically, it ensures that the terminal does not collapse unconstrained height on navigation keys (only on Escape), checks if the user is at the bottom of the scrollable list before auto-scrolling on tool confirmation, and partitions the available terminal height between pending history items and the tool confirmation queue in standard buffer mode. Feedback was provided regarding the minimum height constraints used during partitioning; enforcing a hard minimum of 4 for pending items and 6 for the confirmation queue can still cause overflows on very small terminals (height < 10), so it is recommended to scale these minimums down to 1 when partitioning.
d3f5074 to
993c4a5
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic height partitioning and scroll position preservation in the terminal UI's MainContent component to prevent terminal overflows and improve the user experience when tool confirmations arrive. It also updates AppContainer to collapse the unconstrained height view when pressing Escape or the show-more-lines key, backed by new unit tests. The reviewer feedback correctly points out that when collapsing this view, the keypress event is not marked as handled, which can cause event leakage and unintended side effects in other components.
1b2531d to
cb55d76
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements dynamic height partitioning between pending history items and the tool confirmation queue in standard buffer mode to prevent terminal overflows, preserves scroll position when tool confirmations arrive, and allows collapsing the expanded view using the Escape key. Feedback highlights two key issues: first, height partitioning should be bypassed in alternate buffer mode to avoid unnecessary truncation of scrollable items; second, the Escape key should only collapse the expanded view when no dialogs are open to prevent swallowing keypresses intended for closing dialogs.
9329da1 to
d6025a9
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces scroll position preservation and dynamic height partitioning in MainContent to prevent terminal overflows, along with logic in AppContainer to handle Escape key collapses only when no dialogs are open. Feedback focuses on refactoring the fragile list of 19 individual dialog state checks in AppContainer by memoizing and reusing dialogsVisible to simplify the keypress handler and its dependency array. Additionally, a potential terminal overflow bug was identified in MainContent's height budget calculation when multiple pending items are present, with a recommendation to use a more precise distribution method like the Largest Remainder Method.
a4bc489 to
f73ddce
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces scroll position preservation and dynamic height partitioning in the CLI's main content view to prevent terminal overflows. Specifically, it updates 'MainContent' to only scroll to the end on new tool confirmations if the user is already at the bottom, and partitions the available terminal height budget between pending history items and the tool confirmation queue when in standard buffer mode. Additionally, it refactors 'AppContainer' to ensure that pressing Escape only collapses the unconstrained height when no dialogs are visible, and adds comprehensive unit tests to verify these behaviors. There are no review comments to address, and I have no additional feedback to provide.
Findings🔴 Critical: Scroll Preservation Guard is Bypassed in Production by
|
0f907d9 to
27244b2
Compare
Done. addressed |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request improves terminal height management, scroll behavior, and key handling in the CLI UI. Key changes include preventing unconstrained height collapse on navigation keys, refining scroll-to-bottom behavior to avoid scrolling when a tool confirmation is pending or when the user has scrolled up, and implementing dynamic height partitioning between pending history items and the tool confirmation queue in standard buffer mode to prevent terminal overflows. Comprehensive unit tests have been added to verify these changes. I have no additional feedback to provide as no review comments were submitted.
Summary
This pull request resolves viewport scroll position resets in
Gemini CLIduring active streaming, tool confirmation prompts, and unconstrained height
inspection. It ensures the terminal viewport remains stable when you scroll up
to review earlier conversation history or expanded code diffs.
Details
Three coordinated UI state and layout adjustments address the underlying causes
of unexpected viewport jumps across both virtualized and standard terminal
buffer modes:
packages/cli/src/ui/components/MainContent.tsx):Guards
scrollableListRef.current?.scrollToEnd()inside theconfirmingTooleffect by inspecting
scrollableListRef.current.getScrollState?.(). The viewnow auto-scrolls to the bottom on confirmation arrival only when the list is
already pinned to the bottom (
scrollHeight - innerHeight - scrollTop <= 1),preserving your scroll position when you inspect earlier turns.
packages/cli/src/ui/components/MainContent.tsx):Partitions
availableTerminalHeightin standard buffer mode whenever visiblependingHistoryItems(items other thanAwaitingApprovaltool calls) andToolConfirmationQueuerender simultaneously. Allocating 40% of the budgetacross visible pending items and 60% to
ToolConfirmationQueuevia a scopedUIStateContext.Providerkeeps the combined dynamic region withinprocess.stdout.rowsand prevents full-screen Ink redraw resets.packages/cli/src/ui/AppContainer.tsx):Restricts the
if (!constrainHeight)auto-collapse branch inhandleGlobalKeypressso that it triggers only on explicitCommand.SHOW_MORE_LINES(Ctrl+OorCtrl+S) orCommand.ESCAPEcommands. Navigation keys such as
PageUp,PageDown, and arrow keys nolonger re-enable
constrainHeightor invokerefreshStatic()while youreview expanded output.
Related Issues
Fixes #5009
How to Validate
Run the automated unit test suites, linter, and type checker to verify the
changes across all affected components.
MainContentunit tests to verify scroll preservation and dynamicheight partitioning:
npm test -w @google/gemini-cli -- src/ui/components/MainContent.test.tsxAppContainerunit tests to verify unconstrained height keyboardhandling:
npm test -w @google/gemini-cli -- src/ui/AppContainer.test.tsxcompatibility with existing layout budgets:
npm test -w @google/gemini-cli -- src/ui/components/ToolConfirmationQueue.test.tsx src/ui/components/ToolConfirmationFullFrame.test.tsxPre-Merge Checklist