fix(ui): revert preview theme on dialog unmount#22542
fix(ui): revert preview theme on dialog unmount#22542JayadityaGit wants to merge 4 commits intogoogle-gemini:mainfrom
Conversation
- Track original theme on mount - Revert to original theme if unmounted without a selection - Add test case verifying reversion behavior Addresses an issue where exiting the CLI while previewing a theme leaves the preview theme applied to the terminal state.
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 addresses a bug where previewed themes in the CLI's Theme Dialog would incorrectly remain active after the application was exited without the user explicitly selecting a theme. The changes ensure that the terminal's appearance consistently reflects the user's saved theme upon exit, even if a theme was being previewed. 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 correctly fixes a bug where a previewed theme would persist after quitting the CLI. The use of a useEffect cleanup hook in ThemeDialog is a good approach to ensure the theme is reverted on unmount. However, the current implementation introduces a subtle bug due to a stale closure, where it may revert to an outdated theme if settings change while the dialog is open. I've provided a comment with a suggested fix to address this. The accompanying test and the change to the quit command handler are appropriate.
|
I self reviewd my changes so that it will be easier for reviewers to understand why I did those changes |
There was a problem hiding this comment.
Some food for thought
useEffect shouldn't be used this way. i see two potential paths here
- putting the logic inside an event handler
- a deeper refactor -- this may or may not result in the logic ending up in an event handler (probably yes). i would need to do a deeper review of how this component works
for now I think you could look into whether we can fix this through event handler and also read the linked article.
are there other paths that are properly reverting the preview theme?
I do plan to look at this component deeper within a few days here since it is related to Settings
Removes the useEffect and related useRef hooks used for resetting the theme on unmount in ThemeDialog. The theme reset is already handled correctly by the closeThemeDialog event handler, which is now called explicitly during the application quit sequence. This simplifies the component and adheres to React best practices by relying on event handlers for user-initiated actions.
speaking of settings , I was working on a crucial UX bug i found related to settings, if you are intersted you can check this out #22788 @psinha40898 A new perspective on my changes really helps me out thank you. |
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383). We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'. This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community! |
|
@JayadityaGit, thank you for your contribution! We've reviewed the approach in this PR and decided to keep it closed because using |
|
@cocosheng-g please have a look into it again, i am using existing event handlers here as far as i remember, all the anitpatterns of useffect should be gone, thanks to @psinha40898 |
|
Yes cocosheng I wonder if the stale PR description miscommunicated things iirc the PR is now using the action registry to execute the logic on user press, akin to an event handler @JayadityaGit might be worth updating the PR description too |
|
updated the description . i have deleted my original invalid assumptions to prevent confusion, and kept what is needed. thanks |
Summary
Fixes a bug where quitting the CLI while previewing a theme in the Theme Dialog leaves the preview theme applied globally on exit.
Related Issues
Fixes #22541
How to Validate
npm run start./theme.Enter.Ctrl+Ctwice to exit the CLI.Pre-Merge Checklist