Skip to content

agentHost: add a macOS permission setup modal for Computer Use - #343308

Merged
Giuseppe Cianci (Giuspepe) merged 3 commits into
mainfrom
agents/pasted-text-processing
Oct 21, 2026
Merged

Giuseppe Cianci (Giuspepe) merged 3 commits into
mainfrom
agents/pasted-text-processing

Conversation

@Giuspepe

@Giuspepe Giuseppe Cianci (Giuspepe) commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Why

Computer Use currently asks for macOS Accessibility and Screen Recording with a new question card at every step. This PR replaces those cards with one setup modal. It shows the verified state of both permissions and lets the waiting task continue once both are on.

What changed

  • The local macOS Agent Host turns the plugin's permission prompts into one setup per waiting turn and publishes it as vscode.computerUse.status. Clients act through vscode.computerUse.request, and chat shows one card that opens the modal.
  • The Agent Host checks Accessibility again as soon as macOS posts com.apple.accessibility.api, so the row turns on without a click.
  • For the System Settings step, the modal offers the helper app as a native drag into the permission list, plus Show in Finder. It shows the app's own icon, read from its .icns file.

Scope

  • Covers macOS desktop windows for local Copilot sessions. Other clients and hosts keep the plugin's questions, and no Agent Host Protocol types change.
  • Screen Recording is still checked when the window regains focus, because macOS reports that grant only to a new process.
  • A real mouse drag into System Settings and a real Accessibility toggle are untested. Live checks posted the notification by script.

Tradeoffs

  • Polling the plugin's permission check was rejected. Its helper treats the Agent Host as an untrusted parent and shows an alert on every connection.
  • Electron's app.getFileIcon returns at most 64 px and hung the main process at the large size, so the Agent Host reads the PNG from the app's icon file.

Blast Radius

Chat shows the setup card only for the local Agent Host in a macOS window. IDialogOptions.renderIcon and INativeHostService.startFileDrag change nothing until a caller uses them, and the main process listens for one macOS notification while the Agent Host runs.

Verification

  • Tests, types and layers pass:
    ./scripts/test.sh --run src/vs/platform/agentHost/test/common/computerUse.test.ts --run src/vs/platform/agentHost/test/node/copilotComputerUsePlugin.test.ts --run src/vs/platform/agentHost/test/node/copilotComputerUsePermissionSetup.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentSessions/computerUseSetupDialog.test.ts --run src/vs/base/test/browser/ui/dialog/dialog.test.ts # 46 passing
    ./scripts/test.sh --run src/vs/platform/agentHost/test/node/agentService.test.ts # 1306 passing, 16 pending
    ./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --grep "[Cc]omputer [Uu]se|ComputerUse" # 16 passing
    npm run typecheck-client # passed
    npm run valid-layers-check # passed
    ESLint, Stylelint and the pre-commit hygiene check report nothing on the changed files.
  • Drove the real modal in Code OSS against a live Agent Host through the first round, a running step, the System Settings step, an error, ready and ended. Tab reaches every control. Outlines measure about 1.3:1 against the dialog in the default light and dark themes, and high contrast themes use their contrast border.
  • To try it on macOS, turn on chat.agentHost.computerUse.enabled, run /computer on in a local Copilot chat, and ask it to use an app. Set Up Computer Use in the Command Palette opens the modal any time.

Computer Use's macOS permission prompts arrived as a new question carousel
for every step, so granting Accessibility and Screen Recording meant
answering a series of repeated forms.

The local macOS Agent Host now recognizes those prompts by their verified
source and structured choices and turns them into one setup per waiting
turn. It publishes the setup as the transient root value
`vscode.computerUse.status` and takes nonce-claimed requests from
`vscode.computerUse.request`, answering the plugin's pending prompt over
the MCP connection the Copilot runtime owns. Actions run one at a time
across chats, permissions are reported only as verified by the plugin, and
turn cancellation, disposal and stale requests complete each prompt
exactly once.

Chat shows a single card whose button opens a setup modal with live
status, per-permission actions, a check when the window regains focus, and
Continue once both permissions are confirmed. Other clients and hosts keep
the plugin's ordinary questions, and no Agent Host Protocol types change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The setup modal only noticed a new Accessibility grant when the window
regained focus. The System Settings step also assumed macOS still
listed Copilot Computer Use, which it doesn't after the user removes
the app.

The Electron main process now forwards the macOS notification
com.apple.accessibility.api to the Agent Host, which checks waiting
setups again on its own. It ignores the notification while macOS shows
its Accessibility prompt, because a check restarts the helper that
holds the prompt open. Screen Recording keeps the focus check, since
macOS reports that grant only to a new process.

For the System Settings step, the modal offers the helper app as a
native file drag into the permission list, plus Show in Finder. It
also shows the app's own icon, read from its .icns file, with one
action per permission and shorter copy.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 21, 2026 18:46
…ocessing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Adds a macOS-specific “Computer Use” permission setup flow that replaces repeated plugin prompts with a single setup modal, plus the supporting host/client plumbing to publish status, request actions, and improve UX around Accessibility / Screen Recording.

Changes:

  • Introduces a Computer Use setup service + modal UI (including helper-app drag-to-System Settings support) and wires it into chat rendering.
  • Adds a new native host API to start a native file drag, plus macOS Accessibility trust-change reporting to re-verify automatically.
  • Adds schema/metadata readers and extensive tests for the new status/request contract and UI behavior.
File Description
src/​vs/​workbench/​test/​electron-browser/​workbenchTestServices.ts Extends test native host service with startFileDrag API surface.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​stateToProgressAdapter.test.ts Adds coverage for restoring Computer Use setup requests as settled cards.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​computerUseSetupDialog.test.ts New tests for the Computer Use setup modal view/panel/dialog behavior.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostChatContribution.test.ts Adds tests for rendering the setup card and opening the modal via service.
src/​vs/​workbench/​contrib/​chat/​electron-browser/​chat.contribution.ts Registers helper-app contribution in electron chat contribution.
src/​vs/​workbench/​contrib/​chat/​electron-browser/​agentSessions/​computerUseHelperApp.contribution.ts New workbench contribution to bridge modal drag/reveal to native host APIs.
src/​vs/​workbench/​contrib/​chat/​common/​model/​chatProgressTypes/​chatElicitationRequestPart.ts Adds keepActionsWhilePending to elicitation request parts.
src/​vs/​workbench/​contrib/​chat/​common/​chatService/​chatService.ts Documents/extends elicitation request API with keepActionsWhilePending.
src/​vs/​workbench/​contrib/​chat/​browser/​widget/​chatContentParts/​chatElicitationContentPart.ts Keeps elicitation buttons visible while state remains pending when opted in.
src/​vs/​workbench/​contrib/​chat/​browser/​chat.shared.contribution.ts Registers Computer Use setup service + command contribution.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​stateToProgressAdapter.ts Converts settled setup requests into serialized elicitation cards for transcript/history.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​media/​computerUseSetup.css New styling for the Computer Use setup modal/panel.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​computerUseSetupDialog.ts New setup modal implementation (view model + panel + dialog).
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​computerUseSetup.ts New setup service that reads host status and opens/reveals modal.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​computerUseSetup.contribution.ts Registers setup service singleton and “Set Up Computer Use” command.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostSessionHandler.ts Renders setup card that opens modal and ensures stable keying for in-place updates.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostChatContribution.ts Enables setup-card UX only for supported local macOS clients/hosts.
src/​vs/​sessions/​sessions.desktop.main.ts Registers helper-app contribution for sessions desktop entrypoint.
src/​vs/​platform/​native/​electron-main/​nativeHostMainService.ts Implements startFileDrag in main process via webContents.startDrag.
src/​vs/​platform/​native/​common/​native.ts Adds startFileDrag API contract to common native host service.
src/​vs/​platform/​agentHost/​test/​node/​copilotComputerUseTestUtils.ts New test utilities for Computer Use permission schemas + config harness.
src/​vs/​platform/​agentHost/​test/​node/​copilotComputerUsePlugin.test.ts Adds tests for helper app path resolution and .icns icon extraction.
src/​vs/​platform/​agentHost/​test/​node/​copilotComputerUsePermissionSetup.test.ts New comprehensive tests for permission setup orchestration and status publishing.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Integrates permission setup routing into agent session tests.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Verifies status publishing only for local macOS agent host when enabled.
src/​vs/​platform/​agentHost/​test/​node/​agentServiceTestUtils.ts Registers accessibility trust service in agent host test service set.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Updates management service construction to include accessibility trust service.
src/​vs/​platform/​agentHost/​test/​common/​computerUse.test.ts New tests validating request/status/meta contract readers and invariants.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotComputerUsePlugin.ts Adds helper app path resolution and macOS .icns icon extraction helpers.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotComputerUsePermissionSetup.ts New shared setup orchestrator that publishes status + answers prompts via queued actions.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Routes Computer Use permission prompts through shared setup when available.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Creates/disposes shared permission setup on macOS when Computer Use is enabled.
src/​vs/​platform/​agentHost/​node/​agentHostManagementService.ts Adds management API to report macOS Accessibility trust changes into agent host.
src/​vs/​platform/​agentHost/​node/​agentHostMacAccessibilityTrustService.ts New service relaying reported Accessibility trust-change signals to consumers.
src/​vs/​platform/​agentHost/​node/​agentHostBootstrap.ts Registers accessibility trust service in agent host runtime DI.
src/​vs/​platform/​agentHost/​electron-main/​electronAgentHostStarter.ts Subscribes to macOS Accessibility trust change notification and forwards to agent host.
src/​vs/​platform/​agentHost/​common/​meta/​vscode/​computerUse.ts New validating readers/writers for Computer Use status + setup-card meta.
src/​vs/​platform/​agentHost/​common/​meta/​computerUse.ts Exposes readers and provides root-state status extraction helper.
src/​vs/​platform/​agentHost/​common/​computerUse.ts Defines the Computer Use status/request contract and request validator.
src/​vs/​platform/​agentHost/​common/​agentService.ts Adds management service API reportMacAccessibilityTrustChange.
src/​vs/​base/​browser/​ui/​dialog/​dialog.ts Adds renderIcon option to render custom dialog icons.
src/​vs/​base/​browser/​ui/​dialog/​dialog.css Styles dialog icon container when a custom icon is rendered.
build/​lib/​stylelint/​vscode-known-variables.json Registers new CSS custom property --computer-use-setup-stroke for linting.

Review effort: Lite

Comment thread src/vs/base/browser/ui/dialog/dialog.ts Resolved
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