Skip to content

fix(settings): preserve disk edits when changing authentication - #29762

Closed
seokjeongeum wants to merge 1 commit into
google-gemini:mainfrom
seokjeongeum:fix/auth-signin-settings-persistence
Closed

seokjeongeum wants to merge 1 commit into
google-gemini:mainfrom
seokjeongeum:fix/auth-signin-settings-persistence

Conversation

@seokjeongeum

@seokjeongeum seokjeongeum commented Oct 15, 2026 •

Copy link
Copy Markdown

Summary

Preserve settings-file edits made after Gemini CLI starts when a setting, including the authentication method, is saved. Save the requested property against the current disk contents instead of rewriting the startup snapshot.

Details

Limit property writes to the changed path while retaining unrelated disk additions, deletions, comments, environment placeholders, and array/object changes. If a required ancestor has become incompatible, recreate the ancestors needed for that property while keeping unrelated settings. Object-valued assignments still replace the assigned object. Malformed JSON is reported and left intact.

Document /auth signin/login, /auth signout/logout, and normal /quit persistence. Opening or cancelling authentication selection does not reset preferences; signout removes the selected authentication type, while normal quit retains saved preferences and credentials. No public settings/schema or package-version changes.

Related Issues

Related to #23138. Its stale originalSettings snapshot also reproduces when changing authentication on the upstream base used here.

How to Validate

Validated final head a6b076020dac1024a7a34e687d43308076157518, based on upstream ed96faedfd5571f055c44f2c9509d62321d1138d.

  • node ../../node_modules/vitest/vitest.mjs run src/config/settings.persistence.test.ts src/config/settings.test.ts src/utils/commentJson.test.ts src/ui/commands/authCommand.test.ts src/ui/commands/quitCommand.test.ts --coverage.enabled=false --maxWorkers=1 --minWorkers=1 from packages/cli: 176/176 pass on Linux Node 24.21.0 and native Windows Node 24.14.1.
  • Linux npm run build, npm run typecheck -w @google/gemini-cli-core -w @google/gemini-cli, changed-file ESLint/Prettier, and git diff --check pass. Native Windows core/devtools/CLI npm builds and affected typechecks pass. All 3,027 regular source blobs in the isolated NTFS checkout match this head; the documentation symlink is explicitly materialized.
  • Six real-file scenarios pass against compiled source and isolated installed packages on Linux and native Windows: external additions/deletions/comments/placeholders, unrelated arrays, signout property deletion, incompatible array/object ancestors, and malformed JSON preservation. These exercise saved bytes, not just in-memory state. Authentication command tests mock browser/OAuth operations; no live Google sign-in is claimed.
  • npm run start -- --version/--help and isolated packed npx --offline --no-install gemini --version/--help pass on Linux. Native source version launch and actual offline npm-exec version/help pass. Native packed CLI/core files are extracted into an isolated prefix and hash-checked, using native third-party dependencies from a matching lockfile checkout; a fresh Windows registry installation remains unverified after an offline cache miss and bounded network timeout. No global binary is used for package validation.
  • Built Docker artifact gemini-auth-pr29762:a6b0760 installs the exact CLI/core tarballs and passes all six real-file scenarios plus offline npx version/help on Node 20.20.2. This is a Linux artifact-runtime container hosted by Windows Docker, not native Windows-container coverage or a repository-Dockerfile source build.
  • Full npm run preflight completed in a disposable checkout on this head 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,418 passed, 4 skipped; core reports 76 failed, 8,296 passed, 57 skipped. Every failing record, including repeated parameterized cases, reproduces on upstream ed96faedf with the same runtime, dependencies, isolated home, and worker bounds: no candidate-only failure. Failures concern mocked home/workspace paths, keychain mocks, and unavailable bwrap. The script and SEA suites skipped by the failed workspace chain were run separately on this head: npm run test:scripts passes 202/202 and npm run test:sea-launch passes 17/17.

The previous review thread was checked against this head and remains resolved; no unresolved thread was found in the fully paginated audit.

GitHub Testing: CI reports action_required; a maintainer must approve the external-contributor workflow run. Local results do not imply CI passed. macOS/Seatbelt are unavailable, and 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

@seokjeongeum
seokjeongeum requested review from a team as code owners October 15, 2026 11:52
@github-actions github-actions Bot added the size/l A large sized PR label Oct 15, 2026
@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 data loss issue where changing authentication methods would overwrite the entire settings file with a stale snapshot, causing loss of any user edits made since the application started. The changes introduce granular settings updates, ensuring that only the modified property is persisted to disk while preserving other manual changes, comments, and environment placeholders. Additionally, documentation has been improved to clearly define the side effects of authentication and exit commands.

Highlights

  • Settings Persistence: Modified the settings persistence logic to update only the specific property changed rather than overwriting the entire settings file, preventing loss of external edits made after application startup.
  • Documentation: Updated command documentation to clarify the behavior of /auth and /quit commands regarding settings and credential management.
  • Testing: Added a comprehensive new test suite (settings.persistence.test.ts) to verify that unrelated settings, comments, and environment placeholders are preserved during authentication changes.
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. ↩

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

📊 PR Size: size/L

  • Lines changed: 492
  • Additions: +479
  • Deletions: -13
  • Files changed: 7

@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 improves settings persistence by allowing the CLI to save only the explicitly changed configuration properties rather than overwriting the entire file with a stale startup snapshot, which preserves concurrent or external edits. It updates the format-preserving JSON update utility to support a property path and adds comprehensive tests. Documentation for /auth subcommands and /quit settings has also been updated. Feedback on the changes highlights a potential type mismatch bug in applyPropertyUpdate where an array and a plain object are both treated as property containers, which could lead to silent data loss or schema violations if their types do not match.

Comment thread packages/cli/src/utils/commentJson.ts Resolved
@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 Oct 15, 2026
@gemini-cli

gemini-cli Bot commented Oct 23, 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.

@gemini-cli

gemini-cli Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

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. size/l A large sized PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant