Skip to content

agentHost: finish adopting lazily activated canvas extensions - #348466

Merged
Ulugbek Abdullaev (ulugbekna) merged 2 commits into
mainfrom
ulugbekna/agents/p0-4-p1-p2-subchat-implementation
Nov 16, 2026
Merged

Ulugbek Abdullaev (ulugbekna) merged 2 commits into
mainfrom
ulugbekna/agents/p0-4-p1-p2-subchat-implementation

Conversation

@ulugbekna

Copy link
Copy Markdown
Contributor

Follow-up to #347629, #347946 and #348216.

The Copilot runtime can start an extension on first use instead of with the session (github/copilot-agent-runtime#28873). An extension opts in with an extension.json sidecar that declares its canvases and tools. Its process then starts on the first canvas open, canvas action, or native tool call, and until then the extension is dormant. The same runtime release adds an optional icon to canvas declarations and an optional title to native tools.

VS Code already lists dormant extensions and keeps their canvases open across refreshes. This finishes the adoption.

Changes

The first commit holds the adoption. The second adapts pinned canvases, which landed on main meanwhile, to the new error handling.

  1. End-to-end coverage. A new integration suite runs a project extension with a sidecar through CopilotAgent, VS Code's production extension launcher, and the bundled runtime.
    • Before first use, listAgentExtensions reports it dormant and listSessionCanvases lists its canvas, with no process started.
    • The first open starts it once, and a repeated open doesn't start it again.
    • A canvas action the model calls works.
  2. create-canvas skill. It now writes the sidecar for canvas-only extensions, and imports the same declarations in extension.mjs so the two can't drift. It covers the runtime's rules: no null fields, the 256 KiB limit, joinSession() at top level, staying eager for hooks and observers, and the optional icon. It also corrects what extensions_reload does with dormant extensions. The skill stays host-neutral.
  3. First open from the UI. A first open waits for the extension to start, and sometimes for consent.
    • After 500 ms, a notification shows "Opening canvas {0}...", which screen readers announce. A warm open finishes before it appears.
    • The runtime reports why an open failed only in error text. The host maps its exact messages to dismissed, reloaded, mismatchedDeclaration, startFailed and unavailable, and returns that over IPC. An extension's own errors keep their text.
    • The client shows a localized message that names the canvas. A dismissal shows nothing, and only reloaded offers Try Again.
    • This reuses agentHost: ask before a Copilot extension reads sensitive environment variables #348216's notification. Each Try Again now picks its retry from the latest failure, so a retry that is declined again asks again.
    • It covers the opens the UI requests: the Agents window canvas menus, the context picker, and the Canvases view. Reopening a pinned canvas after a restart shares its messages and Try Again.
  4. Telemetry.
    • agentHost.canvasExtensionsReady gains dormantExtensionCount. The field is additive, so schemaVersion stays 1.
    • The new agentHost.canvasHostOpen reports each open the host requests, from the UI or as a background restore. It records the extension's status just before the open (dormant for a cold start, or running), the outcome, whether someone was asked for consent in a turn or by the client, and durationMs.
    • A UI open is reported once, as its client saw it end, including timeout.
    • PERFORMANCE.md documents both events.
  5. Canvas icons. The runtime returns the icon as a host-local PNG path. A remote client can't read that, and the runtime checks the path only as text. So the host reads it and sends the image.
    • The host reads only a regular file inside the declaring extension's real directory, after resolving symbolic links, that is a bounded PNG (signature, IHDR, at most 4 Mpx, 350,000-character data URI).
    • The runtime doesn't report extension directories, so when more than one folder above the icon looks like the extension, no icon is shown.
    • The loader never opens FIFOs or devices, and caches by real path, modification time and size.
    • Canvas lists carry the image on IAgentCanvasInfo.icon. Open canvases carry it in a namespaced _meta entry, vscode.canvasIcons, until the Agent Host Protocol gives CanvasState icons. Clients validate it, and hosts that send none keep working.
    • Icons show in the Agents window canvas menus, the Canvases view, the pill and its dropdown, the context picker, and editor tabs, with Codicon.preview as the fallback.
    • They're decorative: labels and ARIA labels are unchanged. Each image's stylesheet is released when nothing shows it.
    • Icons are re-read when extensions reload.
  6. Native tool titles. Tool rows already used a native tool's title, but its permission prompt lost it. The prompt now keeps the title, and its question still names the exact tool. title is display-only and isn't sent to the model. VS Code's own client tools don't set it, since that would rename every client tool row.

How to test

  1. Set COPILOT_HOME to an empty folder, and enable chat.canvases.enabled.

  2. Add a user extension in extensions/lazy-board/ inside it, with a 32×32 icon.png:

    extension.json and extension.mjs
    {
    	"version": 1,
    	"initialization": "module",
    	"canvases": [{ "id": "lazy-board", "displayName": "Lazy Board", "description": "Starts on first use.", "icon": "icon.png" }]
    }
    import { createServer } from 'node:http';
    import { createCanvas, joinSession } from '@github/copilot-sdk/extension';
    import declaration from './extension.json' with { type: 'json' };
    
    // Makes the first open visibly slower.
    await new Promise(resolve => setTimeout(resolve, 3000));
    const server = createServer((_request, response) => {
    	response.writeHead(200, { 'content-type': 'text/html' });
    	response.end(`<h1>Lazy Board</h1><p>Started by pid ${process.pid}</p>`);
    });
    await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
    await joinSession({
    	canvases: declaration.canvases.map(canvas => createCanvas({
    		...canvas,
    		open: ({ instanceId }) => ({ url: `http://127.0.0.1:${server.address().port}/${instanceId}` }),
    	})),
    });
  3. In the Agents window, start a chat in any folder and send a message.

  4. Open Lazy Board from Add Context > Canvas....

    • The picker, the Canvases view, the tab and the pill show its icon.
    • "Opening canvas Lazy Board..." appears until the canvas opens, about 3 seconds later. Opening it again shows no progress.
  5. To see an error, make extension.mjs register a canvas ID other than the one extension.json declares. Opening it then says it was withdrawn because it registered differently from its declaration.

  6. Replace icon.png while the canvas is open, then make the runtime reload: add .github/agents/probe.agent.md to the folder and send a message. The tab shows the new icon.

Demo, recorded in a dev build of the Agents window:

Screenshots: picker, Canvases view, pill dropdown, first-open progress, icon before and after a reload, native tool titles.

Validation

On this branch, rebased on current main with the bundled @github/copilot-sdk 1.0.33-preview.0:

  • npm run typecheck-client: passed.
  • ./scripts/test.sh --run with the 14 touched suites (copilotAgentSession, copilotAgent, agentService, copilotCanvasIcons, agentCanvasIconMeta, agentHostCanvas, agentHostCanvasConsent, editorCanvasActions, sessionCanvasRegistryService, sessionCanvasService, pinnedCanvasService, copilotCustomizationsWidget, localAgentHostSessionsProvider, chatPills): passed (5090 passing, 28 existing pending).
  • ./scripts/test-integration.sh --run with copilotNativeExtensions and copilotExtensionEnvConsent: passed (3 + 3 passing). These run the real bundled runtime.
  • ./scripts/test-integration.sh --run with copilotMockLlm, --grep canvas and --grep "lazy extension": passed (1 + 1 passing).
  • extensions/copilot: npx vitest --run --pool=forks src/platform/promptFiles/test/node/builtinSkills.spec.ts: passed (3 passing).
  • npm run oxlint -- <changed files>, npm run valid-layers-check, and node build/stylelint.ts on the two changed CSS files: passed.
  • @vscode/telemetry-extractor over src/vs/platform/agentHost/node: both events have the expected owner and fields. Every number and boolean is a measurement, and every field has a comment.
  • Code review fixes have focused tests that fail without the fix: icon folder checks, FIFO icons, restoring a canvas closed during the status read, retry options, input-only updates, icon refresh on reload, restore consent telemetry, and the classifier's negative cases.
  • Manual checks in a dev build of the Agents window, with throwaway user extensions:
    • Icons in every surface above. A symlinked icon outside the extension and a non-PNG icon fell back to the codicon. The context menu under Add Tab > Canvas shows no icons, as context menus don't render them.
    • First-open progress, the start-failure and withdrawn-declaration messages, and consent Not Now, then Try Again, then Allow.
    • Tool rows titled "Look Up Inventory" (lazy) and "Look Up Orders" (eager).
    • Telemetry with --log trace: a dormant open took about 3.1 s against about 2 ms warm, and a restore after a runtime replacement was reported as restore.
  • Not tested: icons from a remote Agent Host (unit tests only), and Windows or Linux.

Notes

  • Runtime follow-ups:
    • Report open failures with structured codes instead of text.
    • Send an event when a dormant extension starts.
    • Check icons beyond their path's text.
    • Let the Agent Host Protocol carry canvas icons, after which VS Code can drop its _meta entry.
  • The icon loader's folder checks can't pin directories, so a folder swapped between the checks and the read could redirect it. It could only redirect to a PNG shown to the same user, and only by code already running as that user.
  • The context picker passes icons to quick input, whose stylesheet cache keeps them for the window's lifetime. That's existing platform behavior.

Extensions that declare their canvases and tools in an extension.json
sidecar now start on first use. Cover that path end to end and make it
usable:

- Test dormant listing, first-open launch, repeated opens, canvas
  actions, and tool titles through the production extension launcher.
- Teach the create-canvas skill to write the sidecar.
- Show progress while a first open starts an extension, and explain
  why an open failed with a localized message and Try Again when it
  can help.
- Report dormant extensions in canvas readiness telemetry and add
  agentHost.canvasHostOpen to compare cold and warm opens.
- Show the PNG icons extensions declare for their canvases in canvas
  menus, the Canvases view, the canvas pill, the context picker, and
  editor tabs. The host validates and sends them as bounded data URIs,
  so remote clients can show them too.
- Keep the title a native tool declares in its permission prompt.

Co-authored-by: Copilot <[email protected]>
Pinned canvases now report a failed reopen with the same messages and
Try Again as other canvas opens, choosing each retry from its latest
failure.

Co-authored-by: Copilot <[email protected]>
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Joaquín Ruales (@jruales)

Matched files:

  • extensions/copilot/assets/prompts/skills/create-canvas/SKILL.md
  • src/vs/sessions/contrib/canvases/browser/pinnedCanvasService.ts
  • src/vs/sessions/contrib/canvases/electron-browser/sessionCanvasActions.ts
  • src/vs/sessions/contrib/canvases/electron-browser/sessionCanvasService.ts
  • src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasRegistryService.test.ts
  • src/vs/workbench/contrib/canvases/browser/canvasContextPicker.ts
  • src/vs/workbench/contrib/canvases/browser/canvasIcons.ts
  • src/vs/workbench/contrib/canvases/browser/canvasesPillControl.ts
  • src/vs/workbench/contrib/canvases/browser/editorCanvasActions.ts
  • src/vs/workbench/contrib/canvases/common/agentHostCanvas.ts
  • src/vs/workbench/contrib/canvases/common/agentHostCanvasConsent.ts
  • src/vs/workbench/contrib/canvases/common/canvas.ts
  • src/vs/workbench/contrib/canvases/electron-browser/editorCanvases.contribution.ts
  • src/vs/workbench/contrib/canvases/test/browser/editorCanvasActions.test.ts
  • src/vs/workbench/contrib/canvases/test/common/agentHostCanvas.test.ts
  • src/vs/workbench/contrib/canvases/test/common/agentHostCanvasConsent.test.ts

Sandeep Somavarapu (@sandy081)

Matched files:

  • src/vs/workbench/services/sessions/common/session.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/workbench/services/sessions/common/session.ts

@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 01bb4f80 Current: ff0ee76a

Changed (2)

chat/aiCustomizations/aiCustomizationManagementEditor/CanvasesTab/Light
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/CanvasesTabWithoutBrowse/Light
Before After
before after

@ulugbekna
Ulugbek Abdullaev (ulugbekna) added this pull request to the merge queue Nov 16, 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.

🟡 Changes recommended

Unresolved icon-validation and path-containment flaws permit oversized decoded images and sibling-directory access, while asynchronous refresh races can retain stale state or block canvas restoration.

5 open issues
What changed in this PR

Completes VS Code’s adoption of lazily activated canvas extensions, building on dormant-extension discovery, runtime-refresh restoration, and consent handling.

Changes:

  • Adds first-open progress, localized failure messages, retry handling, and native tool titles in permission prompts.
  • Loads and displays canvas icons across workbench surfaces, with host-side file validation and client metadata support.
  • Adds startup telemetry, runtime integration coverage, and lazy-extension authoring guidance.
File Description
src/​vs/​workbench/​services/​sessions/​common/​session.ts Adds icons to session canvas definitions.
src/​vs/​workbench/​contrib/​sessions/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Forwards canvas definition icons.
src/​vs/​workbench/​contrib/​chat/​browser/​aiCustomization/​media/​aiCustomizationManagement.css Styles canvas icons and disabled states.
src/​vs/​workbench/​contrib/​chat/​browser/​aiCustomization/​copilotCustomizationsWidget.ts Displays icons and shares open-progress/error handling.
src/​vs/​workbench/​contrib/​canvases/​test/​common/​agentHostCanvasConsent.test.ts Tests progress, failures, and retry selection.
src/​vs/​workbench/​contrib/​canvases/​test/​common/​agentHostCanvas.test.ts Tests icon metadata consumption and fallback.
src/​vs/​workbench/​contrib/​canvases/​test/​browser/​editorCanvasActions.test.ts Tests menu icons and progress-service wiring.
src/​vs/​workbench/​contrib/​canvases/​electron-browser/​editorCanvases.contribution.ts Injects progress support into canvas actions.
src/​vs/​workbench/​contrib/​canvases/​common/​canvas.ts Adds icon validation and editor-tab updates.
src/​vs/​workbench/​contrib/​canvases/​common/​agentHostCanvasConsent.ts Centralizes progress, failure messages, and retries.
src/​vs/​workbench/​contrib/​canvases/​common/​agentHostCanvas.ts Reads icons from host canvas metadata.
src/​vs/​workbench/​contrib/​canvases/​browser/​editorCanvasActions.ts Adds menu icons and shared opening feedback.
src/​vs/​workbench/​contrib/​canvases/​browser/​canvasIcons.ts Manages reference-counted image styles.
src/​vs/​workbench/​contrib/​canvases/​browser/​canvasesPillControl.ts Supplies image icons to canvas pills.
src/​vs/​workbench/​contrib/​canvases/​browser/​canvasContextPicker.ts Passes menu icons into picker entries.
src/​vs/​workbench/​common/​canvasReference.ts Adds icons to canvas instances.
src/​vs/​workbench/​browser/​media/​chatPills.css Sizes pill and dropdown image icons.
src/​vs/​workbench/​browser/​chatPills.ts Supports custom icon classes on pill entries.
src/​vs/​workbench/​browser/​chatDropdownPill.ts Renders and refreshes custom pill icons.
src/​vs/​sessions/​contrib/​canvases/​test/​electron-browser/​sessionCanvasRegistryService.test.ts Updates test wiring for progress support.
src/​vs/​sessions/​contrib/​canvases/​electron-browser/​sessionCanvasService.ts Uses shared canvas-opening feedback.
src/​vs/​sessions/​contrib/​canvases/​electron-browser/​sessionCanvasActions.ts Adds icons to Agents window canvas actions.
src/​vs/​sessions/​contrib/​canvases/​browser/​pinnedCanvasService.ts Shares failure and retry handling for pinned canvases.
src/​vs/​platform/​agentHost/​test/​node/​providerIntegration/​copilotNativeExtensions.integrationTest.ts Covers lazy activation and native tool titles.
src/​vs/​platform/​agentHost/​test/​node/​copilotCanvasIcons.test.ts Tests icon bounds, containment, and file handling.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Covers icon refresh, failures, restoration, and telemetry.
src/​vs/​platform/​agentHost/​test/​common/​agentCanvasIconMeta.test.ts Tests icon metadata validation and preservation.
src/​vs/​platform/​agentHost/​PERFORMANCE.md Documents readiness and host-open telemetry.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotCanvasIcons.ts Loads bounded PNG icons from extension directories.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Integrates icons, failure classification, telemetry, and tool titles.
src/​vs/​platform/​agentHost/​node/​agentHostTelemetryReporter.ts Adds dormant counts and host-open events.
src/​vs/​platform/​agentHost/​common/​meta/​vscode/​agentCanvasIconMeta.ts Defines icon metadata encoding and validation.
src/​vs/​platform/​agentHost/​common/​meta/​agentCanvasIconMeta.ts Exposes shared icon metadata helpers.
src/​vs/​platform/​agentHost/​common/​agent.ts Extends canvas icon and open-result contracts.
extensions/​copilot/​src/​platform/​promptFiles/​test/​node/​builtinSkills.spec.ts Checks lazy-canvas authoring guidance.
extensions/​copilot/​assets/​prompts/​skills/​create-canvas/​SKILL.md Documents sidecars, first-use activation, and validation.

Review effort: Balanced

Merged via the queue into main with commit 6659689 Nov 16, 2026
51 of 68 checks passed
@ulugbekna
Ulugbek Abdullaev (ulugbekna) deleted the ulugbekna/agents/p0-4-p1-p2-subchat-implementation branch November 16, 2026 06:47
@vs-code-engineering vs-code-engineering Bot added this to the 1.148.0 milestone Nov 16, 2026
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