Skip to content

fix(cli): resolve duplicate footer on tool cancel via ESC (#21743)#21781

Merged
ruomengz merged 1 commit intomainfrom
fix/21743-esc-double-footer
Mar 18, 2026
Merged

fix(cli): resolve duplicate footer on tool cancel via ESC (#21743)#21781
ruomengz merged 1 commit intomainfrom
fix/21743-esc-double-footer

Conversation

@ruomengz
Copy link
Copy Markdown
Contributor

@ruomengz ruomengz commented Mar 9, 2026

Summary

This PR fixes an issue where the CLI footer would duplicate when cancelling a tool confirmation using the ESCAPE key.

Details

  • CLI Fix: Updated ToolConfirmationMessage to call handleConfirm inside useEffect. This ensures the appContainer first updates constrainHeight and then unmounts ToolConfirmationMessage.
  • Testing: Added unit tests to ToolConfirmationMessage.test.tsx covering the ESC sync confirmation behavior.

Related Issues

Fixes #21743

How to Validate

  1. Run a command that triggers a tool confirmation (e.g., npm run start and ask to write a file).
  2. Ask "Can you ask me a dummy question that is at least 50 lines, and trigger ask_user tool to ask me to accept it".
  3. ctrl+O to expand the content
  4. ESC to cancel the confirmation.
  5. Verify the tool is cancelled and the footer rendering is correct (no duplication).
  6. Run the new tests: npm test -w @google/gemini-cli -- src/ui/components/messages/ToolConfirmationMessage.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:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@ruomengz ruomengz requested a review from a team as a code owner March 9, 2026 22:28
@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 addresses a visual bug in the CLI where cancelling a tool confirmation with the ESC key led to a duplicated footer. The changes ensure that the UI state related to height constraints is correctly reset and the display is refreshed, providing a consistent and clean user interface experience.

Highlights

  • CLI Footer Fix: Resolved an issue where the CLI footer would duplicate when a tool confirmation was cancelled using the ESC key.
  • UI State Management: Updated the ToolConfirmationMessage component to reset the constrainHeight property to true and trigger a static UI refresh when the ESC key is pressed, ensuring correct layout recalculation.
  • Testing: Added new unit tests to ToolConfirmationMessage.test.tsx to cover the ESC key behavior and its interaction with constrainHeight.
Changelog
  • packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx
    • Imported ToolConfirmationOutcome for use in tests.
    • Added new test cases to verify that pressing the ESC key correctly cancels the tool confirmation and resets the constrainHeight UI state.
  • packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx
    • Imported useUIActions and useUIState hooks to manage UI state.
    • Integrated uiActions and constrainHeight into the component's logic.
    • Added conditional logic to the ESC key handler to reset constrainHeight to true and call refreshStatic if constrainHeight was previously false.
Activity
  • Added/updated tests.
  • Validated on required platforms/methods: MacOS (npm run).
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.

@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Mar 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 9, 2026

Size Change: +211 B (0%)

Total Size: 26.2 MB

Filename Size Change
./bundle/chunk-BO7MPMFL.js 0 B -3.63 MB (removed) 🏆
./bundle/chunk-FLYFLPJB.js 0 B -13.5 MB (removed) 🏆
./bundle/core-SQM7HWWD.js 0 B -41.4 kB (removed) 🏆
./bundle/devtoolsService-LY7REQFS.js 0 B -27.7 kB (removed) 🏆
./bundle/interactiveCli-SOVPBWA2.js 0 B -1.61 MB (removed) 🏆
./bundle/oauth2-provider-FKFTWIMH.js 0 B -9.19 kB (removed) 🏆
./bundle/chunk-GIRQ3ZCQ.js 3.63 MB +3.63 MB (new file) 🆕
./bundle/chunk-H4MYRAEJ.js 13.5 MB +13.5 MB (new file) 🆕
./bundle/core-ZOL3X6DB.js 41.4 kB +41.4 kB (new file) 🆕
./bundle/devtoolsService-GT4SC6TJ.js 27.7 kB +27.7 kB (new file) 🆕
./bundle/interactiveCli-6ZR6H3DF.js 1.61 MB +1.61 MB (new file) 🆕
./bundle/oauth2-provider-GN52TALK.js 9.19 kB +9.19 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
./bundle/chunk-34MYV7JD.js 2.45 kB
./bundle/chunk-37ZTTFQF.js 966 kB
./bundle/chunk-5AUYMPVF.js 858 B
./bundle/chunk-664ZODQF.js 124 kB
./bundle/chunk-DAHVX5MI.js 206 kB
./bundle/chunk-G4TMH6EN.js 1.95 MB
./bundle/chunk-IUUIT4SU.js 56.5 kB
./bundle/chunk-RJTRUG2J.js 39.8 kB
./bundle/devtools-36NN55EP.js 696 kB
./bundle/dist-T73EYRDX.js 356 B
./bundle/gemini.js 696 kB
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB
./bundle/memoryDiscovery-KKSSU3SI.js 922 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB
./bundle/sandbox-macos-strict-open.sb 4.82 kB
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB
./bundle/src-QVCVGIUX.js 47 kB
./bundle/tree-sitter-7U6MW5PS.js 274 kB
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB
./bundle/undici-4X2YZID5.js 360 B

compressed-size-action

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 addresses a UI issue where the CLI footer would duplicate when cancelling a tool confirmation using the ESC key. The fix involves updating the ToolConfirmationMessage component to reset constrainHeight to true and trigger a static refresh when ESC is pressed, ensuring correct layout recalculation. New unit tests have been added to cover this specific ESC key behavior and its interaction with constrainHeight.

My primary feedback concerns the use of magic numbers in the newly added test cases, which can lead to flaky tests and impact maintainability.

@ruomengz ruomengz force-pushed the fix/21743-esc-double-footer branch from ffd8c65 to 843c70a Compare March 9, 2026 22:44
@jerop
Copy link
Copy Markdown
Contributor

jerop commented Mar 10, 2026

I have reviewed this PR using the /review-frontend command. Here are the observations based on our strict development rules:

  • Test Hygiene: Please add vi.restoreAllMocks() to the afterEach block in ToolConfirmationMessage.test.tsx to prevent potential test pollution, as required by our guidelines.
  • Async Testing: Consider wrapping vi.runAllTimersAsync() in act() in your tests to ensure state updates are properly handled.
  • State Management: The use of setTimeout in ToolConfirmationMessage.tsx to delay setConstrainHeight and refreshStatic is a bit of a code smell. Our guidelines favor using reducers for state transitions and avoiding setState triggers in callbacks. Could this layout reset be handled more deterministically?

Otherwise, the fix correctly addresses the footer duplication issue and the PR title follows our conventional commit standards.

@ruomengz ruomengz force-pushed the fix/21743-esc-double-footer branch 2 times, most recently from 152df12 to 9d3540c Compare March 10, 2026 17:20
@jerop jerop requested a review from jacob314 March 10, 2026 18:11
@ruomengz ruomengz force-pushed the fix/21743-esc-double-footer branch from 9d3540c to 75f6f1b Compare March 10, 2026 18:15
{ isActive: isFocused, priority: true },
);

useEffect(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already code in AppContainer calling refreshStatic when appropriate on changes to constrainHeight. Please make these changes there instead of adding this logic here.
Also make sure we are only doing this when not in alternate buffer mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Once I moved the handleConfirm to useEffect, the constrainHeight is actually set by handleGlobalKeypress in AppContainer.

@ruomengz ruomengz force-pushed the fix/21743-esc-double-footer branch from 75f6f1b to ef0a6bf Compare March 11, 2026 01:04
@ruomengz ruomengz changed the title fix(cli): reset constrainHeight on ESC in tool confirmation (#21743) fix(cli): resolve duplicate footer on tool cancel via ESC (#21743) Mar 11, 2026
@ruomengz ruomengz force-pushed the fix/21743-esc-double-footer branch from ef0a6bf to d812c25 Compare March 11, 2026 01:22
@jerop jerop requested a review from jacob314 March 12, 2026 01:07
@ruomengz ruomengz requested review from a team as code owners March 13, 2026 14:51
@ruomengz ruomengz force-pushed the fix/21743-esc-double-footer branch from a6108a6 to 72db16e Compare March 13, 2026 14:53
@ruomengz ruomengz removed the request for review from a team March 13, 2026 14:53
@ruomengz ruomengz force-pushed the fix/21743-esc-double-footer branch 2 times, most recently from e408d7d to a6ffecb Compare March 18, 2026 19:24
Copy link
Copy Markdown
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

The ToolConfirmationMessage component previously suffered from a race condition
where cancelling a tool confirmation via the ESC key would synchronously call
handleConfirm. This caused the component to be abruptly unmounted before Ink
could flush its final render frame, resulting in UI glitches like duplicate
footers.
@ruomengz ruomengz force-pushed the fix/21743-esc-double-footer branch from a6ffecb to 414ccb4 Compare March 18, 2026 19:58
@ruomengz ruomengz added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit 94e6bf8 Mar 18, 2026
27 checks passed
@ruomengz ruomengz deleted the fix/21743-esc-double-footer branch March 18, 2026 20:42
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 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix plan mode render double footer when ESC exit from expanded plan

3 participants