Skip to content

fix(core): publish policy update on auto-edit transition Removes an early return in updatePolicy to ensure the UPDATE_POLICY message is broadcast when entering AUTO_EDIT mode.#19074

Open
ahsanfarooq210 wants to merge 2 commits intogoogle-gemini:mainfrom
ahsanfarooq210:fix/allow-for-session-persistence

Conversation

@ahsanfarooq210
Copy link

Summary for #18727

Fixes a bug where "Allow for this session" for edit tools (write_file, edit) wasn't persisting the permission, causing repeated prompts. The issue occurred because the code was returning early after setting AUTO_EDIT mode, skipping the session rule creation.

Details

  • Root Cause: In updatePolicy(), when handling edit tools with "Allow for this session", the code was setting AUTO_EDIT mode but then returning early, preventing the session rule from being created.
  • Fix: Removed the early return after setting AUTO_EDIT mode, allowing the policy update to proceed and create the session rule.
  • Impact: Users will no longer see repeated prompts for the same edit tool after selecting "Allow for this session".

Related Issues

Fixes #18727

How to Validate

  1. Use an edit tool (e.g., write_file, edit) in the CLI
  2. When prompted for permission, select "Allow for this session"
  3. Use the same tool again in the same session
  4. Expected: No permission prompt should appear for subsequent uses in the same session
  5. Edge Case: Verify that AUTO_EDIT mode is still properly set for edit tools

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
    • Updated test case to verify both AUTO_EDIT mode and policy update
  • Noted breaking changes (if any) - N/A (bug fix only)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Removes an early return in `updatePolicy` to ensure the `UPDATE_POLICY` message is broadcast when entering `AUTO_EDIT` mode.
@ahsanfarooq210 ahsanfarooq210 requested a review from a team as a code owner February 14, 2026 15:40
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ahsanfarooq210, 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 critical bug preventing session-based permissions for edit tools from persisting. By modifying the updatePolicy function to remove a premature exit, it ensures that the necessary policy updates are fully processed and broadcast, thereby eliminating repetitive permission prompts for users who select "Allow for this session."

Highlights

  • Bug Fix: Session Persistence for Edit Tools: Resolved an issue where "Allow for this session" for edit tools (e.g., write_file, edit) did not persist permissions, leading to repeated prompts. This was caused by an early return preventing the session rule from being created.
  • Policy Update Broadcast: Ensured that the UPDATE_POLICY message is correctly broadcast when transitioning to AUTO_EDIT mode, by removing an early return in the updatePolicy function.
  • Test Coverage Enhanced: Updated existing tests to verify that AUTO_EDIT mode is set and the policy update is published, confirming the fix.
Changelog
  • packages/core/src/scheduler/policy.test.ts
    • Updated the test description for updatePolicy to reflect the new behavior of publishing policy updates.
    • Added an assertion to verify that mockMessageBus.publish is called with the UPDATE_POLICY type when AUTO_EDIT mode is set.
  • packages/core/src/scheduler/policy.ts
    • Removed an early return statement within the isAutoEditTransition block in the updatePolicy function, allowing subsequent policy update logic to execute.
Activity
  • The author updated relevant documentation and README (if needed).
  • Tests were added/updated, including a new test case to verify both AUTO_EDIT mode and policy updates.
  • The changes were validated on MacOS using npm run.
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.

Copy link
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 correctly fixes a bug where session-level permissions for edit tools were not being persisted. Removing the early return in updatePolicy ensures that the policy update message is correctly published. The change is logical and directly addresses the issue. However, I've noticed a potential issue in the accompanying test case where an incorrect tool name is used, which could cause the test to fail or not accurately verify the intended behavior. Please see my detailed comment.

@gemini-cli gemini-cli bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality area/security Issues related to security labels Feb 14, 2026
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 area/security Issues related to security priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Already selected allow for this session, but still prompted for each operation

1 participant