Skip to content

fix(plan): prevent plan truncation in approval dialog by supporting unconstrained heights#21037

Merged
Adib234 merged 23 commits intomainfrom
fix/askuserdialog-height
Mar 10, 2026
Merged

fix(plan): prevent plan truncation in approval dialog by supporting unconstrained heights#21037
Adib234 merged 23 commits intomainfrom
fix/askuserdialog-height

Conversation

@Adib234
Copy link
Contributor

@Adib234 Adib234 commented Mar 4, 2026

Summary

Fixes the plan approval dialog so that it displays the full plan without truncating it at 15 lines. This improves the workflow for reviewing long plans by letting the plan content take up the maximum vertical space available.

Details

  • Adds an unconstrainedHeight?: boolean; property to the Question interface in packages/core/src/confirmation-bus/types.ts.
  • Updates ChoiceQuestionView in packages/cli/src/ui/components/AskUserDialog.tsx to utilize unconstrainedHeight. When true, it dynamically calculates the maximum question height based on the available terminal height and the number of selection items, bypassing the hard-coded 15-line limit.
  • Sets unconstrainedHeight: true on the question object inside ExitPlanModeDialog.tsx.
  • Updates ExitPlanModeDialog snapshot tests to reflect the new un-truncated UI.

Related Issues

Fixes #20716

How to Validate

  1. Run the CLI and enter plan mode: gemini -> /plan
  2. Give a broad prompt that generates a plan longer than 15 lines.
  3. Once the plan finishes, attempt to exit plan mode (/act or Ctrl+C).
  4. Ensure the plan dialog fully expands to show the majority of the plan text, without unnecessarily truncating at 15 lines.
  5. Verify regular AskUserDialog instances (like multi-choice settings dialogs) remain unaffected.

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

@Adib234 Adib234 requested a review from a team as a code owner March 4, 2026 00:34
@gemini-code-assist
Copy link
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 the CLI's plan approval dialog would truncate lengthy plans, displaying only the first 15 lines. The changes implement a flexible height mechanism for dialogs, allowing them to expand and utilize available terminal space to show complete plan content. This enhancement significantly improves the review process for complex or extensive plans by ensuring full visibility.

Highlights

  • Dynamic Dialog Height: Introduced an unconstrainedHeight property to the Question interface, allowing dialogs to dynamically adjust their vertical space instead of being strictly capped.
  • Plan Truncation Fix: Updated the ChoiceQuestionView component to utilize unconstrainedHeight, removing the previous hardcoded 15-line limit for question display and enabling dynamic height calculation based on available terminal space.
  • Exit Plan Mode Dialog Enhancement: Configured the ExitPlanModeDialog to use unconstrainedHeight: true, ensuring that long plans are no longer truncated and are fully visible to the user.
  • Snapshot Test Updates: Adjusted snapshot tests for ExitPlanModeDialog to reflect the new behavior where plan content is fully displayed without truncation.
Changelog
  • packages/cli/src/ui/components/AskUserDialog.tsx
    • Introduced maxQuestionHeight calculation that considers question.unconstrainedHeight and available listHeight.
    • Replaced the fixed 15 line limit with the dynamically calculated maxQuestionHeight for questionHeight.
  • packages/cli/src/ui/components/ExitPlanModeDialog.tsx
    • Set unconstrainedHeight: true for the question object within the ExitPlanModeDialog configuration.
  • packages/cli/src/ui/components/snapshots/ExitPlanModeModeDialog.test.tsx.snap
    • Updated multiple snapshot blocks to reflect the removal of the "... last X lines hidden" message, indicating full plan display.
  • packages/core/src/confirmation-bus/types.ts
    • Added an optional unconstrainedHeight?: boolean; property to the Question interface, along with a JSDoc comment explaining its purpose.
Activity
  • The author provided a clear summary of the problem and the proposed solution.
  • Detailed validation steps were provided, including how to generate a long plan and verify the dialog's behavior.
  • The author confirmed that tests were added/updated and validated the 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 an unconstrainedHeight option to prevent truncation of long content in approval dialogs, which is a great improvement for usability. The implementation is mostly correct, but I've identified a potential issue in the height calculation within the generic AskUserDialog component. The current logic could lead to UI issues in other scenarios with many options. I've provided a suggestion to make the height calculation more robust and future-proof.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Size Change: +119 B (0%)

Total Size: 26.2 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.7 MB +119 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./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

@Adib234 Adib234 marked this pull request as draft March 4, 2026 00:42
@Adib234 Adib234 changed the title fix(cli): prevent plan truncation in approval dialog by supporting unconstrained heights [DRAFT] fix(cli): prevent plan truncation in approval dialog by supporting unconstrained heights Mar 4, 2026
@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 4, 2026
@Adib234 Adib234 changed the title [DRAFT] fix(cli): prevent plan truncation in approval dialog by supporting unconstrained heights fix(plan): prevent plan truncation in approval dialog by supporting unconstrained heights Mar 4, 2026
@Adib234 Adib234 self-assigned this Mar 4, 2026
@Adib234 Adib234 marked this pull request as ready for review March 4, 2026 16:19
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 enhances the Gemini CLI by preventing plan truncation in the approval dialog, introducing an unconstrainedHeight property to the Question interface for dynamic height adjustment and improved user experience. However, this change introduces a critical security vulnerability: an increased risk of terminal escape sequence injection. The LLM-generated plan content is rendered without sanitization, which could allow an attacker to manipulate the terminal UI and trick users into approving malicious actions. It is highly recommended to add sanitization for the plan content before it is displayed.

@Adib234 Adib234 force-pushed the fix/askuserdialog-height branch from 3110789 to 7490f28 Compare March 6, 2026 04:11
@jacob314
Copy link
Contributor

I completely agree with the goal of this PR! Expanding the vertical space for the ExitPlanModeDialog is a great improvement for readability without squishing the dialog options.

However, looking at the code, I noticed the addition of a magic number (+ 4) to artificially increase the maxHeight specifically for exit_plan_mode.

Root Cause:
In AppContainer.tsx, the availableTerminalHeight context value—which ToolConfirmationQueue and HistoryArea rely on to constrain item heights—was artificially shortened. It was previously subtracting 5 lines: staticExtraHeight (3 lines for the AppHeader) + 2 padding lines. But the AppHeader renders inside the scrollable list container, meaning it natively scrolls out of view and doesn't permanently occupy viewport space!

By artificially subtracting those 5 lines from the available container height, all history items (and dialogs within them) were being forced to truncate 5 lines shorter than necessary, leading to the need for the + 4 hack specifically for ExitPlanMode just to reclaim that lost space.

The Fix:
We should fix this at the root by correcting availableTerminalHeight in AppContainer.tsx to precisely represent the scrollable view: terminalHeight - controlsHeight - backgroundShellHeight - 1 (where the 1 is for the bottom margin). Once that is corrected, we can remove the isExitPlanMode + 4 maxHeight conditional block from ToolConfirmationQueue.tsx. Because availableTerminalHeight will accurately model the taller viewport, ToolConfirmationQueue will naturally allocate those 4/5 extra lines to ExitPlanModeDialog and any other dialog or tool result that needs it, without relying on special case logic.

Let me know if you agree with this approach! I have a fix ready locally and can push it to this PR if needed.

@jerop jerop requested a review from jacob314 March 10, 2026 16:57
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

@Adib234 Adib234 enabled auto-merge March 10, 2026 19:33
@Adib234 Adib234 added this pull request to the merge queue Mar 10, 2026
Merged via the queue into main with commit e5615f4 Mar 10, 2026
27 checks passed
@Adib234 Adib234 deleted the fix/askuserdialog-height branch March 10, 2026 19:47
@Adib234
Copy link
Contributor Author

Adib234 commented Mar 10, 2026

/patch preview

@github-actions
Copy link

🚀 [Step 1/4] Patch workflow(s) waiting for approval!

📋 Details:

  • Channels: preview
  • Commit: e5615f47c45730839daec95ca3ca264ef1db4541
  • Workflows Created: 1

⏳ Status: The patch creation workflow has been triggered and is waiting for deployment approval. Please visit the specific workflow links below and approve the runs.

🔗 Track Progress:

github-actions bot pushed a commit that referenced this pull request Mar 10, 2026
…nconstrained heights (#21037)

Co-authored-by: jacob314 <jacob314@gmail.com>
@github-actions
Copy link

🚀 [Step 2/4] Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. Review and approve the hotfix PR: #21922
  2. Once merged, the patch release will automatically trigger
  3. You'll receive updates here when the release completes

🔗 Track Progress:

@github-actions
Copy link

🚀 [Step 3/4] Patch Release Waiting for Approval!

📋 Release Details:

⏳ Status: The patch release has been triggered and is waiting for deployment approval. Please visit the specific workflow run link below and approve the deployment. You'll receive another update when it completes.

🔗 Track Progress:

@github-actions
Copy link

[Step 4/4] Patch Release Complete!

📦 Release Details:

🎉 Status: Your patch has been successfully released and published to npm!

📝 What's Available:

🔗 Links:

JaisalJain pushed a commit to JaisalJain/gemini-cli that referenced this pull request Mar 11, 2026
…nconstrained heights (google-gemini#21037)

Co-authored-by: jacob314 <jacob314@gmail.com>
kunal-10-cloud pushed a commit to kunal-10-cloud/gemini-cli that referenced this pull request Mar 12, 2026
…nconstrained heights (google-gemini#21037)

Co-authored-by: jacob314 <jacob314@gmail.com>
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
…nconstrained heights (google-gemini#21037)

Co-authored-by: jacob314 <jacob314@gmail.com>
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 2026
…nconstrained heights (google-gemini#21037)

Co-authored-by: jacob314 <jacob314@gmail.com>
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. release/patch-to-preview PR needs to be patch to preview release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix truncation of plans in the approval dialog

5 participants