Skip to content

fix(cli): hide read-only settings scopes#26249

Merged
scidomino merged 3 commits intogoogle-gemini:mainfrom
cvan20191:fix-25429-settings-readonly-scopes-clean
May 6, 2026
Merged

fix(cli): hide read-only settings scopes#26249
scidomino merged 3 commits intogoogle-gemini:mainfrom
cvan20191:fix-25429-settings-readonly-scopes-clean

Conversation

@cvan20191
Copy link
Copy Markdown
Contributor

@cvan20191 cvan20191 commented Apr 30, 2026

Summary

Fixes a bug in the /settings dialog that incorrectly allowed users to select read-only scopes. Previously, modifying these scopes would only update the temporary runtime state and fail to save permanently to settings.json

Details

  • Filters read-only scopes from the editable settings list in SettingsDialog.
  • Preserves readOnly metadata in LoadedSettingsSnapshot.
  • Updates dependency arrays in SettingsDialog callbacks to use writableSelectedScope and effectiveSelectedScope instead of selectedScope.
  • Adds regression tests for getSnapshot() and scope filtering behavior.

Related Issues

Fixes #25429

How to Validate

  1. npm run test --workspace @google/gemini-cli -- src/config/settings.test.ts src/ui/components/SettingsDialog.test.tsx
  2. npm run build
  3. npm run typecheck

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:
    • Linux
      • npm run
      • npx

@cvan20191 cvan20191 requested a review from a team as a code owner April 30, 2026 04:48
@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 refines the CLI's settings management by ensuring that the settings dialog only presents editable scopes to the user. This change resolves an issue where users could select read-only scopes, leading to confusion when changes made within them were not persisted. The update enhances the clarity and reliability of the settings interface by guiding users towards valid modification targets.

Highlights

  • Read-Only Scope Filtering: Implemented logic to prevent read-only settings scopes from being offered as editable targets in the /settings dialog, addressing a previous issue where changes in such scopes were non-persistent.
  • Metadata Preservation: Ensured that the readOnly metadata for each settings scope is correctly preserved within the LoadedSettingsSnapshot to accurately identify editable scopes.
  • Enhanced Test Coverage: Added comprehensive test cases to validate the new behavior, including scenarios where read-only scopes are hidden, the dialog falls back to writable scopes, and no save operations occur if all scopes are read-only.
  • UI/UX Improvement: Refactored the SettingsDialog component to dynamically manage and display only writable scopes, improving the user experience by preventing attempts to modify uneditable settings.
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.

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
Copy Markdown
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 implements logic to handle read-only settings scopes within the CLI's settings dialog. It updates the LoadedSettings class to preserve readOnly metadata during snapshots and modifies the SettingsDialog component to filter out non-writable scopes from the UI. The changes include logic to automatically fall back to a writable scope if the current selection is read-only and prevent editing actions when no writable scopes are available. Comprehensive tests were added to verify these behaviors across different scope configurations. I have no feedback to provide.

@cvan20191 cvan20191 force-pushed the fix-25429-settings-readonly-scopes-clean branch from ac0158f to a74fa70 Compare April 30, 2026 05:06
@gemini-cli gemini-cli Bot added area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Apr 30, 2026
Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request May 4, 2026
BerriAI/litellm#27106 (mcp oauth auth-gate fix), charmbracelet/crush#2606 (split-pane+pty infra), google-gemini/gemini-cli#26249 (hide read-only settings scopes).
@scidomino scidomino self-requested a review May 4, 2026 19:28
@scidomino
Copy link
Copy Markdown
Collaborator

Great fix! The React logic and test coverage are excellent.

I have two minor suggestions regarding the core logic and test utils that could make this implementation a bit more elegant and robust against future changes:

1. Use object spread in cloneSettingsFile
In packages/cli/src/config/settings.ts, instead of manually mapping scalar properties (which is why readOnly was missed in the first place), we can use the object spread operator. This ensures that any future primitive properties added to SettingsFile are automatically copied without needing to update this function:

const cloneSettingsFile = (file: SettingsFile): SettingsFile => ({
  ...file,
  settings: structuredClone(file.settings),
  originalSettings: structuredClone(file.originalSettings),
});

2. Update MockSettingsFile directly
In packages/cli/src/ui/components/SettingsDialog.test.tsx, you created a local MockSettingsFileWithReadOnly type. It would be slightly cleaner to just add readOnly?: boolean; directly to the MockSettingsFile interface in packages/cli/src/test-utils/settings.ts. This removes the need for the local type extension and keeps the shared test abstractions accurate for future tests.

Otherwise, this is a very high-quality PR and looks good to go!

@cvan20191
Copy link
Copy Markdown
Contributor Author

@scidomino, thanks for the review, I’ve addressed both of your suggestions.

  • Updated cloneSettingsFile to use ...file while deep‑cloning settings and originalSettings.
  • Added readOnly?: boolean to the shared MockSettingsFile and removed the local MockSettingsFileWithReadOnly helper.

All tests and type checks pass on my end. Let me know if there’s anything else I should adjust. On a side note, I appreciate the detailed feedback

@scidomino
Copy link
Copy Markdown
Collaborator

Remove this code from the useEffect and just replace it with direct code. This will be more efficient since it won't need to render twice:

  if (writableSelectedScope && selectedScope !== writableSelectedScope) {
    setSelectedScope(writableSelectedScope);
  }

@cvan20191
Copy link
Copy Markdown
Contributor Author

@scidomino Done! thank you for the feedback

@scidomino scidomino enabled auto-merge May 6, 2026 18:50
@scidomino scidomino added this pull request to the merge queue May 6, 2026
Merged via the queue into google-gemini:main with commit e4242ed May 6, 2026
27 checks passed
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 help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: Global Configuration Serialisation Failure

2 participants