Skip to content

fix(core): throttle shell text output UI updates - #22843

Closed
nbardy wants to merge 1 commit into
google-gemini:mainfrom
nbardy:fix/shell-output-throttle
Closed

fix(core): throttle shell text output UI updates#22843
nbardy wants to merge 1 commit into
google-gemini:mainfrom
nbardy:fix/shell-output-throttle

Conversation

@nbardy

@nbardy nbardy commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Shell tool text output (data events) triggered a React re-render on every chunk, while binary_progress already throttled to 1s intervals via OUTPUT_UPDATE_INTERVAL_MS
  • Commands that produce thousands of lines (e.g. build warnings, manifest generation with ~2000 duplicate warnings) caused the UI to freeze — each line forced a full re-render of the shell output panel
  • Apply the same OUTPUT_UPDATE_INTERVAL_MS throttle to text data events. The final output is unaffected — it is rendered from the complete result after the command exits

Test plan

  • Verified existing shell.test.ts tests are unaffected (only test using type: 'data' is for background mode which already skips updateOutput)
  • Manual test: run a command that produces high-volume output (e.g. for i in $(seq 1 5000); do echo "line $i"; done) and verify the UI remains responsive
  • Verify final output after command completion is still complete and correct

🤖 Generated with Claude Code

@nbardy
nbardy requested a review from a team as a code owner March 17, 2026 19: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 significantly enhances the user interface's responsiveness when handling shell commands that produce a large amount of text output. By introducing a throttling mechanism for text data events, it prevents the UI from freezing due to excessive re-renders, thereby improving the overall user experience without compromising the accuracy or completeness of the displayed information.

Highlights

  • UI Responsiveness: Addressed UI freezing issues caused by frequent React re-renders during high-volume shell text output.
  • Throttling Mechanism: Implemented throttling for shell text data events using the existing OUTPUT_UPDATE_INTERVAL_MS to limit UI updates.
  • Output Integrity: Ensured that the final shell output remains complete and correct, as it is rendered only after the command exits.
Changelog
  • packages/core/src/tools/shell.ts
    • Implemented throttling logic for 'data' events to prevent frequent UI updates.
    • Added comments explaining the purpose of the new throttling mechanism.
Activity
  • Verified that existing shell.test.ts tests remain unaffected by the changes.
  • Suggested manual testing for commands producing high-volume output to confirm UI responsiveness.
  • Suggested manual testing to verify the completeness and correctness of the final output after command completion.
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-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 aims to improve UI performance by throttling shell output updates, which is a valuable enhancement. However, the current implementation introduces a functional regression for non-PTY shell executions. By overwriting the output with each chunk instead of accumulating it, intermediate output is lost during the throttled live updates. I've provided a critical review comment with a code suggestion to address this issue by correctly handling both string-based (cumulative) and object-based (overwrite) output types.

Comment thread packages/core/src/tools/shell.ts Outdated
@@ -241,7 +241,13 @@ export class ShellToolInvocation extends BaseToolInvocation<
case 'data':
if (isBinaryStream) break;
cumulativeOutput = event.chunk;

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.

critical

The current implementation overwrites cumulativeOutput with each new event.chunk. While this is correct for PTY executions where event.chunk represents the full terminal state (AnsiOutput), it is incorrect for non-PTY (child_process) executions where event.chunk is a partial string of the output. With the new throttling logic, any intermediate chunks received between UI updates will be lost, leading to an incomplete and choppy live view of the command's output.

To fix this, you should accumulate the output for string-based chunks, while continuing to overwrite for AnsiOutput chunks.

Suggested change
cumulativeOutput = event.chunk;
if (typeof event.chunk === 'string') {
cumulativeOutput = (cumulativeOutput as string) + event.chunk;
} else {
cumulativeOutput = event.chunk;
}

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.

This was fixed in the latest commit

@nbardy
nbardy force-pushed the fix/shell-output-throttle branch from 8cfd982 to 1af4345 Compare March 17, 2026 19:35
@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Mar 17, 2026
Improves shell tool output accumulation. By accurately buffering the text stream and accumulating chunks, it prevents the terminal UI from freezing or lagging during high-volume text streams (e.g. verbose build commands) without losing intermediate output chunks.
@nbardy
nbardy force-pushed the fix/shell-output-throttle branch from 9502704 to 7f69803 Compare March 20, 2026 11:34
@gemini-cli

gemini-cli Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community!

@nbardy

nbardy commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Tracking issue filed: #25459. Cannot reopen this PR (GitHub blocks it — branch is far behind base). Will open a fresh PR against current main referencing the issue.

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

Labels

size/s A small PR 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