Skip to content

Save sandbox path access in user settings - #341208

Merged
Dileep Yavanmandha (dileepyavan) merged 4 commits into
microsoft:mainfrom
dileepyavan:DileepY/sandbox_allow_read
Oct 14, 2026
Merged

Dileep Yavanmandha (dileepyavan) merged 4 commits into
microsoft:mainfrom
dileepyavan:DileepY/sandbox_allow_read

Conversation

@dileepyavan

@dileepyavan Dileep Yavanmandha (dileepyavan) commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

This change lets the user save file access when the sandbox blocks an operation. The runtime must supply the path and access type.

  • Show this header: "Add to user sandbox settings and retry?"
  • Show two buttons: Allow and Skip.
  • When the user selects Allow, save the path in the local user profile's settings.json. Use chat.agent.sandbox.fileSystem.userConfiguredPaths.
  • Save the setting before the runtime retries the blocked operation. Keep the sandbox enabled.
  • Keep the saved access across sessions and workspaces that use this user profile. Share the setting with connected agent hosts.
  • When the user selects Skip, do not grant access.

Preserve unrelated user settings. Do not copy workspace path permissions into user settings. If the save fails, show an error and keep the confirmation open.

Remove the session-only path grant option. Put sandbox configuration and request handling in CopilotSessionSandbox. Process configuration updates and grants in sequence. Reject expired requests and grants without a save acknowledgement.

Select and track path grants in CopilotSessionSandbox, not in CopilotAgentSession. Use the SDK's path grant contract. Do not repeat its sandbox bypass check. Keep the request-kind checks for type safety. Keep the managed-approval check because that flow permits only a one-time human decision.

Update the accessibility help and tests to match the controls.

How to test

  1. Enable the Copilot Agent Host sandbox.
  2. Request a file operation on a path outside its permitted paths. Use an operation for which the runtime offers a path grant.
  3. Check that the header explains the save and retry action. Check that the buttons show Allow and Skip.
  4. Select Allow. Check that the path is in the user setting, not the workspace setting.
  5. Check that the blocked operation retries inside the sandbox.
  6. Start another session with the same user profile. Check that the saved setting is available.
  7. Repeat with another blocked path. Select Skip. Check that access is not added.

These manual steps were not run in this session. Live-provider flows were not tested.

Validation

  • Before the final grant-selection refactor, the VS Code runTests tool reported 1,325 passed, 0 failed across these files:
    • src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts
    • src/vs/platform/agentHost/test/node/copilotToolDisplay.test.ts
    • src/vs/platform/agentHost/test/node/sessionSandbox.test.ts
    • src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts
    • src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostSandboxPathGrant.test.ts
  • Existing Core - Typecheck task: passed, 0 errors. Used the current task output. Did not start a duplicate build.
  • npm run -s precommit: passed through the normal Git hook. Hygiene checked all 10 committed files.
  • The focused header and confirmation-flow test command below: passed, 4 tests.

Final grant-selection refactor

  • Sandbox grant and bypass regression tests: passed, 35 tests. This includes new read, write, and shell cases with and without managed approval.
  • Existing Core - Typecheck task: passed, 0 errors after the final change.
  • Changed-file ESLint: passed, 3 files.
  • npm run -s precommit: passed through the normal Git hook. Hygiene checked all 3 files in commit bc407d0e362.
.\scripts\test.bat --run src\vs\platform\agentHost\test\node\copilotAgentSession.test.ts --grep "sandbox path grant|sandbox bypass|managed asks" --reporter dot
npm run eslint -- src\vs\platform\agentHost\node\copilot\copilotSessionSandbox.ts src\vs\platform\agentHost\node\copilot\copilotAgentSession.ts src\vs\platform\agentHost\test\node\copilotAgentSession.test.ts

Earlier validation commands

The header and confirmation-flow tests passed with this command:

.\scripts\test.bat --run src\vs\platform\agentHost\test\node\copilotToolDisplay.test.ts --run src\vs\workbench\contrib\chat\test\browser\agentSessions\agentHostChatContribution.test.ts --grep "Sandbox path grant confirmation display|sandbox path grant" --reporter spec

Changed-file ESLint: passed, 10 files.

npm run eslint -- src\vs\platform\agentHost\common\sandboxPathGrant.ts src\vs\platform\agentHost\node\copilot\copilotAgentSession.ts src\vs\platform\agentHost\node\copilot\copilotSessionSandbox.ts src\vs\platform\agentHost\node\copilot\copilotToolDisplay.ts src\vs\platform\agentHost\test\node\copilotAgentSession.test.ts src\vs\platform\agentHost\test\node\copilotToolDisplay.test.ts src\vs\platform\agentHost\test\node\sessionSandbox.test.ts src\vs\workbench\contrib\chat\browser\actions\chatAccessibilityHelp.ts src\vs\workbench\contrib\chat\test\browser\agentSessions\agentHostChatContribution.test.ts src\vs\workbench\contrib\chat\test\browser\agentSessions\agentHostSandboxPathGrant.test.ts

Copilot AI balanced review requested due to automatic review settings October 13, 2026 00:13

Copilot AI left a comment

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.

🟡 Changes recommended

Pending refreshes can strand confirmations, and stale session grants can override persistent read/write upgrades.

2 open findings
What changed in this PR

Adds session-scoped and persistent sandbox path grants while preserving sandbox enforcement.

Changes:

  • Introduces validated path-grant metadata and persistence acknowledgements.
  • Adds confirmation UI, settings persistence, configuration synchronization, and accessibility guidance.
  • Adds focused coverage for grant handling, failures, cancellation, and platform paths.
File Description
src/​vs/​platform/​agentHost/​common/​agent.ts Extends permission response context.
src/​vs/​platform/​agentHost/​common/​meta/​vscode/​agentPermissionResponseMeta.ts Serializes persistence acknowledgements.
src/​vs/​platform/​agentHost/​common/​meta/​vscode/​agentToolCallMeta.ts Reads path-grant metadata.
src/​vs/​platform/​agentHost/​common/​sandboxPathGrant.ts Defines and applies grants.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Executes and tracks grants.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotToolDisplay.ts Builds grant confirmations.
src/​vs/​platform/​agentHost/​node/​sessionPermissions.ts Preserves grant options.
src/​vs/​platform/​agentHost/​test/​common/​agentPermissionResponseMeta.test.ts Tests acknowledgement metadata.
src/​vs/​platform/​agentHost/​test/​common/​sandboxPathGrant.test.ts Tests grant validation and application.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Tests runtime grant flows.
src/​vs/​platform/​agentHost/​test/​node/​copilotToolDisplay.test.ts Tests confirmation content.
src/​vs/​platform/​agentHost/​test/​node/​sessionSandbox.test.ts Tests option construction.
src/​vs/​workbench/​contrib/​chat/​browser/​actions/​chatAccessibilityHelp.ts Documents grant controls.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostSandboxNotifications.ts Generalizes failure text.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostSandboxPathGrant.ts Serializes settings writes.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostSessionHandler.ts Saves grants before confirmation.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostChatContribution.test.ts Tests save/dispatch ordering.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostSandboxNotifications.test.ts Updates notification expectations.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostSandboxPathGrant.test.ts Tests persistent settings writes.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +3585 to +3586
if (!isCurrent()) {
return;
Comment on lines +5994 to +5996
if (!response.persist) {
this._sessionSandboxPathGrants.push(grant);
}
@dileepyavan Dileep Yavanmandha (dileepyavan) changed the title Support session and persistent sandbox path grants Save sandbox path access in user settings Oct 14, 2026
@dileepyavan
Dileep Yavanmandha (dileepyavan) marked this pull request as ready for review October 14, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants