Skip to content

[1.138] Show effective sandbox policy in Copilot agent sessions - #335920

Open
Dileep Yavanmandha (dileepyavan) wants to merge 1 commit into
release/1.138from
DileepY/sandbox_diagnostics-1.138
Open

[1.138] Show effective sandbox policy in Copilot agent sessions#335920
Dileep Yavanmandha (dileepyavan) wants to merge 1 commit into
release/1.138from
DileepY/sandbox_diagnostics-1.138

Conversation

@dileepyavan

@dileepyavan Dileep Yavanmandha (dileepyavan) commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

fixes #330986

20260912-0056-47.9836396.mp4

Backport #335918 to release/1.138 by cherry-picking commit adc9092582503ef136344e5d017aa68b3c10c944 with provenance (git cherry-pick -x).

Backport commit: fe1417b0daa. The cherry-pick applied without conflicts or release-specific code changes. The original PR against main remains unchanged.

Changes

  • Add /sandbox-policy completion for Copilot agent-host sessions, mapping it to the SDK's existing /sandbox policy command without starting a model turn or changing sandbox enforcement.
  • Persist a uniquely named Markdown report for each invocation and show an Open Sandbox Policy preview link in chat.
  • Keep SDK mapping, argument validation, ANSI cleanup, report formatting, and persistence in the sandbox display implementation. Propagate SDK and file-write failures instead of emitting broken links.
  • Introduce optional command invocation/output hooks with fallbacks to existing SDK behavior; support structured text and link output with optional Markdown/preview flags.
  • Preserve preview metadata across local and remote Agent Host URI rewriting, use theme-aware chat link colors, and support mouse and keyboard activation.
  • Reuse a single-anchor rendering helper to avoid a second anchor scan and duplicate widget registration. Reuse shared SDK command metadata types.
  • Add accessible-help guidance, unit coverage, and dark/light visual fixtures.

Compatibility

Existing commands retain their default invocation, rendering, and lifecycle when no custom handler applies. No SDK dependency updates, additional permissions, or sandbox enforcement changes are included.

Release-branch validation

  • 801 targeted tests passed across Copilot sessions, command handlers, completion, inline anchors, Markdown content, URI rewriting, and accessibility help.
  • Core typecheck and transpile watchers completed with zero errors after the cherry-pick.
  • git diff origin/release/1.138...HEAD --check passed.
  • Branch contains only the requested cherry-picked commit on top of release/1.138.

The original change additionally passed ESLint, CSS lint, and dark/light visual checks. Coverage includes a 1,001-link response with one anchor scan, optional-hook fallbacks, report snapshots and failures, local/remote links, and keyboard activation.

Copilot AI balanced review requested due to automatic review settings September 12, 2026 01:12
@dileepyavan Dileep Yavanmandha (dileepyavan) changed the title [1.138] Add sandbox policy reports to Copilot agent sessions [1.138] Show effective sandbox policy in Copilot agent sessions Sep 12, 2026

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.

Copilot review overview

🟡 Changes recommended

Output hooks can bypass cache invalidation or lose valid output, and the accessibility guidance omits Space activation.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 2 Medium severity · 1 Low severity

Open findings (3)
What changed in this PR

Backports sandbox-policy reporting for Copilot Agent Host sessions, exposing the effective policy as a persistent Markdown preview.

Changes:

  • Adds /sandbox-policy invocation, formatting, persistence, and completion.
  • Adds preview-aware link rendering, URI rewriting, keyboard support, and styling.
  • Adds unit and visual fixture coverage.
File Description
chatWidget.fixture.ts Adds sandbox-policy visual fixture.
chatMarkdownContentPart.test.ts Tests preview rendering and activation.
chatInlineAnchorWidget.test.ts Tests metadata filtering and opening.
stateToProgressAdapter.test.ts Tests URI metadata preservation.
chatAccessibilityHelp.test.ts Tests new help guidance.
chatInlineAnchorWidget.css Styles preview links.
chatMarkdownDecorationsRenderer.ts Renders preview anchors in one scan.
chatInlineAnchorWidget.ts Adds preview-aware widgets and keyboard handling.
stateToProgressAdapter.ts Preserves preview metadata during URI rewriting.
chatAccessibilityHelp.ts Documents sandbox-policy interaction.
copilotSlashCommandCompletionProvider.test.ts Tests command discovery and collisions.
copilotSlashCommand.test.ts Tests command hooks and output rendering.
copilotAgentSession.test.ts Tests policy formatting, persistence, and failures.
copilotSlashCommandProvider.ts Adds the host command and handlers.
copilotSlashCommandCompletionProvider.ts Reuses shared SDK command types.
copilotSlashCommand.ts Defines invocation and output hooks.
copilotSandboxPolicyDisplay.ts Builds and persists policy reports.
copilotAgentSession.ts Integrates custom command invocation and output.
copilotAgent.ts Updates provider construction.

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

this._logService.error(err, `[Copilot:${this.sessionId}] rpc.commands.invoke(${slashCommand.command}) failed`);
throw err;
}
const output = await runtimeSlashCommand.getOutput?.(slashCommand.rest, result);
throw err;
}
const output = await runtimeSlashCommand.getOutput?.(slashCommand.rest, result);
const renderedOutput = output ? renderCopilotSlashCommandOutput(output) : undefined;
content.push(localize('workbench.action.openAgentsWindow', 'To open the Agents Window, invoke the Open Agents Window command{0}. In screen reader mode, this keybinding includes Alt to avoid conflicts with screen reader shortcuts.', '<keybinding:workbench.action.openAgentsWindow>'));
content.push(localize('workbench.action.chat.openAgentHostFolderPicker', 'When starting an agent session in a multi-root workspace, you can choose which root folder it runs in by invoking the Folder command{0}, then selecting a folder from the list.', '<keybinding:workbench.action.chat.openAgentHostFolderPicker>'));
content.push(localize('chat.agentHostApprovalsPicker', 'When an agent session exposes approval presets, use Tab to reach the Approvals picker and choose how it handles workspace access, commands, and the internet.'));
content.push(localize('chat.agentHostSandboxPolicy', "In Copilot agent-host sessions, use /sandbox-policy to view the effective sandbox policy. In the response, use Tab to focus Open Sandbox Policy and Enter to open the formatted report."));
@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: b065ad9c Current: cf426573

4 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

Added (2)

chat/widget/chatWidget/SandboxPolicyLink/Dark

current

chat/widget/chatWidget/SandboxPolicyLink/Light

current

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.

2 participants