Skip to content

refactor(core,cli): useAlternateBuffer read from config#20346

Merged
jacob314 merged 14 commits intogoogle-gemini:mainfrom
psinha40898:pyush/refactor/config-alt-buffer
Feb 27, 2026
Merged

refactor(core,cli): useAlternateBuffer read from config#20346
jacob314 merged 14 commits intogoogle-gemini:mainfrom
psinha40898:pyush/refactor/config-alt-buffer

Conversation

@psinha40898
Copy link
Copy Markdown
Contributor

@psinha40898 psinha40898 commented Feb 25, 2026

Summary

In order to remove the batching of saves interactions in the UI that depend on restart required settings should read from the immutable once instantiated config object instead of the mutable settings object.

prerequisite to #18963

Details

Related Issues

How to Validate

Test out alternate buffer mode, switch the setting, restart, test out that the mode has been toggled.

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

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @psinha40898, 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 how the useAlternateBuffer setting is managed and accessed within the application. By transitioning this setting from a mutable settings object to an immutable configuration object, the change aims to enhance stability and predictability, particularly for UI elements that depend on restart-required settings. This ensures that once the application starts, the useAlternateBuffer value remains constant, preventing potential inconsistencies that could arise from runtime modifications to mutable settings. This is a foundational step towards addressing broader UI interaction batching issues.

Highlights

  • Configuration Refactoring: The useAlternateBuffer setting has been refactored to be read from an immutable Config object rather than a mutable Settings object, ensuring consistent behavior across the application lifecycle.
  • UI Integration Update: The AppContainer component and the useAlternateBuffer React hook now retrieve the alternate buffer status directly from the Config context, aligning with the new immutable configuration approach.
  • Testing Enhancements: New and updated tests have been added for the Config class and the useAlternateBuffer hook to validate the correct handling and retrieval of the useAlternateBuffer setting.
  • Dependency Streamlining: The calculateMainAreaWidth utility function has been simplified to directly accept the isAlternateBuffer boolean, removing its dependency on the full settings object.
Changelog
  • packages/cli/src/config/config.ts
    • Added useAlternateBuffer to the loadCliConfig function parameters to include it in the CLI configuration.
  • packages/cli/src/ui/AppContainer.test.tsx
    • Updated AppContainer tests to mock the getUseAlternateBuffer method from the mockConfig object, reflecting the new configuration source.
  • packages/cli/src/ui/AppContainer.tsx
    • Removed the import for the useAlternateBuffer hook.
    • Modified the isAlternateBuffer variable to retrieve its value from config.getUseAlternateBuffer().
    • Updated the calculateMainAreaWidth function call to pass isAlternateBuffer directly instead of the settings object.
  • packages/cli/src/ui/hooks/useAlternateBuffer.test.ts
    • Added a new test file to verify the functionality of the useAlternateBuffer hook and the isAlternateBufferEnabled utility, ensuring they correctly read from the Config context.
  • packages/cli/src/ui/hooks/useAlternateBuffer.ts
    • Changed the useAlternateBuffer hook to import and utilize useConfig instead of useSettings.
    • Updated the useAlternateBuffer hook to return the value from config.getUseAlternateBuffer().
  • packages/cli/src/ui/utils/ui-sizing.test.ts
    • Removed mocking for isAlternateBufferEnabled.
    • Adjusted calculateMainAreaWidth tests to directly pass the altBuffer boolean parameter.
  • packages/cli/src/ui/utils/ui-sizing.ts
    • Removed imports for LoadedSettings and isAlternateBufferEnabled.
    • Modified the calculateMainAreaWidth function signature to accept isAlternateBuffer directly instead of a settings object.
  • packages/core/src/config/config.test.ts
    • Added new test cases for the useAlternateBuffer configuration within the Config class, covering default, true, and false values.
  • packages/core/src/config/config.ts
    • Added useAlternateBuffer as an optional property to the ConfigParameters interface.
    • Declared a private useAlternateBuffer readonly property in the Config class.
    • Initialized this.useAlternateBuffer in the Config constructor with a default value of false.
    • Implemented a getUseAlternateBuffer() getter method to expose the useAlternateBuffer value.
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.

@psinha40898 psinha40898 marked this pull request as ready for review February 25, 2026 21:12
@psinha40898 psinha40898 requested a review from a team as a code owner February 25, 2026 21:12
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 successfully refactors the useAlternateBuffer setting to be read from the immutable config object instead of the mutable settings object. This is a good architectural improvement. The changes are applied consistently across the cli and core packages, and the tests have been updated accordingly. I have one suggestion to remove some dead code that resulted from this refactoring.

@gemini-cli gemini-cli bot added priority/p1 Important and should be addressed in the near term. priority/p2 Important but can be addressed in a future release. 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 Feb 25, 2026
Copy link
Copy Markdown
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.

Approved after these comments are addressed.

Copy link
Copy Markdown
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

@jacob314 jacob314 enabled auto-merge February 25, 2026 22:16
auto-merge was automatically disabled February 25, 2026 22:56

Head branch was pushed to by a user without write access

@psinha40898 psinha40898 marked this pull request as draft February 25, 2026 23:31
@jacob314 jacob314 marked this pull request as ready for review February 26, 2026 06:18
@jacob314 jacob314 enabled auto-merge February 26, 2026 06:18
@jacob314
Copy link
Copy Markdown
Contributor

LGTM. The refactoring of useAlternateBuffer correctly utilizes the immutable config object and the test implementation appropriately uses an ES6 Proxy without breaking the prototype. All builds and tests pass cleanly.

@jacob314 jacob314 added this pull request to the merge queue Feb 26, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 26, 2026
@jacob314 jacob314 enabled auto-merge February 26, 2026 19:42
@jacob314 jacob314 added this pull request to the merge queue Feb 27, 2026
Merged via the queue into google-gemini:main with commit d7320f5 Feb 27, 2026
27 checks passed
BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 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 help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p1 Important and should be addressed in the near term. priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants