Skip to content

Canvases: enable remote Agent Host presentation - #345102

Merged
Ulugbek Abdullaev (ulugbekna) merged 2 commits into
mainfrom
ulugbekna/agents/remote-canvas-support-exploration
Oct 30, 2026
Merged

Ulugbek Abdullaev (ulugbekna) merged 2 commits into
mainfrom
ulugbekna/agents/remote-canvas-support-exploration

Conversation

@ulugbekna

@ulugbekna Ulugbek Abdullaev (ulugbekna) commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Prerequisite

microsoft/vscode#345149 merged into main and provides the generic WebSocket/WebRTC/popup hardening used here. This branch is rebased directly onto the merged commits.

Deep architecture explainer

Remote canvases from the ground up explains the protocol state, ownership model, BrowserView network routing, authenticated proxy and Agent Host TCP flow, lifecycle, security boundaries, validation, and debugging path without assuming prior context.

Summary

This enables desktop canvases published by a remote Agent Host to render in the existing native BrowserView canvas editor.

Remote canvas URLs retain their original URL, including 127.0.0.1, while the BrowserView resolves the network from the exact owning session/chat. The canvas requires that network, preventing a disconnected, unsupported, or disabled remote from falling back to the client or an unrelated workspace remote.

Architecture

Remote Agent Host publishes CanvasState.url
                    │
                    ▼
AgentHostCanvasCollection projects the exact chat-owned canvas
                    │
                    ▼
CanvasService creates an unlisted BrowserView for the owning chat
                    │
                    ▼
SessionBrowserNetworkContribution resolves chat → session → host authority
                    │
                    ▼
BrowserViewWorkbenchService requires that resolved network
                    │
                    ▼
Existing authenticated Agent Host BrowserView proxy
                    │
                    ▼
Remote Agent Host network, including its loopback canvas server

Fail-closed behavior

  • CanvasService supplies the exact chat owner and requests strict network resolution.
  • BrowserViewWorkbenchService resolves the owner even when remote proxying is disabled, then rejects if that network cannot be used.
  • Ambient remote Editor windows delegate TCP to their Agent Host connection.
  • Non-ambient remote hosts present canvases only in the Agents window, where owning-session resolution exists.
  • Local canvases retain their current behavior.

How to review

Review the two commits independently:

1. canvases: enable remote Agent Host presentation

  1. Provider policy:
  2. Exact network requirement:
  3. Ambient remote Editor TCP:

Canvas enablement and strict routing intentionally remain in the same commit: enabling presentation without fail-closed ownership would create an unsafe intermediate state.

2. canvases: add native remote network coverage

  • browser.test.ts drives a real Electron BrowserView through redirect, SSE, ws://, an 8 MiB response, and WebRTC gathering.
  • It first disables remote proxying and verifies zero HTTP/WebSocket/UDP traffic.
  • It then enables proxying and verifies all browser protocols succeed with zero UDP/STUN leakage.

Validation

  • npm run build-fast -- --client-only — passed
  • npm run typecheck-client — passed
  • Provider, canvas, chat contribution, and ambient remote client suites — 1,824 passed
  • Changed TypeScript ESLint — passed for 13 files
  • npm run valid-layers-check — passed
  • npm run gulp compile-extension:vscode-api-tests — passed with 0 errors
  • ./scripts/test-integration.sh --suite api-folder --grep "remote Agent Host network loads native Chromium protocols and fails closed" — 1 passed
  • git diff origin/main..HEAD --check — passed

Manual dogfood

Verified against a Windows devbox2 Remote Agent Host through an authenticated dev tunnel:

  • the remote agent discovered and opened the Session timeline canvas;
  • the BrowserView rendered while retaining its remote loopback URL;
  • that port had no listener on the Mac and direct local curl failed, confirming traffic crossed the Agent Host proxy;
  • closing, reopening, and interacting with the canvas succeeded.

Scope and limitations

  • Desktop native BrowserViews only.
  • Copilot Agent Host canvas channels only.
  • No public extension API changes.
  • No relay transport support without negotiated TCP forwarding.
  • Non-ambient remote hosts present canvases only in the Agents window.

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

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

Remote canvas loopback URLs can load on the client or an unrelated workspace remote because owning-connection resolution is missing and the required-network check accepts undefined.

3 open issues
What changed in this PR

This PR extends the existing native BrowserView canvas editor to present canvases published by remote Copilot Agent Host sessions on desktop.

Changes:

  • Enables remote canvas presentation and adds required-network selection plus ambient remote TCP forwarding.
  • Hardens remote browser traffic with authenticated WebSocket upgrades, WebRTC UDP containment, and popup restrictions.
  • Adds focused unit and native integration coverage, and updates provider documentation.
File Description
src/​vs/​workbench/​services/​agentHost/​test/​browser/​editorRemoteAgentHostServiceClient.test.ts Tests TCP connection delegation.
src/​vs/​workbench/​services/​agentHost/​browser/​editorRemoteAgentHostServiceClient.ts Delegates TCP connections to the protocol client.
src/​vs/​workbench/​contrib/​chat/​browser/​remoteAgentHost/​remoteAgentHostChatContribution.ts Enables desktop remote Copilot canvases.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostChatContribution.ts Extends canvas support to ambient remote hosts.
src/​vs/​workbench/​contrib/​canvases/​electron-browser/​canvasService.ts Requests required-network canvas creation.
src/​vs/​workbench/​contrib/​browserView/​test/​electron-browser/​browserViewWorkbenchService.test.ts Tests rejection of unavailable required networks.
src/​vs/​workbench/​contrib/​browserView/​electron-browser/​browserViewWorkbenchService.ts Adds strict network selection for embedded views.
src/​vs/​workbench/​contrib/​browserView/​electron-browser/​browserView.contribution.ts Adds extension-test commands for networked views.
src/​vs/​workbench/​contrib/​browserView/​common/​browserView.ts Extends the embedded-view creation interface.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​test/​browser/​remoteAgentHostSessionsProvider.test.ts Tests remote canvas capability exposure.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md Documents remote canvas routing and containment.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​browser/​remoteAgentHostSessionsProvider.ts Advertises desktop Copilot canvas support.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Renames a test to reflect expanded support.
src/​vs/​sessions/​contrib/​providers/​agentHost/​AGENT_HOST_SESSIONS_PROVIDER.md Updates the canvas presentation contract.
src/​vs/​platform/​tunnel/​test/​node/​tunnelProxy.test.ts Covers direct streams, upgrades, and cancellation.
src/​vs/​platform/​tunnel/​node/​tunnelProxy.ts Forwards authenticated upgrades and reduces URL logging.
src/​vs/​platform/​browserView/​test/​common/​browserView.test.ts Tests remote unlisted popup denial.
src/​vs/​platform/​browserView/​electron-main/​browserView.ts Applies WebRTC and popup containment.
src/​vs/​platform/​browserView/​common/​browserView.ts Denies popups from remote unlisted views.
extensions/​vscode-api-tests/​src/​singlefolder-tests/​browser.test.ts Exercises native protocols and network containment.

Review effort: Balanced

@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/remote-canvas-support-exploration branch from a8b7091 to 9a7c234 Compare October 30, 2026 09:21
@ulugbekna
Ulugbek Abdullaev (ulugbekna) changed the base branch from main to ulugbekna/agents/remote-browser-proxy-hardening October 30, 2026 09:21
@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/remote-browser-proxy-hardening branch from dcb21b8 to 69f99fc Compare October 30, 2026 09:34
@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/remote-canvas-support-exploration branch from 9a7c234 to 149fe29 Compare October 30, 2026 09:34
Base automatically changed from ulugbekna/agents/remote-browser-proxy-hardening to main October 30, 2026 09:50
Enable desktop Copilot canvases for remote Agent Host sessions and require the owning chat's resolved BrowserView network, including ambient remote Editor connections, so canvas traffic never falls back locally.

Co-authored-by: Copilot <[email protected]>
Exercise redirect, SSE, WebSocket, large-response, and WebRTC behavior through a real Agent Host BrowserView network, including fail-closed behavior while remote proxying is disabled.

Co-authored-by: Copilot <[email protected]>
@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/remote-canvas-support-exploration branch from 149fe29 to cd4b93c Compare October 30, 2026 09:53
@ulugbekna
Ulugbek Abdullaev (ulugbekna) marked this pull request as ready for review October 30, 2026 09:58
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Kyle Cutler (@kycutler)

Matched files:

  • extensions/vscode-api-tests/src/singlefolder-tests/browser.test.ts
  • src/vs/workbench/contrib/browserView/common/browserView.ts
  • src/vs/workbench/contrib/browserView/electron-browser/browserView.contribution.ts
  • src/vs/workbench/contrib/browserView/electron-browser/browserViewWorkbenchService.ts
  • src/vs/workbench/contrib/browserView/test/electron-browser/browserViewWorkbenchService.test.ts

Joaquín Ruales (@jruales)

Matched files:

  • extensions/vscode-api-tests/src/singlefolder-tests/browser.test.ts
  • src/vs/workbench/contrib/browserView/common/browserView.ts
  • src/vs/workbench/contrib/browserView/electron-browser/browserView.contribution.ts
  • src/vs/workbench/contrib/browserView/electron-browser/browserViewWorkbenchService.ts
  • src/vs/workbench/contrib/browserView/test/electron-browser/browserViewWorkbenchService.test.ts

@ulugbekna
Ulugbek Abdullaev (ulugbekna) merged commit e245892 into main Oct 30, 2026
55 checks passed
@ulugbekna
Ulugbek Abdullaev (ulugbekna) deleted the ulugbekna/agents/remote-canvas-support-exploration branch October 30, 2026 10:07
@vs-code-engineering vs-code-engineering Bot added this to the 1.145.0 milestone Oct 30, 2026
Kyle Cutler (kycutler) added a commit that referenced this pull request Oct 30, 2026
* Browser: Tighten remote canvas networking

Follow-up to #345102 and #345149:
- Offer canvases on remote agent hosts only while browser remote proxying is enabled and the host can forward TCP; an unknown host, such as a disconnected one, keeps its canvases.
- Require an embedded view's owner network whenever an owner is given, instead of a separate flag.
- Remove the WebSocket upgrade handler from the tunnel proxy: Chromium always tunnels WebSockets, including ws://, through CONNECT.
- Replace the extension test commands with unit coverage for failing closed, gating, and large and WebSocket traffic over agent host streams.

Co-authored-by: Copilot <[email protected]>

* Browser: Address remote canvas review feedback

Resolve an embedded view's owner network before any asynchronous work and reject unknown agent owners instead of falling back to the local network. Gate remote editor-window canvases reactively on remote browser proxying. Cover the browser proxy over real Agent Host TCP and Chromium's remote WebSocket, large-response and WebRTC UDP behavior in the remote API suite.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
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