Skip to content

fix(acp): Pass the cwd to AcpFileSystemService to avoid looping failures in asking for perms to write plan md file#23612

Merged
sripasg merged 1 commit intomainfrom
sripas_fix_22191
Mar 24, 2026
Merged

fix(acp): Pass the cwd to AcpFileSystemService to avoid looping failures in asking for perms to write plan md file#23612
sripasg merged 1 commit intomainfrom
sripas_fix_22191

Conversation

@sripasg
Copy link
Copy Markdown
Contributor

@sripasg sripasg commented Mar 24, 2026

Summary

The gemini-cli agent was sending requests to the ACP IDE client to write its .md plan files into a designated scratch directory (~/.gemini/tmp/) located outside your project's workspace, causing the IDE to block the action for security reasons. To fix this, we need to update the ACP file system integration to detect when a target file resides outside the workspace root. When it does that, the agent bypasses the IDE's file system and natively writes the file to the local disk.

Details

Main issue: The IDE's ACP implementation correctly denies writing files outside of its active workspace scope, which halted Plan Mode completely because the agent stores markdown plans in its internal global cache (~/.gemini/tmp/).
So we do the following:

  • Update AcpFileSystemService constructor to accept and store the active workspace's root directory string (cwd).
  • Inject workspace context at the session start by passing the cwd parameter down into the AcpFileSystemService from both the newSession and loadSession setup methods within packages/cli/src/acp/acpClient.ts.
  • Import the isWithinRoot utility and wrap the ACP readTextFile and writeTextFile methods with it. If isWithinRoot(filePath, this.root) resolves to false, the operation aborts the IDE proxy communication and calls the native Node.js fallback instead.
  • Update the fileSystemService.test.ts suite to instantiate the service with a dummy root path, adding dedicated tests to explicitly verify that out-of-bounds file paths trigger the fallback logic without calling the mockConnection.

Related Issues

Fixes #22191

How to Validate

Use ACP in plan mode ans ensure that there is no failures to automatically write a plan.md file for the prompt.

Pre-Merge Checklist

  • [NA] Updated relevant documentation and README (if needed)
  • [✅] Added/updated tests (if needed)
  • [NA] 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

@sripasg sripasg requested a review from a team as a code owner March 24, 2026 00:16
@sripasg sripasg requested a review from jerop March 24, 2026 00:17
@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 resolves an issue where the Gemini CLI agent was unable to write plan files due to the IDE's security restrictions on file operations outside the active workspace. The solution enhances the AcpFileSystemService by introducing workspace root awareness. It now intelligently determines if a file operation is within the project's scope, falling back to direct native file system access when attempting to write to locations outside the workspace, thereby ensuring both functionality and adherence to security policies.

Highlights

  • Security Enhancement: The IDE's ACP file system integration now prevents writing files outside the active workspace for security reasons.
  • Fallback Mechanism: Introduced a mechanism in AcpFileSystemService to detect out-of-workspace file paths and bypass the IDE's file system, using native Node.js file operations instead.
  • Workspace Context Injection: The AcpFileSystemService constructor was updated to accept the current working directory (cwd), which is now passed during session initialization in acpClient.ts.
  • Path Validation: The isWithinRoot utility is used to validate file paths before readTextFile and writeTextFile operations, ensuring files are within the defined workspace root.
  • Improved Test Coverage: Added dedicated tests to fileSystemService.test.ts to explicitly verify that out-of-bounds file paths correctly trigger the native fallback logic.
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 correctly addresses an issue where the ACP IDE client would block file writes outside the workspace. By passing the current working directory to AcpFileSystemService and checking if file paths are within the workspace root, the implementation now correctly falls back to the native file system for out-of-bounds operations. The changes are logical and the accompanying tests are thorough, verifying the new fallback mechanism. I have one suggestion to improve maintainability by reducing code duplication.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

Size Change: +939 B (0%)

Total Size: 26.2 MB

Filename Size Change
./bundle/chunk-AUPAO6LT.js 0 B -3.64 MB (removed) 🏆
./bundle/chunk-MHRHKVEQ.js 0 B -14.6 MB (removed) 🏆
./bundle/core-VIEM3LM6.js 0 B -43.4 kB (removed) 🏆
./bundle/devtoolsService-CHD26DS4.js 0 B -27.7 kB (removed) 🏆
./bundle/interactiveCli-NEWVKQBG.js 0 B -1.62 MB (removed) 🏆
./bundle/oauth2-provider-R72G7Z57.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-X3K6QZIQ.js 3.64 MB +3.64 MB (new file) 🆕
./bundle/chunk-ZBWCJABL.js 14.6 MB +14.6 MB (new file) 🆕
./bundle/core-S3K4IEJI.js 43.4 kB +43.4 kB (new file) 🆕
./bundle/devtoolsService-TG5DBMZG.js 27.7 kB +27.7 kB (new file) 🆕
./bundle/interactiveCli-PIZFAE4N.js 1.62 MB +1.62 MB (new file) 🆕
./bundle/oauth2-provider-JRRT73MM.js 9.16 kB +9.16 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-6QHMIPJ4.js 1.96 MB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-T73EYRDX.js 356 B 0 B
./bundle/gemini.js 522 kB +943 B (+0.18%)
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/memoryDiscovery-HUJCFP4R.js 922 B 0 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B

compressed-size-action

@gemini-cli gemini-cli bot added area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Mar 24, 2026
Copy link
Copy Markdown
Contributor

@nmcnamara-eng nmcnamara-eng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a sensible fix to the problem to my eyes. Though I didn't directly test it.

@sripasg sripasg self-assigned this Mar 24, 2026
@sripasg sripasg added the ACP label Mar 24, 2026
… ensure file operations outside `cwd` use the fallback service.
@sripasg sripasg added this pull request to the merge queue Mar 24, 2026
Merged via the queue into main with commit 46fd7b4 Mar 24, 2026
27 checks passed
@sripasg sripasg deleted the sripas_fix_22191 branch March 24, 2026 05:48
ProthamD pushed a commit to ProthamD/gemini-cli that referenced this pull request Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ACP area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plan Mode doesn't work at all with ACP

2 participants