Skip to content

fix(patch): cherry-pick 81ccd80 to release/v0.28.0-preview.5-pr-18406 to patch version v0.28.0-preview.5 and create version 0.28.0-preview.6#18651

Merged
skeshive merged 2 commits intorelease/v0.28.0-preview.5-pr-18406from
hotfix/v0.28.0-preview.5/0.28.0-preview.6/preview/cherry-pick-81ccd80/pr-18406
Feb 9, 2026
Merged

fix(patch): cherry-pick 81ccd80 to release/v0.28.0-preview.5-pr-18406 to patch version v0.28.0-preview.5 and create version 0.28.0-preview.6#18651
skeshive merged 2 commits intorelease/v0.28.0-preview.5-pr-18406from
hotfix/v0.28.0-preview.5/0.28.0-preview.6/preview/cherry-pick-81ccd80/pr-18406

Conversation

@gemini-cli-robot
Copy link
Copy Markdown
Collaborator

This PR automatically cherry-picks commit 81ccd80 to patch version v0.28.0-preview.5 in the preview release to create version 0.28.0-preview.6.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @gemini-cli-robot, 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 is an automated cherry-pick to patch a preview release, primarily focusing on enhancing the robustness and reliability of folder trust management. It introduces asynchronous and atomic file operations for saving trusted folder configurations, utilizing the proper-lockfile library. These core changes necessitated updates across various parts of the CLI, including UI components, hooks, and test suites, to correctly handle the new asynchronous behavior and ensure data integrity.

Highlights

  • Asynchronous Folder Trust Operations: The setValue method in the trustedFolders module has been refactored to be asynchronous, ensuring non-blocking file operations. This change impacts how folder trust levels are set and saved.
  • Atomic File Writes with proper-lockfile: The trustedFolders.json file now uses proper-lockfile to ensure atomic writes, preventing data corruption during concurrent modifications. This also includes handling of potentially corrupted files by emitting feedback and attempting to recover.
  • Dependency Updates: New dependencies @types/ws and proper-lockfile have been added to package.json, package-lock.json, and packages/cli/package.json to support the new asynchronous and atomic file operations.
  • UI and Hook Updates: Several UI components and hooks, including extension-manager.ts, ConsentPrompt.test.tsx, LogoutConfirmationDialog.test.tsx, MultiFolderTrustDialog.tsx, PermissionsModifyTrustDialog.tsx, useFolderTrust.ts, and usePermissionsModifyTrust.ts, have been updated to correctly await the now asynchronous setValue calls.
  • Test Refactoring: Test files, particularly extensionUpdates.test.ts and trustedFolders.test.ts, have undergone significant refactoring to improve mocking strategies, remove unnecessary mocks, and adapt to the asynchronous nature of the updated functions, with trustedFolders.test.ts now testing against the real file system for locking behavior.
Changelog
  • package-lock.json
    • Added @types/ws dependency.
    • Added proper-lockfile dependency.
  • package.json
    • Added @types/ws dependency.
  • packages/cli/package.json
    • Added proper-lockfile dependency.
  • packages/cli/src/config/extension-manager.ts
    • Updated trustedFolders.setValue call to be awaited.
  • packages/cli/src/config/extensions/extensionUpdates.test.ts
    • Removed unused imports (path, os, KeychainTokenStorage, ExtensionStorage, EXTENSION_SETTINGS_FILENAME).
    • Enhanced node:fs mock to include promises and more specific mock implementations for existsSync, statSync, lstatSync, realpathSync.
    • Added mocks for consent.js, extensionSettings.js, trustedFolders.js, and ExtensionStorage to isolate tests.
    • Simplified os.homedir mock.
    • Removed getMissingSettings describe block and related tests, as the logic is now mocked.
    • Updated ExtensionManager integration tests to use the new mocking strategy and await calls.
  • packages/cli/src/config/trustedFolders.test.ts
    • Refactored tests to use real file system operations with temporary directories for trustedFolders.json.
    • Added tests for locking and concurrency using proper-lockfile.
    • Improved handling of JSON parsing errors and invalid trust levels.
    • Removed mocks for fs, os, strip-json-comments to test real behavior.
    • Simplified isPathTrusted setup.
    • Updated isWorkspaceTrusted integration tests.
    • Added symlink support tests.
    • Removed realpath caching tests.
    • Removed Auth and Trust Interaction tests as they are no longer relevant to this file's testing scope.
  • packages/cli/src/config/trustedFolders.ts
    • Imported crypto and proper-lockfile.
    • Changed setValue method to be async.
    • Implemented file locking using proper-lockfile for atomic updates to trustedFolders.json.
    • Added logic to handle potential file corruption during setValue by re-reading and emitting feedback.
    • Modified saveTrustedFolders to use a temporary file and fs.renameSync for atomic writes.
    • Introduced parseTrustedFoldersJson helper function.
  • packages/cli/src/ui/components/ConsentPrompt.test.tsx
    • Updated act calls to await act(async () => ...) for asynchronous operations.
  • packages/cli/src/ui/components/LogoutConfirmationDialog.test.tsx
    • Updated act calls to await act(async () => ...) for asynchronous operations.
  • packages/cli/src/ui/components/MultiFolderTrustDialog.tsx
    • Updated trustedFolders.setValue call to be awaited.
  • packages/cli/src/ui/components/PermissionsModifyTrustDialog.tsx
    • Updated commitTrustLevelChange call to be awaited within an async IIFE.
  • packages/cli/src/ui/hooks/useFolderTrust.test.ts
    • Updated handleFolderTrustSelect calls to be awaited.
  • packages/cli/src/ui/hooks/useFolderTrust.ts
    • Changed handleFolderTrustSelect and trustedFolders.setValue to be async and awaited, respectively.
  • packages/cli/src/ui/hooks/usePermissionsModifyTrust.test.ts
    • Updated updateTrustLevel and commitTrustLevelChange calls to be awaited.
  • packages/cli/src/ui/hooks/usePermissionsModifyTrust.ts
    • Changed updateTrustLevel and commitTrustLevelChange to be async and awaited, respectively.
  • packages/core/package.json
    • Added proper-lockfile dependency.
Activity
  • This pull request was automatically generated by gemini-cli-robot to cherry-pick commit 81ccd80c6d94a7fe315b258e1672065629ce0d50.
  • The purpose is to patch version v0.28.0-preview.5 and create version 0.28.0-preview.6.
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.

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 refactors the 'trusted folders' functionality to use asynchronous file operations and ensure atomic writes, primarily by introducing the 'proper-lockfile' dependency. The trustedFolders.setValue method is updated to be asynchronous, utilizing file locking to prevent race conditions during concurrent updates and implementing a safe write pattern (write to temp file, then rename) to avoid data corruption. The changes also include updating various UI components and hooks to correctly await the now-asynchronous setValue calls, and modifying test suites to reflect these asynchronous behaviors and to test real file system interactions with locking. A review comment specifically highlighted the need to replace synchronous fs.existsSync calls with asynchronous alternatives like fsPromises.access within the setValue method to prevent blocking the event loop, which was addressed in the code changes.

Comment on lines +176 to +185
if (!fs.existsSync(dirPath)) {
await fsPromises.mkdir(dirPath, { recursive: true });
}

// lockfile requires the file to exist
if (!fs.existsSync(this.user.path)) {
await fsPromises.writeFile(this.user.path, JSON.stringify({}, null, 2), {
mode: 0o600,
});
}
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.

high

This block uses synchronous fs.existsSync calls within an async function, which can block the event loop. It's better to use asynchronous alternatives. For creating the directory, the check is redundant as mkdir with { recursive: true } handles it. For checking if the file exists before locking, you can use fsPromises.access in a try/catch block. This aligns with the general preference for asynchronous file system operations to avoid blocking the event loop.

Suggested change
if (!fs.existsSync(dirPath)) {
await fsPromises.mkdir(dirPath, { recursive: true });
}
// lockfile requires the file to exist
if (!fs.existsSync(this.user.path)) {
await fsPromises.writeFile(this.user.path, JSON.stringify({}, null, 2), {
mode: 0o600,
});
}
await fsPromises.mkdir(dirPath, { recursive: true });
// lockfile requires the file to exist
try {
await fsPromises.access(this.user.path);
} catch {
await fsPromises.writeFile(this.user.path, JSON.stringify({}, null, 2), {
mode: 0o600,
});
}
References
  1. Use asynchronous file system operations (e.g., fs.promises.readFile) instead of synchronous ones (e.g., fs.readFileSync) to avoid blocking the event loop.

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 9, 2026

Size Change: +28.2 kB (+0.12%)

Total Size: 23.7 MB

Filename Size Change
./bundle/gemini.js 23.7 MB +28.2 kB (+0.12%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

@skeshive skeshive enabled auto-merge (squash) February 9, 2026 18:16
@skeshive skeshive merged commit 9506601 into release/v0.28.0-preview.5-pr-18406 Feb 9, 2026
23 of 24 checks passed
@skeshive skeshive deleted the hotfix/v0.28.0-preview.5/0.28.0-preview.6/preview/cherry-pick-81ccd80/pr-18406 branch February 9, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants