Skip to content

fix(shell): throttle text output updates to prevent UI jank#25643

Open
ixchio wants to merge 1 commit intogoogle-gemini:mainfrom
ixchio:fix/throttle-shell-text-output
Open

fix(shell): throttle text output updates to prevent UI jank#25643
ixchio wants to merge 1 commit intogoogle-gemini:mainfrom
ixchio:fix/throttle-shell-text-output

Conversation

@ixchio
Copy link
Copy Markdown

@ixchio ixchio commented Apr 18, 2026

Quick one — the UI freezes up during high-volume shell output.

What's happening

Every text data event triggers a React re-render. Run something like npm test on a big project or a build with hundreds of warnings, and the UI becomes completely unresponsive. Meanwhile, binary_progress already throttles to OUTPUT_UPDATE_INTERVAL_MS (1 second) — text output just... didn't get the same treatment.

The fix

Applied the same Date.now() - lastUpdateTime > OUTPUT_UPDATE_INTERVAL_MS time-gate to the data case in two places:

  1. packages/core/src/tools/shell.ts — the tool execution path
  2. packages/cli/src/ui/hooks/useExecutionLifecycle.ts — the user shell (! prefix) path

The final output is always delivered via the result object after the command completes, so you never lose anything — you just don't re-render 500 times a second while it's running.

Why not PR #25461?

That PR was flagged for unbounded memory growth in cumulativeOutput accumulation. This fix doesn't change what gets accumulated — it only gates how often we call updateOutput() / setPendingHistoryItem(). The accumulation behavior stays exactly the same.

Total diff is like 8 lines.

Fixes #25459

cc @NTaylorMullen @abhipatel12 this touches your area — thoughts?

@ixchio ixchio requested review from a team as code owners April 18, 2026 22:45
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 18, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 18, 2026

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

@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 UI unresponsiveness caused by high-frequency shell output updates. By introducing a time-gated check for text data events, the application avoids unnecessary re-renders while maintaining the integrity of the final output once command execution completes.

Highlights

  • UI Performance Optimization: Implemented a time-based throttle for shell text output updates to prevent excessive React re-renders during high-volume data streams.
  • Consistent Throttling Logic: Applied the existing OUTPUT_UPDATE_INTERVAL_MS gate to the 'data' event handlers in both the core shell tool and the CLI execution lifecycle hook.
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.

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 implements throttling for UI updates during command execution to prevent excessive re-renders. While the approach addresses performance, the review highlights critical issues: initializing the update timer to the current time causes a delay in showing the first output, binary progress events are missing throttling, and the shell tool logic leads to data loss because output chunks are overwritten rather than accumulated during the throttle window.

Comment thread packages/cli/src/ui/hooks/useExecutionLifecycle.ts Outdated
Comment thread packages/cli/src/ui/hooks/useExecutionLifecycle.ts
Comment thread packages/core/src/tools/shell.ts
@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Apr 18, 2026
Text data events trigger a React re-render on every chunk, while
binary_progress already throttles to OUTPUT_UPDATE_INTERVAL_MS (1s).
High-volume commands like builds with hundreds of warnings make the
UI completely unresponsive.

This applies the same time-gate to text data events in both the core
shell tool and the useExecutionLifecycle hook. The final output is
always delivered via the result object after the command completes,
so nothing gets lost.

Fixes google-gemini#25459
@ixchio ixchio force-pushed the fix/throttle-shell-text-output branch from b546c64 to 9f14b3c Compare April 18, 2026 22:59
@Jordanwaslistening
Copy link
Copy Markdown

Code Review

This pull request implements throttling for UI updates during command execution to prevent excessive re-renders. While the approach addresses performance, the review highlights critical issues: initializing the update timer to the current time causes a delay in showing the first output, binary progress events are missing throttling, and the shell tool logic leads to data loss because output chunks are overwritten rather than accumulated during the throttle window.

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 help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell tool text output causes UI jank on high-volume commands

2 participants