-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix setting migration nosiness and merging #7571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @galz10, 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 significant bug in the settings management system where workspace configurations would inadvertently overwrite entire blocks of user settings. The core change introduces a robust deep-merge mechanism, ensuring that user, workspace, and system default settings are intelligently combined, allowing for more flexible and predictable configuration behavior without data loss.
Highlights
- Critical Settings Merge Fix: Implemented a deep-merge strategy for configuration settings (e.g., general, ui, ide, privacy, telemetry, tools, context) to prevent workspace settings from completely overwriting user settings. This ensures granular combination of preferences, preserving user-defined values while allowing workspace-specific overrides for individual properties.
- Dependency Updates and Additions: Updated package versions across the project to
0.3.0-preview.1
and introduced new dependencies:simple-git
in@google/gemini-cli
and@lvce-editor/ripgrep
in@google/gemini-cli-core
. - Logging Cleanup: Removed verbose logging messages that appeared during in-memory settings migration to reduce console noise and improve clarity.
- Settings Migration Map Enhancement: Added
allowedTools
to the settings migration map, ensuring proper handling of this setting during configuration updates. - Test Suite Refinements: Updated unit tests for settings loading and merging to accurately reflect the new deep-merge behavior and the expected structure of merged settings, including default empty objects for various top-level setting categories.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
There was a problem hiding this 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 addresses a critical bug in settings merging by implementing a deep-merge strategy for configuration blocks, preventing workspace settings from completely overwriting user settings. The change correctly fixes the immediate issue for the known settings keys. However, the implementation is brittle and could allow the bug to resurface with future changes. My review includes a critical comment with a suggestion for a more robust and maintainable merging strategy. Additionally, the removal of verbose logging during settings migration is a welcome cleanup.
Settings from different sources (user, workspace) were overwriting entire configuration objects (e.g., 'tools', 'ui') instead of merging. This caused user settings to be lost if a workspace defined any part of the same configuration object. This fix implements a deep merge for top-level settings categories, allowing for granular overrides and preserving settings from all sources. Also reducing the noisyness of the setting migration.
66b4c3b
to
c5d24df
Compare
Code Coverage Summary
CLI Package - Full Text Report
Core Package - Full Text Report
For detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
TLDR
This pull request fixes a critical bug where workspace settings would completely overwrite user settings for entire configuration blocks (e.g.,
tools
,ui
,context
). The fix implements a deep-merge strategy, ensuring that settings from user, workspace, and system defaults are combined granularly.Dive Deeper
Previously, the settings merge logic used a shallow merge (
...
spread operator) for top-level properties. This meant if a user had definedtools: { core: ['a'] }
in their global settings and the workspace definedtools: { sandbox: true }
, the final configuration would only containtools: { sandbox: true }
, completely discarding the user'score
tools setting.This change modifies the merge function to recursively combine objects for all major settings categories (
general
,ui
,ide
,privacy
,telemetry
,security
,tools
,context
, etc.). This ensures that nested properties are preserved across all configuration sources, with workspace settings taking precedence over user settings only for the specific properties they define.As a minor cleanup, verbose logging messages that appeared during in-memory settings migration have been removed to reduce noise.
Reviewer Test Plan
To validate this fix, you can manually create conflicting user and workspace settings files and observe the merged output.
Create a global user setting:
~/.gemini/settings.json
.Create a local workspace setting:
.gemini/settings.json
file.Verify the merged configuration:
gemini config list
command.tools
object and the user'sui
theme:core
andsandbox
undertools
confirms the deep merge was successful.Testing Matrix
Linked issues / bugs