Skip to content

feat: allow queuing messages during compression (#24071)#26506

Merged
Adib234 merged 2 commits intomainfrom
issue-24071-v2
May 5, 2026
Merged

feat: allow queuing messages during compression (#24071)#26506
Adib234 merged 2 commits intomainfrom
issue-24071-v2

Conversation

@cocosheng-g
Copy link
Copy Markdown
Contributor

Summary

This PR allows users to queue messages while chat history compression is running. It introduces a highly robust, derived-state design that requires minimal changes to the existing architecture, completely avoiding state conflicts and duplicate loading indicators.

Details

To enable seamless background maintenance, the /compress command has been updated to execute asynchronously. This immediately releases the global isProcessing UI lock, allowing the user to interact with the input prompt without being blocked.

Crucially, rather than passing a fragile new boolean state throughout the application, the isCompressing state is now purely derived from the existing pendingHistoryItems list (specifically looking for an active MessageType.COMPRESSION item).

  • Minimal Architecture Change: slashCommandProcessor, useGeminiStream, and the core StreamingState enum retain their exact original behaviors. No new Context values or global states were added.
  • Robust UI Resolution: Because isCompressing is derived from the history item (which renders its own inline spinner), the global LoadingIndicator ("Thinking...") naturally stays hidden since the streamingState remains Idle. This completely solves the duplicate loading indicator bug.
  • No Steering Hint Conflicts: Messages submitted during compression are routed into useMessageQueue. Because isAgentRunning correctly evaluates to false (as streamingState is Idle and no tools are executing), there is zero risk of triggering the model steering hint logic.

Key Changes:

  • compressCommand.ts: Wrapped the compression try/catch in a non-awaited asynchronous IIFE.
  • AppContainer.tsx: Derived isCompressing from pendingHistoryItems. Updated handleFinalSubmit to route input into the queue when this state is active.
  • useMessageQueue.ts: Updated to accept a shouldQueue boolean, generalizing the hook to queue during any active background system task (like compression).
  • AppContainer.test.tsx: Added a comprehensive unit test verifying that messages are queued during compression without triggering steering hints.

Related Issues

Closes #24071

How to Validate

  1. Open the CLI in interactive mode.
  2. Run /compress.
  3. Verify the input prompt remains active and only the "Compressing chat history..." inline spinner is visible (no duplicate "Thinking..." indicator).
  4. Type and submit a message while compression is running.
  5. Verify the message is queued.
  6. Wait for compression to finish and confirm the queued message is automatically sent.

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

@cocosheng-g cocosheng-g requested a review from a team as a code owner May 5, 2026 15:47
@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 improves the user experience during chat history compression by enabling background execution. By shifting to an asynchronous model and utilizing derived state, the application now allows users to queue messages while compression is in progress, avoiding UI blocks and resolving issues with conflicting loading indicators.

Highlights

  • Asynchronous Compression: Updated the /compress command to execute asynchronously, preventing the UI from locking and allowing users to continue interacting with the input prompt.
  • Derived State Implementation: Introduced an isCompressing state derived from pendingHistoryItems, eliminating the need for new global state variables and preventing duplicate loading indicators.
  • Message Queuing: Updated useMessageQueue to support queuing messages while background tasks like compression are active, ensuring a seamless user experience.
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.

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 introduces logic to queue user messages while a background chat history compression task is active, preventing concurrent state modifications. Key changes include the addition of an isCompressing state in the AppContainer, updates to the useMessageQueue hook to pause processing during compression, and a refactor of the compressCommand to handle execution asynchronously. Feedback highlights the need to also queue slash commands during compression to maintain total state consistency and suggests refining the management of the pendingItem state in compressCommand to avoid UI glitches during concurrent command executions.

Comment thread packages/cli/src/ui/AppContainer.tsx
Comment thread packages/cli/src/ui/commands/compressCommand.ts
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Size Change: +458 B (0%)

Total Size: 34 MB

Filename Size Change
./bundle/chunk-2FYZLGZO.js 0 B -14.7 MB (removed) 🏆
./bundle/chunk-2MLCQYIU.js 0 B -3.43 kB (removed) 🏆
./bundle/chunk-6DHHNIXI.js 0 B -2.78 MB (removed) 🏆
./bundle/chunk-7DI4UAL6.js 0 B -19.5 kB (removed) 🏆
./bundle/chunk-GEBXPFA6.js 0 B -49.2 kB (removed) 🏆
./bundle/chunk-L2OLO656.js 0 B -658 kB (removed) 🏆
./bundle/chunk-NGHAFHYE.js 0 B -12.5 kB (removed) 🏆
./bundle/chunk-TMUJBMM7.js 0 B -3.8 kB (removed) 🏆
./bundle/core-7VDBELN5.js 0 B -48.7 kB (removed) 🏆
./bundle/devtoolsService-EVVM3TTM.js 0 B -28 kB (removed) 🏆
./bundle/gemini-73AHUN36.js 0 B -583 kB (removed) 🏆
./bundle/interactiveCli-BJ5ZUZGL.js 0 B -1.29 MB (removed) 🏆
./bundle/liteRtServerManager-WZ5RGPME.js 0 B -2.11 kB (removed) 🏆
./bundle/oauth2-provider-HSPEWCTQ.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-3TVLDQIG.js 658 kB +658 kB (new file) 🆕
./bundle/chunk-BPLV577G.js 12.5 kB +12.5 kB (new file) 🆕
./bundle/chunk-HAFYFJYX.js 49.2 kB +49.2 kB (new file) 🆕
./bundle/chunk-RRIKXCLV.js 3.8 kB +3.8 kB (new file) 🆕
./bundle/chunk-SWGSXAAF.js 14.7 MB +14.7 MB (new file) 🆕
./bundle/chunk-T4IPIXLL.js 19.5 kB +19.5 kB (new file) 🆕
./bundle/chunk-UQY45MV6.js 3.43 kB +3.43 kB (new file) 🆕
./bundle/chunk-VMSBGJDR.js 2.78 MB +2.78 MB (new file) 🆕
./bundle/core-XBWLFVSR.js 48.7 kB +48.7 kB (new file) 🆕
./bundle/devtoolsService-5BOVYHVG.js 28 kB +28 kB (new file) 🆕
./bundle/gemini-EMWV3PBN.js 583 kB +583 kB (new file) 🆕
./bundle/interactiveCli-3DYCZG6Y.js 1.29 MB +1.29 MB (new file) 🆕
./bundle/liteRtServerManager-MURS7LBE.js 2.11 kB +2.11 kB (new file) 🆕
./bundle/oauth2-provider-UCMSZRQT.js 9.16 kB +9.16 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/bundled/third_party/index.js 8 MB 0 B
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-5PS3AYFU.js 1.18 kB 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-ECNYAST2.js 1.97 MB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/cleanup-D7NOHH5C.js 0 B -932 B (removed) 🏆
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-T73EYRDX.js 356 B 0 B
./bundle/events-XB7DADIJ.js 418 B 0 B
./bundle/examples/hooks/scripts/on-start.js 188 B 0 B
./bundle/examples/mcp-server/example.js 1.43 kB 0 B
./bundle/gemini.js 5.1 kB 0 B
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/memoryDiscovery-FB7MMKTA.js 980 B 0 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 222 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 229 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 13.4 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
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/start-DDL5MGZA.js 0 B -652 B (removed) 🏆
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/cleanup-6PIKKM65.js 932 B +932 B (new file) 🆕
./bundle/start-YPRFFC4B.js 652 B +652 B (new file) 🆕

compressed-size-action

@cocosheng-g cocosheng-g force-pushed the issue-24071-v2 branch 3 times, most recently from 5d8924b to aebbca4 Compare May 5, 2026 16:17
@cocosheng-g
Copy link
Copy Markdown
Contributor Author

/gemini review

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 transitions the chat history compression process into an asynchronous background task and implements a queuing system for user inputs during active compression. Changes include the introduction of an "isCompressing" state in AppContainer and logic in useMessageQueue to defer message processing. Feedback highlights that slash commands are currently being queued alongside regular messages, which unnecessarily blocks immediate system commands like /quit or /help; it is recommended to allow these commands to bypass the compression check to ensure the CLI remains responsive.

Comment thread packages/cli/src/ui/AppContainer.tsx
@gemini-cli gemini-cli Bot added priority/p3 Backlog - a good idea but not currently a priority. area/core Issues related to User Interface, OS Support, Core Functionality labels May 5, 2026
@cocosheng-g cocosheng-g force-pushed the issue-24071-v2 branch 3 times, most recently from 74eb2de to c191344 Compare May 5, 2026 17:00
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Size Change: +464 B (0%)

Total Size: 34 MB

Filename Size Change
./bundle/chunk-2FYZLGZO.js 0 B -14.7 MB (removed) 🏆
./bundle/chunk-2MLCQYIU.js 0 B -3.43 kB (removed) 🏆
./bundle/chunk-6DHHNIXI.js 0 B -2.78 MB (removed) 🏆
./bundle/chunk-7DI4UAL6.js 0 B -19.5 kB (removed) 🏆
./bundle/chunk-GEBXPFA6.js 0 B -49.2 kB (removed) 🏆
./bundle/chunk-L2OLO656.js 0 B -658 kB (removed) 🏆
./bundle/chunk-NGHAFHYE.js 0 B -12.5 kB (removed) 🏆
./bundle/chunk-TMUJBMM7.js 0 B -3.8 kB (removed) 🏆
./bundle/core-7VDBELN5.js 0 B -48.7 kB (removed) 🏆
./bundle/devtoolsService-EVVM3TTM.js 0 B -28 kB (removed) 🏆
./bundle/gemini-73AHUN36.js 0 B -583 kB (removed) 🏆
./bundle/interactiveCli-BJ5ZUZGL.js 0 B -1.29 MB (removed) 🏆
./bundle/liteRtServerManager-WZ5RGPME.js 0 B -2.11 kB (removed) 🏆
./bundle/oauth2-provider-HSPEWCTQ.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-5WP2PS5C.js 14.7 MB +14.7 MB (new file) 🆕
./bundle/chunk-CEWUEIH5.js 2.78 MB +2.78 MB (new file) 🆕
./bundle/chunk-G62XFPLM.js 658 kB +658 kB (new file) 🆕
./bundle/chunk-H3NJY662.js 3.43 kB +3.43 kB (new file) 🆕
./bundle/chunk-JFC77IYS.js 3.8 kB +3.8 kB (new file) 🆕
./bundle/chunk-JS6XAXGG.js 19.5 kB +19.5 kB (new file) 🆕
./bundle/chunk-OGVO7HIR.js 12.5 kB +12.5 kB (new file) 🆕
./bundle/chunk-ZCR6XXGF.js 49.2 kB +49.2 kB (new file) 🆕
./bundle/core-RGOL7QMV.js 48.7 kB +48.7 kB (new file) 🆕
./bundle/devtoolsService-D2I45FIQ.js 28 kB +28 kB (new file) 🆕
./bundle/gemini-4DP6LJ3E.js 583 kB +583 kB (new file) 🆕
./bundle/interactiveCli-J2YKGTWR.js 1.29 MB +1.29 MB (new file) 🆕
./bundle/liteRtServerManager-VYXY47WS.js 2.11 kB +2.11 kB (new file) 🆕
./bundle/oauth2-provider-JZ6SDXTJ.js 9.16 kB +9.16 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/bundled/third_party/index.js 8 MB 0 B
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-5PS3AYFU.js 1.18 kB 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-ECNYAST2.js 1.97 MB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/cleanup-D7NOHH5C.js 0 B -932 B (removed) 🏆
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-T73EYRDX.js 356 B 0 B
./bundle/events-XB7DADIJ.js 418 B 0 B
./bundle/examples/hooks/scripts/on-start.js 188 B 0 B
./bundle/examples/mcp-server/example.js 1.43 kB 0 B
./bundle/gemini.js 5.1 kB 0 B
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/memoryDiscovery-FB7MMKTA.js 980 B 0 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 222 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 229 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 13.4 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
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/start-DDL5MGZA.js 0 B -652 B (removed) 🏆
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/cleanup-GUSDMO75.js 932 B +932 B (new file) 🆕
./bundle/start-3G2FI3EH.js 652 B +652 B (new file) 🆕

compressed-size-action

@cocosheng-g
Copy link
Copy Markdown
Contributor Author

/gemini review

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 message queuing during chat history compression to prevent UI blocking and ensure message order. It introduces an isCompressing state in AppContainer and updates the useMessageQueue hook to defer query submission until compression is complete. The compressCommand was also updated to run its logic in a non-blocking background task. The reviewer suggests restoring the async keyword to the compressCommand action to maintain type compatibility with the SlashCommand interface.

Comment thread packages/cli/src/ui/commands/compressCommand.ts Outdated
@Adib234 Adib234 enabled auto-merge May 5, 2026 17:52
@Adib234 Adib234 added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit e80d7cc May 5, 2026
27 checks passed
@Adib234 Adib234 deleted the issue-24071-v2 branch May 5, 2026 18:48
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 priority/p3 Backlog - a good idea but not currently a priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let users queue a message while compression is running

2 participants