Skip to content

fix(cli): restore YOLO mode after exiting Plan mode-new - #19625

Closed
Manik-Khajuria-5 wants to merge 1 commit into
google-gemini:mainfrom
Manik-Khajuria-5:fix/restore-yolo-after-exit-plan-mode-new
Closed

fix(cli): restore YOLO mode after exiting Plan mode-new#19625
Manik-Khajuria-5 wants to merge 1 commit into
google-gemini:mainfrom
Manik-Khajuria-5:fix/restore-yolo-after-exit-plan-mode-new

Conversation

@Manik-Khajuria-5

@Manik-Khajuria-5 Manik-Khajuria-5 commented Feb 20, 2026

Copy link
Copy Markdown

Fixes #19592

Problem

When starting with gemini --yolo, entering Plan mode (Shift+Tab) and then exiting with Shift+Tab always returned to Default/Manual instead of YOLO. Tool execution then required confirmation instead of staying auto-approved.

Solution

  • Initial mode at startup: On first run, the hook records the current approval mode (YOLO when started with --yolo, otherwise DEFAULT). This is used when leaving Plan so we restore the right mode.
  • Exiting Plan: When leaving Plan via Shift+Tab, we restore the mode that was active at CLI open (YOLO or DEFAULT) instead of always restoring DEFAULT.
  • Cycle behavior:
    • YOLO sequence (started with --yolo): YOLO → DEFAULT → AUTO_EDIT → PLAN → YOLO (repeat).
    • Default sequence: DEFAULT → PLAN → AUTO_EDIT → DEFAULT (repeat).
  • From YOLO, Shift+Tab goes to DEFAULT so the full cycle (including Plan) is still available.

Changes

  • packages/cli/src/ui/hooks/useApprovalModeIndicator.ts: Added initialModeRef to capture mode at CLI open; cycle logic uses it so Plan exit restores YOLO or DEFAULT and the two sequences above are correct.
  • packages/cli/src/ui/hooks/useApprovalModeIndicator.test.ts: Tests for YOLO restore after Plan, default sequence (DEFAULT → PLAN → AUTO_EDIT → DEFAULT), and updated expectations for initial getApprovalMode call count and cycle behavior.

Testing

  • npm run preflight (or npm run test in packages/cli) — all tests pass.

  • Manual: Start with gemini --yolo, press Shift+Tab until Plan, then Shift+Tab again → returns to YOLO.

  • 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

@Manik-Khajuria-5
Manik-Khajuria-5 requested a review from a team as a code owner February 20, 2026 09:00
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Manik-Khajuria-5, 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 an issue where the CLI's approval mode would incorrectly revert to Default after exiting Plan mode, even when initially launched in YOLO mode. The changes introduce a robust mechanism to remember the initial approval state and ensure that exiting Plan mode restores the correct, original approval setting, thereby maintaining the intended user experience for YOLO mode users.

Highlights

  • YOLO Mode Restoration: Implemented a fix to ensure that when the CLI is started with --yolo and the user enters and then exits Plan mode (Shift+Tab), the approval mode correctly reverts to YOLO instead of defaulting to Manual/Default.
  • Initial Mode Capture: Introduced a mechanism to capture the initial approval mode (YOLO or DEFAULT) when the CLI starts, which is then used to determine the correct mode to restore after exiting Plan mode.
  • Approval Mode Cycle Logic: Refined the cycling behavior for approval modes (YOLO, DEFAULT, AUTO_EDIT, PLAN) to support two distinct sequences: one for when starting in YOLO mode and another for the default sequence, ensuring consistent transitions.
  • Test Coverage: Added new tests and updated existing ones to validate the YOLO mode restoration after exiting Plan mode, as well as to confirm the correct cycling behavior for both YOLO and default sequences.
Changelog
  • packages/cli/src/ui/hooks/useApprovalModeIndicator.test.ts
    • Updated expected call counts for mockConfigInstance.getApprovalMode in several initialization tests to reflect a new useEffect hook.
    • Modified test expectations for cycling from YOLO mode via Shift+Tab, changing the expected next mode from AUTO_EDIT to DEFAULT.
    • Added new test cases to verify the correct restoration of YOLO mode after cycling through Plan mode.
    • Included a new test to confirm the complete default approval mode sequence (DEFAULT -> PLAN -> AUTO_EDIT -> DEFAULT).
  • packages/cli/src/ui/hooks/useApprovalModeIndicator.ts
    • Imported the useRef hook from React.
    • Added initialModeRef to store the approval mode active at the CLI's initial startup.
    • Implemented a useEffect hook to initialize initialModeRef once, ensuring PLAN mode is treated as DEFAULT for initial state capture.
    • Revised the approval mode cycling logic within the useKeypress handler to incorporate initialModeRef and differentiate between YOLO and default cycling sequences.
    • Removed redundant comments related to state updates and central handler notifications.
Activity
  • The author identified a problem where YOLO mode was not restored after exiting Plan mode.
  • A solution was proposed involving capturing the initial approval mode and adjusting the cycling logic.
  • Changes were implemented in useApprovalModeIndicator.ts and corresponding tests in useApprovalModeIndicator.test.ts.
  • Testing instructions were provided, including running npm run preflight and manual verification steps.
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 successfully addresses an issue where YOLO mode was not correctly restored after exiting Plan mode. The solution involves tracking the initial approval mode and implementing separate cycling logic for sessions started in YOLO mode versus default mode. The changes are well-tested with new test cases covering both scenarios. I have one suggestion to improve performance and code quality in the useApprovalModeIndicator hook, which has been retained as it aligns with general best practices and is not contradicted by any specific rules.

@Manik-Khajuria-5 Manik-Khajuria-5 changed the title fix/restore-yolo-after-exit-plan-mode-new fix(cli): restore YOLO mode after exiting Plan mode-new Feb 20, 2026
@jerop

jerop commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

This is fixed in #19570 where we removed EnterPlanMode tool from YOLO mode - we want to be careful about switching to YOLO without user action

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

Labels

size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YOLO mode is disabled after exiting Plan mode

3 participants