Skip to content

fix: optimize height calculations for ask_user dialog#19017

Open
jackwotherspoon wants to merge 10 commits intomainfrom
ask-user/ghost-space
Open

fix: optimize height calculations for ask_user dialog#19017
jackwotherspoon wants to merge 10 commits intomainfrom
ask-user/ghost-space

Conversation

@jackwotherspoon
Copy link
Contributor

Summary

Fixes "ghost space" in the ask_user and exit_plan_mode dialogs by optimizing terminal height calculations. This change reclaims approximately 8 lines of vertical space that were previously being redundantly subtracted, allowing for more visible content in interactive prompts.

Details

The investigation revealed that height was being over-subtracted in two layers:

  1. ToolConfirmationQueue: Previously subtracted 6 lines for overhead. Since ask_user hides the "Tool Identity" section, it now correctly only subtracts 4 lines, giving 2 lines back.
  2. ToolConfirmationMessage: Previously subtracted ~6 lines for elements (question prompt, radio options) that it assumes it will render. Since ask_user handles its own UI, these subtractions were redundant and have been removed for tools that manage their own layout.

Related Issues

Related to #18907

How to Validate

  1. Run any tool that triggers an ask_user dialog (e.g., a prompt that requires clarification).
  2. Observe that the dialog utilizes more of the available terminal height.
  3. Verify that truncation logic (scroll arrows or "lines hidden" messages) correctly adapts to the increased space.
  4. Run the UI tests to ensure snapshot consistency:
    npm test -w @google/gemini-cli -- src/ui/components/ToolConfirmationQueue.test.tsx

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on MacOS

@jackwotherspoon jackwotherspoon requested a review from a team as a code owner February 13, 2026 18:46
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Feb 13, 2026

Hi @jackwotherspoon, 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!

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jackwotherspoon, 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 enhances the user interface experience by optimizing how dialogs calculate and utilize available terminal height. The changes ensure that interactive prompts, particularly ask_user and exit_plan_mode, display more content by intelligently adjusting space allocation, leading to a more efficient and less truncated view for users.

Highlights

  • Optimized Dialog Height Calculations: Improved the ask_user and exit_plan_mode dialogs by refining terminal height calculations, eliminating 'ghost space' and reclaiming approximately 8 lines of vertical display.
  • ToolConfirmationQueue Adjustment: Modified the ToolConfirmationQueue component to conditionally subtract 4 lines instead of 6 when the 'Tool Identity' section is hidden, specifically for ask_user and exit_plan_mode dialogs.
  • ToolConfirmationMessage Refinement: Removed redundant height subtractions in ToolConfirmationMessage for tools that manage their own UI layout, ensuring more accurate content display.
Changelog
  • packages/cli/src/ui/components/ToolConfirmationQueue.tsx
    • Reordered variable declarations for isRoutine, borderColor, and hideToolIdentity for better readability.
    • Modified the availableContentHeight calculation to dynamically subtract 4 or 6 lines based on whether the tool identity is hidden, preventing excessive space reservation.
  • packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx
    • Added logic to return the full availableTerminalHeight when a component handles its own UI, preventing unnecessary height subtractions.
    • Included handlesOwnUI in the dependency array of the useMemo hook that calculates contentHeight to ensure correct re-evaluation.
Activity
  • Updated relevant documentation and README (if needed).
  • Added/updated tests (if needed).
  • Validated changes on MacOS.
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
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 introduces optimizations to the terminal height calculations for ask_user and exit_plan_mode dialogs, addressing an issue with "ghost space" and reclaiming vertical screen real estate. The changes in ToolConfirmationQueue.tsx correctly adjust the height subtraction based on whether the tool identity section is visible. In ToolConfirmationMessage.tsx, the height calculation is now bypassed for tools that handle their own UI layout, preventing redundant subtractions. The changes are logical, well-targeted, and align with the goal of improving the layout of interactive prompts. The code quality is good and I don't see any issues.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 13, 2026
@github-actions
Copy link

github-actions bot commented Feb 13, 2026

Size Change: +105 B (0%)

Total Size: 24.4 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.4 MB +105 B (0%)
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

@jerop jerop requested a review from jacob314 February 13, 2026 19:05
Copy link
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

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

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants