fix: harden CLI interrupt handling for shell mode and chat compression#21683
fix: harden CLI interrupt handling for shell mode and chat compression#21683chrisjcthomas wants to merge 5 commits intogoogle-gemini:mainfrom
Conversation
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 robustness of the Gemini CLI's interrupt handling mechanisms. It addresses critical scenarios where user input, such as pressing "Escape" or "Ctrl+C", did not behave as expected, leading to unintended cancellations of background processes or API calls. The changes ensure a more predictable and reliable user experience by correctly propagating cancellation signals and refining input interpretations. 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 hardens interrupt handling in the CLI, which is a great improvement for user experience. The changes correctly propagate the abortSignal for chat compression and fix an issue with the Escape key in shell mode. I've identified a potential issue where the removal of a fallback for the abortSignal could make the chat compression service less robust, potentially hindering cancellability. My review includes suggestions to address this by ensuring AbortSignals are consistently propagated, aligning with best practices for asynchronous operations.
Note: Security Review did not run due to the size of the PR.
Addresses gemini-code-assist review: restore the nullish coalescing fallback (`?? new AbortController().signal`) to ensure `generateContent` always receives a valid AbortSignal, even when `compress()` is called without one.
chrisjcthomas
left a comment
There was a problem hiding this comment.
Thanks for catching this! Both instances have been fixed in commit b133082 — the ?? new AbortController().signal fallback has been restored on both generateContent calls to ensure a valid AbortSignal is always provided, even when compress() is called without one.
|
@jkcinouye I cleaned up the stale Gemini review threads on this PR and updated the description to match the current scope. If you have a chance, I’d appreciate a review. |
|
@g-samroberts adding you here as well since you had context on #21679. I cleaned up the stale Gemini review threads and updated the description to match the current scope; if you have a chance, I’d appreciate a review. |
|
Thank you for your interest in contributing to the project! We are closing this PR as the issue was already fixed. |
This PR improves how Gemini CLI handles user interruptions via
EscapeandCtrl+Cto ensure a more consistent and reliable user experience.Improvements
Escapewhile in shell mode (typing a!command) would accidentally cancel ongoing background agent requests. Now,Escapecorrectly exits shell mode without affecting the agent.abortSignalfrom the current turn into theChatCompressionService. This ensures that when a user cancels a request (e.g., viaCtrl+C), any in-flight API calls for chat summarization/compression are also immediately aborted.Verification
Escapein shell mode no longer cancels background thoughts.abortSignalis correctly passed fromAppContainerthroughGeminiClientandLocalExecutorinto the compression service.Closes #20615