fix(cli): hide shortcuts hint while model is thinking or the user has typed a prompt + add debounce to avoid flicker#19389
Conversation
|
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! |
Summary of ChangesHello @jacob314, 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 enhances the user experience of the CLI composer by intelligently managing the visibility of the shortcuts hint. By hiding the hint when the model is processing or when the input buffer contains text, and by introducing a debounce for its appearance, the UI becomes less distracting and more responsive to user interaction, leading to a cleaner and more intuitive interface. Highlights
Changelog
Activity
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 logic to hide the shortcuts hint while the model is responding or when the input buffer is not empty, and adds a debounce to the hint's appearance. The changes look good and are supported by new tests.
I've found a potential UI flicker bug in the implementation of the debounce logic and provided a suggestion to fix it. This change will also make the hint's appearance more consistent.
| const [showShortcutsHintDebounced, setShowShortcutsHintDebounced] = | ||
| useState(canShowShortcutsHint); |
There was a problem hiding this comment.
Initializing showShortcutsHintDebounced with canShowShortcutsHint can lead to a UI flicker.
Here's the scenario:
- On initial render, if
canShowShortcutsHintistrue, the state is initialized totrueand the hint is shown immediately. - If the user then performs an action that makes
canShowShortcutsHintbecomefalse(like typing a character), the component re-renders. - During this re-render,
showShortcutsHintDebouncedis stilltruefrom the previous state, so the hint is incorrectly rendered for one frame. - The
useEffectthen runs and sets the state tofalse, triggering another re-render to hide the hint.
This causes a flicker.
By initializing the state to false, you ensure the debounce logic is applied consistently, even on the initial render, and it fixes this flicker bug. This will introduce a 200ms delay before the hint appears for the first time, which is a reasonable trade-off for a smoother user experience.
| const [showShortcutsHintDebounced, setShowShortcutsHintDebounced] = | |
| useState(canShowShortcutsHint); | |
| const [showShortcutsHintDebounced, setShowShortcutsHintDebounced] = | |
| useState(false); |
There was a problem hiding this comment.
initial render tends to be with an empty prompt so would create more flicker if we did this.
|
Size Change: +610 B (0%) Total Size: 25.7 MB ℹ️ View Unchanged
|
|
I've pushed up some commits locally to address some strict testing rules. Let me know if you would like me to push my changes up directly. |
ed93f4d to
8ab92a1
Compare
… typed a prompt + add debounce to avoid flicker (google-gemini#19389)
… typed a prompt + add debounce to avoid flicker (google-gemini#19389)
… typed a prompt + add debounce to avoid flicker (google-gemini#19389)
… typed a prompt + add debounce to avoid flicker (#19389)
Summary
New behavior in alternate buffer mode:
https://screencast.googleplex.com/cast/NjYzMDg0OTEwNDU3NjUxMnw2MGQyYjgyNC1kMg
Demo of undesired bounce when not in alternate buffer mode:
https://screencast.googleplex.com/cast/NjczNjYzMzg4MDY0MTUzNnwxYjgwYWQxOS0zNQ
To repro:
Verify the hint now properly goes away when the model is thinking and goes away when the input prompt is not empty.
Verify that there is no flicker of the hint showing up when you press enter when the input prompt is small.
Fixes #19386