Skip to content

fix(cli): restore debounced static UI refresh on terminal width changes - #29644

Open
jvargassanchez-dot wants to merge 1 commit into
google-gemini:mainfrom
jvargassanchez-dot:b_568045332
Open

jvargassanchez-dot wants to merge 1 commit into
google-gemini:mainfrom
jvargassanchez-dot:b_568045332

Conversation

@jvargassanchez-dot

Copy link
Copy Markdown
Contributor

Summary

Restores the debounced refreshStatic() effect on terminalWidth changes in AppContainer.tsx (using a 100ms debounce) so that horizontal terminal resize events in default inline rendering mode clear wrapped frame remnants (ansiEscapes.clearTerminal) and remount the <Static> history region at the updated column width.

Details

  • packages/cli/src/ui/AppContainer.tsx:
    • In default inline mode (ui.useAlternateBuffer: false and ui.terminalBuffer: false), narrowing the terminal width causes full-width lines in the dynamic Composer region (────, ▄▄▄▄, ▀▀▀▀) to soft-wrap across multiple physical terminal rows. Because Ink's log-update renderer erases previousLineCount logical lines rather than the wrapped physical row count, the top portion of the previous dynamic frame remains in scrollback during resize events.
    • Restores isInitialMount (useRef(true)) and a 100ms debounced useEffect watching [terminalWidth, refreshStatic] to clear the terminal and increment historyRemountKey once horizontal resizing settles.
    • Scopes the dependency array strictly to terminalWidth (excluding terminalHeight) so vertical-only terminal dimension changes (such as mobile virtual keyboard toggles) do not trigger <Static> remounts.
  • packages/cli/src/ui/AppContainer.test.tsx:
    • Adds unit test coverage verifying that AppContainer skips refreshStatic() on initial mount and on height-only dimension changes, debounces rapid terminalWidth updates by 100ms, and writes ansiEscapes.clearTerminal while incrementing historyRemountKey in default inline mode.

Related Issues

How to Validate

  1. Run the AppContainer unit test suite:
    npm test -w @google/gemini-cli -- src/ui/AppContainer.test.tsx
  2. Manually start Gemini CLI in default inline mode, type a prompt into the input box, resize the terminal window horizontally, and verify that after 100ms the terminal clears any wrapped line remnants and re-renders cleanly at the new width.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • [ x] Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • [ x] Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • [ x] Linux
      • [ x] npm run
      • npx
      • Docker

@jvargassanchez-dot
jvargassanchez-dot requested a review from a team as a code owner October 5, 2026 18:58
@github-actions github-actions Bot added the size/m A medium sized PR label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 99
  • Additions: +99
  • Deletions: -0
  • Files changed: 2

@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 rendering artifacts in the CLI's default inline mode that occur when the terminal window is resized horizontally. By implementing a debounced refresh mechanism, the application now correctly clears wrapped line remnants and remounts the static history region only after the resize operation has stabilized, ensuring a clean UI state.

Highlights

  • Debounced UI Refresh: Restored a 100ms debounced effect in AppContainer.tsx that triggers refreshStatic() upon terminal width changes to ensure proper rendering in inline mode.
  • Resize Logic Optimization: Scoped the resize effect to strictly monitor terminalWidth, preventing unnecessary re-renders during vertical-only dimension changes like mobile keyboard toggles.
  • Test Coverage: Added comprehensive unit tests to verify debounce behavior, initial mount handling, and correct filtering of height-only resize events.
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 the 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 counterproductive. 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.

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-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a debouncing mechanism for refreshing the static terminal UI when the terminal width changes. Specifically, in AppContainer.tsx, a new useEffect hook debounces calls to refreshStatic by 100ms upon changes to terminalWidth, while ignoring the initial mount using an isInitialMount ref. Additionally, corresponding unit tests have been added in AppContainer.test.tsx to verify that refreshStatic is correctly debounced on width changes and ignores height-only changes. There are no review comments, and I have no feedback to provide.

This branch has not been deployed

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

Labels

priority/p1 Important and should be addressed in the near term. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant