fix(cli): ensure dialogs stay scrolled to bottom in alternate buffer mode#20527
fix(cli): ensure dialogs stay scrolled to bottom in alternate buffer mode#20527
Conversation
… change for the bottom item in a list.
|
Hi @jacob314, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this. We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines. Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed. Thank you for your understanding and for being a part of our community! |
|
You already have 7 pull requests open. Please work on getting existing PRs merged before opening more. |
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 significantly enhances the scrolling experience in CLI dialogs by ensuring that content consistently remains scrolled to the bottom when new information appears or existing content changes size. This is achieved through the adoption of Highlights
Changelog
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 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 counter productive. 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-executed refactoring of the Scrollable and VirtualizedList components to improve scrolling behavior, particularly the 'stick to bottom' functionality. The transition from useLayoutEffect with measureElement to using ResizeObserver is a major improvement for performance and reliability. The new regression tests are also excellent and cover important edge cases. I have one suggestion to remove a piece of redundant logic that could introduce subtle bugs.
| if (wasAtBottom && actualScrollTop >= prevScrollTop.current) { | ||
| setIsStickingToBottom(true); | ||
| } |
There was a problem hiding this comment.
This logic for initiating the "sticking" behavior appears to be redundant and potentially incorrect. The wasAtBottom variable is calculated based on the state from the previous render, which means this condition won't trigger when a user scrolls to the bottom for the first time. The imperative scroll methods (scrollBy, scrollTo, scrollToEnd) already correctly handle setting isStickingToBottom when a scroll action reaches the end of the list. This block can be safely removed to avoid redundancy and prevent this latent bug.
|
Thank you for linking an issue! This pull request has been automatically reopened. |
|
Size Change: +3.89 kB (+0.02%) Total Size: 25.7 MB
ℹ️ View Unchanged
|
jerop
left a comment
There was a problem hiding this comment.
tested and works well, thanks!
Summary
Fix behavior so scroll to bottom is robust and optimize ScrollableList positions using ResizeObserver.
ScrollableandVirtualizedList) have been updated to more reliably maintain a 'scrolled to bottom' state, especially when content dynamically changes or resizes. This addresses issues where dialogs might not stay at the bottom in alternate buffer mode.ResizeObserverinScrollableandVirtualizedListto accurately detect changes in content and container dimensions. This replaces previous manual measurement methods, leading to more responsive and accurate scroll calculations.ScrollableandVirtualizedListto useNumber.MAX_SAFE_INTEGERas a robust indicator for 'scroll to end', ensuring consistent behavior when new items are added or existing items change size.Scrollable,ScrollableList, andVirtualizedListto cover various dynamic content scenarios, including item additions, removals, and resizing, ensuring the improved scroll-to-bottom functionality is stable.Demo of fixed behavior:
https://screencast.googleplex.com/cast/NTYwNTk4NTIxNjM2NDU0NHw3YmRjOTIwYi03OQ
Fixes #18700
Details: switch to using ResizeObserver instead of using useLayoutEffect for size measurement as using useLayoutEffect would miss when components resized. ResizeObserver was recently added to the ink for and behaves like ResizeObserver on the web.