-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Fix React render loops and side effects in InputPrompt and AppContainer #14263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix React render loops and side effects in InputPrompt and AppContainer #14263
Conversation
Summary of ChangesHello @maximmasiutin, 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 stability of the application's user interface by resolving critical issues related to React render loops and side effects. It specifically targets and eliminates the "Cannot update a component while rendering a different component" error, which was leading to UI instability. The changes involve refactoring how state updates and side effects are managed within the InputPrompt and AppContainer components, ensuring that these operations occur in a controlled manner outside of the render phase. 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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly identifies and fixes critical React rendering issues. Moving the setShellExecutionConfig call into a useEffect in AppContainer.tsx is the right approach to prevent side effects during rendering. Similarly, the change in InputPrompt.tsx resolves an infinite render loop. I've included a suggestion for InputPrompt.tsx to make the fix more efficient and align with React best practices.
|
If you would like to proceed with this pr let me know and I'll review after merge conflicts are resolved. |
|
Hi there! Thank you for your contribution to Gemini CLI. We really appreciate the time and effort you've put into this pull request. To keep our backlog manageable and ensure we're focusing on current priorities, we are closing pull requests that haven't seen maintainer activity for 30 days. Currently, the team is prioritizing work associated with 🔒 maintainer only or help wanted issues. If you believe this change is still critical, please feel free to comment with updated details. Otherwise, we encourage contributors to focus on open issues labeled as help wanted. Thank you for your understanding! |
Summary
Fixes #14660 - the recurring
Cannot update a component ('InputPrompt') while rendering a different component ('AppContainer')error. This addresses critical UI instability caused by infinite render loops and side effects occurring during the render phase.Details
InputPrompt.tsx: Replaces an unstableuseEffectdependency (dirsChanged) with a stable deep comparison of the directory list. This implements the fix currently suggested indocs/troubleshooting.mddirectly into the codebase. The useEffect hook is refactored to use deep comparison for directory updates instead of an unstable dependency, effectively stopping infinite render loops.AppContainer.tsx: Moves theconfig.setShellExecutionConfig()call out of the render body and into auseEffecthook. This prevents illegal state mutations during the render phase. The config.setShellExecutionConfig call is moved from the main render body into a useEffect hook to prevent illegal state mutations during renderingRelated Issues
Directly related (render loop/UI instability): #14678 [OPEN] (Infinite re-render loop warnings in Gemini CLI debug console - reports "severe infinite loop React state management bugs")
As such, the list of fixes is:
InputPrompt) while rendering a different component (AppContainer) #12149 (closed but same error)Also fixes 14660, #13000, closes #12607.
How to Validate
npm run buildand start the CLI.AppContainerre-renders).Cannot update a component...no longer appears.Pre-Merge Checklist