Skip to content

fix(cli): preserve quota-interrupted sessions and stop on Escape - #29799

Draft
seokjeongeum wants to merge 1 commit into
google-gemini:mainfrom
seokjeongeum:fix/quota-history-persistence
Draft

seokjeongeum wants to merge 1 commit into
google-gemini:mainfrom
seokjeongeum:fix/quota-history-persistence

Conversation

@seokjeongeum

@seokjeongeum seokjeongeum commented Oct 17, 2026 •

Copy link
Copy Markdown

Summary

Keep the latest user prompt and completed tool rounds when a request stops for quota or cancellation, so normal quit/signout cleanup does not erase resumable conversation history. One Escape stops the quota retry dialog.

Details

Preserve history for terminal/retryable quota errors and cancellation, and recompute its prompt-token estimate instead of rolling back those turns. Other request failures retain the existing rollback behavior. Escape in the quota dialog chooses Stop and consumes the key once.

Regressions write real JSONL, run normal session cleanup, reload the record, and rebuild the client history. They also cover a completed tool call/result and signout's account-specific thought-signature cleanup. No authentication, public settings-schema, model-catalog, or package-version additions.

Related Issues

User-reported regression; no linked issue.

How to Validate

Validated final head 3ed37a028bf6267cd8a9b97dfe967160a8d1721f, based on upstream ed96faedfd5571f055c44f2c9509d62321d1138d.

  • Core: node node_modules/vitest/vitest.mjs run --root packages/core src/core/geminiChat.test.ts src/core/geminiChat.quota.test.ts src/core/geminiChat_network_retry.test.ts src/services/chatRecordingService.test.ts src/utils/sessionUtils.test.ts src/utils/delay.test.ts --coverage.enabled=false --maxWorkers=1 --minWorkers=1 passes 230/230 on Linux Node 24.21.0 and native Windows Node 24.14.1.
  • CLI: the same Vitest invocation with --root packages/cli and src/ui/components/ProQuotaDialog.test.tsx src/ui/hooks/useQuotaAndFallback.test.ts src/ui/commands/authCommand.test.ts src/ui/commands/quitCommand.test.ts passes 60/60 on both platforms.
  • A separate probe imports compiled production GeminiChat, uses real Config/storage/recording with a fake content generator, and passes three real-file scenarios against source builds and installed core tarballs on Linux and native Windows: terminal quota then normal quit cleanup/resume; retryable quota then cleanup/resume; completed tool round then abort/signout signature cleanup/resume.
  • Actual Linux source and isolated packed-npx terminal launches use a localhost backend returning a 429 with a simulated 3,600-second reset. One Escape stops the request, normal /quit exits 0, and the prompt remains in JSONL. Native Windows actual offline npm-exec from an isolated installed prefix passes the same product assertions, including CLI exit 0 and the saved prompt. Package smoke version/help checks are recorded separately from these feature assertions.
  • Native Windows uses an isolated NTFS checkout and native dependencies. Resolution from the actual compiled CLI entry points to its own core build; its GeminiChat hash matches the intended history change. Packed CLI/core tarballs and resolved paths are checked separately. Native packages use extracted local tarballs and matching native dependency junctions after a bounded registry-install timeout; this does not claim a successful fresh registry installation.
  • Linux build, affected core/CLI typechecks, changed-file ESLint/Prettier, and whitespace checks pass. Native core/test-utils/devtools/CLI build stages and affected focused tests pass; native npm run start -- --version and --help also exit 0 in the isolated checkout. The built artifact image gemini-history-pr29799:3ed37a0 passes all three JSONL cases and the actual npx Escape/quit flow under Linux Node 20.20.2 with external networking disabled. Repeating through native Windows -> WSL Docker also passes; these are Linux containers.
  • Full npm run preflight completed on this head in a disposable Linux checkout under Node 20.19.0 with two Vitest workers. Install/format/build/full lint/all typechecks pass; tracked source remains clean. CLI reports 10 failed, 7,401 passed, 4 skipped; core reports 76 failed, 8,300 passed, 57 skipped. All 86 failing records reproduce on the matching upstream base with the same runtime, dependencies, isolated home, and worker bounds; no candidate-only failure. They concern mocked home/workspace paths, keychain mocks, and unavailable bwrap. Separately, npm run test:scripts passes 202/202 and npm run test:sea-launch passes 17/17.

Native source-fixture limitation: in the unbundled ConPTY run, explicitly choosing Stop and then typing /quit is interpreted as another prompt on both this head and a correctly built/resolved upstream baseline. The matched probes fail identically; this is not counted as a fully passing source quit flow. The native packaged-npx flow and compiled JSONL scenarios pass. The local native terminal helper also retains handles after recording product exit 0; that helper teardown is distinguished from the CLI exit result.

GitHub Testing: CI for this head reports action_required; a maintainer must approve the external-contributor run. Local results do not imply CI passed. macOS/Seatbelt are unavailable. Podman fixtures remain pending because host sudo authentication is unavailable.

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

@github-actions github-actions Bot added the size/l A large sized PR label Oct 17, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/L

  • Lines changed: 466
  • Additions: +430
  • Deletions: -36
  • Files changed: 5

@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 a regression where conversation history was incorrectly rolled back during quota-related interruptions or user cancellations. By adjusting the session management logic, the application now preserves the latest user prompts and completed tool rounds, ensuring that sessions remain resumable after cleanup. Additionally, the CLI quota dialog has been updated to provide a more responsive experience by allowing users to stop the interaction using the Escape key.

Highlights

  • Preserve Conversation History: Modified the chat session logic to retain user prompts and completed tool rounds when a request is interrupted by quota limits or user cancellation, preventing the loss of history during cleanup.
  • Quota Dialog Interaction: Updated the ProQuotaDialog to support stopping the interaction immediately upon pressing the Escape key, improving the user experience during quota-limited scenarios.
  • Improved Error Handling: Updated GeminiChat to handle cancellation and quota errors without rolling back the conversation history, while ensuring token counts are correctly re-estimated.
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 updates the Gemini CLI to improve handling of quota errors and stream cancellations. Key changes include adding an Escape key handler to the ProQuotaDialog to allow users to retry later, updating GeminiChat to preserve user prompts and completed tool rounds when streams are aborted or encounter quota errors, and removing redundant history rollback logic. Comprehensive tests were added to verify session persistence and correct cancellation behavior under various error conditions. There are no review comments to address.

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Oct 18, 2026
@seokjeongeum
seokjeongeum marked this pull request as draft October 19, 2026 01:37
@gemini-cli gemini-cli Bot removed the status/need-issue Pull requests that need to have an associated issue. label Oct 19, 2026
@gemini-cli

gemini-cli Bot commented Oct 25, 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 only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant