Skip to content

Consistently guard restarts against concurrent auto updates#21016

Merged
scidomino merged 1 commit intomainfrom
tomm_relaunch
Mar 4, 2026
Merged

Consistently guard restarts against concurrent auto updates#21016
scidomino merged 1 commit intomainfrom
tomm_relaunch

Conversation

@scidomino
Copy link
Collaborator

@scidomino scidomino commented Mar 3, 2026

Summary

Consistently guard restarts against concurrent auto updates

Details

Also, protect against multiple calls to relaunch.

Related Issues

Fixes #20127

How to Validate

Change a setting that requires restart and verify that it waits for auto update to finish.

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

@scidomino scidomino marked this pull request as ready for review March 3, 2026 21:21
@scidomino scidomino requested a review from a team as a code owner March 3, 2026 21:21
@gemini-code-assist
Copy link
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 refactors the application's restart mechanism to ensure consistent and robust behavior, particularly when dealing with concurrent auto-update processes. By introducing a centralized relaunchApp utility, the PR eliminates scattered restart logic, making the application more resilient to race conditions during updates or configuration changes that necessitate a restart.

Highlights

  • Centralized Restart Logic: Replaced direct calls to process.exit(RELAUNCH_EXIT_CODE) and runExitCleanup() with a new relaunchApp() utility function across multiple UI components.
  • Improved Restart Consistency: Ensured all application restart points now use the centralized relaunchApp() function, which is designed to guard against concurrent auto-updates, leading to more robust behavior.
  • Code Simplification: Removed redundant runExitCleanup() calls and RELAUNCH_EXIT_CODE imports, streamlining the codebase and reducing potential for inconsistencies.
Changelog
  • packages/cli/src/ui/AppContainer.tsx
    • Replaced RELAUNCH_EXIT_CODE import with relaunchApp.
    • Updated Google login restart logic to use relaunchApp.
    • Updated agent acknowledgment restart logic to use relaunchApp.
  • packages/cli/src/ui/auth/AuthDialog.tsx
    • Removed runExitCleanup and RELAUNCH_EXIT_CODE imports.
    • Modified setTimeout callback to directly invoke relaunchApp.
  • packages/cli/src/ui/auth/LoginWithGoogleRestartDialog.tsx
    • Removed runExitCleanup and RELAUNCH_EXIT_CODE imports.
    • Updated restart logic within setTimeout to use relaunchApp.
  • packages/cli/src/ui/components/DialogManager.tsx
    • Removed runExitCleanup and RELAUNCH_EXIT_CODE imports.
    • Updated onRestartRequest prop for SettingsDialog to use relaunchApp.
  • packages/cli/src/ui/components/FolderTrustDialog.tsx
    • Modified setTimeout callback for restarting to directly invoke relaunchApp.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
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.

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Size Change: -292 B (0%)

Total Size: 25.9 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.4 MB -292 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 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

compressed-size-action

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 refactors the application restart logic by introducing a centralized relaunchApp function. This is a good improvement for consistency and maintainability. The new function also correctly waits for any pending auto-updates to complete before restarting, which addresses the main goal of this PR. I've found one potential issue related to the idempotency of the new relaunchApp function, which could lead to race conditions during shutdown. My review comment includes a suggestion to make this function more robust.

Note: Security Review did not run due to the size of the PR.

@gemini-cli gemini-cli bot added priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality labels Mar 3, 2026
@scidomino
Copy link
Collaborator Author

/gemini review

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 refactors the application restart logic to prevent race conditions with auto-updates. A new relaunchApp function is introduced, which centralizes the restart process. This function waits for any ongoing auto-updates to complete before exiting and includes a guard to prevent multiple concurrent relaunch calls. The existing restart call sites throughout the UI components have been updated to use this new utility function. The associated tests have also been updated to mock the new asynchronous relaunch behavior and ensure test isolation.

@scidomino scidomino enabled auto-merge March 4, 2026 03:33
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@scidomino scidomino added this pull request to the merge queue Mar 4, 2026
Merged via the queue into main with commit 7e06559 Mar 4, 2026
28 checks passed
@scidomino scidomino deleted the tomm_relaunch branch March 4, 2026 06:30
neeraj-par pushed a commit to neeraj-par/gemini-cli that referenced this pull request Mar 4, 2026
BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
struckoff pushed a commit to struckoff/gemini-cli that referenced this pull request Mar 6, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 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 priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restarting Gemini CLI to approve folder trust on Windows while an update is in progress results in a crash

2 participants