Skip to content

fix(cli): prevent settings escape key from cancelling active turn#22788

Closed
JayadityaGit wants to merge 3 commits intogoogle-gemini:mainfrom
JayadityaGit:fix-settings-escape-propagation
Closed

fix(cli): prevent settings escape key from cancelling active turn#22788
JayadityaGit wants to merge 3 commits intogoogle-gemini:mainfrom
JayadityaGit:fix-settings-escape-propagation

Conversation

@JayadityaGit
Copy link
Copy Markdown
Contributor

Summary

Fixes an issue where pressing Escape to close the /settings dialog (or any dialog using BaseSettingsDialog such as /agent) inadvertently cancels an active background stream request because the keypress event is not fully consumed.

Details

In BaseSettingsDialog.tsx's useKeypress hook, the handler was returning implicitly (return; which is undefined). This caused KeypressContext to treat the event as unhandled, allowing it to bubble up to the global Escape handler in useGeminiStream which cancels the active turn. I've updated the handler to explicitly return true; when keys are consumed.

Related Issues

Fixes #22787

How to Validate

  1. Run Gemini CLI and issue a long-running request.
  2. Immediately type /settings to open the Settings dialog.
  3. Press Escape to close the dialog.
  4. Verify that the settings dialog closes but the background response is not cancelled.
  5. Also verified with unit tests: npm test -w @google/gemini-cli -- src/ui/components/shared/BaseSettingsDialog.test.tsx

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • Linux
      • npm run

@JayadityaGit JayadityaGit requested a review from a team as a code owner March 17, 2026 12:42
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 resolves an issue where pressing the Escape key to close a dialog, such as the settings dialog, would unintentionally cancel any active background stream requests. The fix ensures that keypress events are properly handled and consumed within the dialog's context, preventing them from bubbling up and triggering global listeners that could lead to unexpected behavior. This improves the reliability of user interactions with the CLI.

Highlights

  • Event Handling: Modified keypress handlers in BaseSettingsDialog.tsx to explicitly return true when an event is consumed, preventing the Escape key from inadvertently cancelling active background streams.
Changelog
  • packages/cli/src/ui/components/shared/BaseSettingsDialog.tsx
    • Updated keypress handlers to explicitly return true when an event is handled.
    • Changed the final default return from an implicit undefined to false to clearly indicate unhandled events.
Activity
  • No human activity has been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 fixes a bug where the Escape key in settings dialogs was not being fully consumed, leading to unintended side effects like cancelling background requests. The change modifies the keypress handler in BaseSettingsDialog.tsx to explicitly return true for handled key events, which stops event propagation. All instances where a keypress is handled are updated to reflect this, and the final return is changed to false for unhandled keys, improving clarity.

@JayadityaGit
Copy link
Copy Markdown
Contributor Author

JayadityaGit commented Mar 17, 2026

normally slash commands are not allowed to be executed during a running request

but there are some commands which are considered safe and one of them is /settings giving luxury to user to change settings in middle of their work is proccessing

but in a case when request is still being processed and the user executes /settings and presses esc, it closes the dialog but also cancels the ongoing request which is not intended

this PR makes that propagation not occur. now it only closes the dialog, not canceling the ongoing request.

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Mar 17, 2026
@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Apr 1, 2026

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!

@gemini-cli gemini-cli bot closed this Apr 1, 2026
@JayadityaGit
Copy link
Copy Markdown
Contributor Author

Hey @jackwotherspoon !!

some time ago, I was assigned for this issue by you, can you have a look at this 😄?

thanks for your time ⏰!!

@psinha40898
Copy link
Copy Markdown
Contributor

psinha40898 commented Apr 8, 2026

This was a great catch and should be looked at. I have some notes regarding the situation in general.

  • Most slash commands, including theme, simply do not allow usage during a pending request. I wonder if this is the robust approach, and the actual bug is the Settings Dialog appearing at all during pending requests instead of showing "slash commands cannot be queued"

tldr: Should dialogs like settings be able to activate during ongoing requests? (e.g, should these dialogs behave like theme does, or like how settings does)?

Answering that question should let us know what this PR should really be.

either way, a PR to consolidate the UX seems like a good move.

CC @keithguerin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(cli): /settings escape key cancels active turn

2 participants