fix(cli): stabilize resetFileSearchState closure in useAtCompletion#24971
fix(cli): stabilize resetFileSearchState closure in useAtCompletion#24971spencer426 wants to merge 1 commit intomainfrom
Conversation
|
Hi @spencer426, 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, 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 memory management issue within the useAtCompletion hook. By stabilizing the resetFileSearchState function, the changes ensure that event listeners and effects do not retain stale references to component state, improving the overall stability and memory footprint of the CLI UI. 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. Footnotes
|
|
You already have 7 pull requests open. Please work on getting existing PRs merged before opening more. |
There was a problem hiding this comment.
Code Review
This pull request updates the useAtCompletion hook in packages/cli to wrap the resetFileSearchState function in a useCallback hook. It also updates the dependency arrays of related useEffect hooks to include resetFileSearchState, ensuring stable function identity and correct effect execution. I have no feedback to provide.
Summary
Stabilizes the
resetFileSearchStateclosure inuseAtCompletionto prevent stale React Fiber nodes from being kept alive in memory.Details
In
useAtCompletion.ts,resetFileSearchStatecaptured an initial stale closure to the Ink/React FiberNodes and held it forever in the global workspace context event listener. Wrapping the function inuseCallbackensures a stable, non-stale closure.This is 4 of 4 atomic PRs split from the monolithic memory leak PR #24963.
Related Issues
Pre-Merge Checklist