Skip to content

agentHost: treat dormant canvas extensions as enabled and settled - #347629

Merged
Ulugbek Abdullaev (ulugbekna) merged 2 commits into
mainfrom
ulugbekna/agents/implement-dormant-extension-status
Nov 11, 2026
Merged

Ulugbek Abdullaev (ulugbekna) merged 2 commits into
mainfrom
ulugbekna/agents/implement-dormant-extension-status

Conversation

@ulugbekna

Copy link
Copy Markdown
Contributor

The Copilot runtime can now start an extension lazily (github/copilot-agent-runtime#28873). An extension that declares its tools and canvases in an extension.json sidecar with "initialization": "module" is advertised without starting its process, and it starts on first tool use or canvas open. Until then, session.extensions.list reports it as dormant, a status that means the extension is enabled.

VS Code mapped dormant to unknown, as #347239 notes. As a result, the Canvases view labeled these canvases Not Active although they are ready to open. It also never pruned their stale cached canvases.

Changes

  • The agent host and the AHP client pass dormant through instead of turning it into unknown. Older clients still map it to unknown, and hosts that never send it are unaffected.
  • A new helper, isAgentExtensionEnabledAndSettled, treats running and dormant alike. It is used in three places:
    • Confirming an enable after a reconciliation error. An enabled lazy extension stays dormant after reconciliation, so it now counts as applied instead of failed.
    • Merging duplicate inventory entries. When the runtime lists one ID twice as running and dormant, the merged status is now running instead of unknown. Other combinations merge as before.
    • Pruning cached canvases. The runtime's canvas list already includes a dormant extension's declared canvases, so it is authoritative for pruning.
  • Unchanged: canvas listing still waits only for starting extensions, so a dormant extension doesn't delay it. An inventory read without a live chat still reports unknown, because only a live chat knows whether an extension is dormant.

How to test

  1. Set COPILOT_HOME to an empty folder and create extensions/dormant-demo/ inside it with the two files below.
  2. Launch Code - OSS with that environment, enable chat.canvases.enabled, and start a Copilot chat in the Agents window. Don't open any canvas yet.
  3. Open Customizations > Canvases. Dormant Demo reads Ready to Open and its switch is on. No dormant-demo process has started. Each extension launch writes a logs/process-*.log file whose first line names the extension module.
  4. Open Dormant Demo. The runtime starts the extension, and the page shows the new process ID.
  5. In a new chat, disable and re-enable the extension before opening the canvas. It returns to Ready to Open, and no process starts.
Demo extension files

extension.json:

{
	"version": 1,
	"initialization": "module",
	"canvases": [
		{
			"id": "dormant-demo",
			"displayName": "Dormant Demo",
			"description": "Checks lazy canvas activation."
		}
	]
}

extension.mjs, which reuses the declarations from extension.json so they can't drift:

import { createServer } from "node:http";
import { createCanvas, joinSession } from "@github/copilot-sdk/extension";
import declaration from "./extension.json" with { type: "json" };

const startedAt = new Date().toISOString();
const server = createServer((_request, response) => {
	response.writeHead(200, { "content-type": "text/html; charset=utf-8" });
	response.end(`<!doctype html><html><body style="font-family: system-ui; padding: 24px"><h1>Dormant Demo</h1><p>Extension process ${process.pid} started at ${startedAt}.</p></body></html>`);
});
await new Promise(resolve => server.listen(0, "127.0.0.1", resolve));
const { port } = server.address();

await joinSession({
	canvases: [
		createCanvas({
			...declaration.canvases[0],
			open: () => ({ url: `http://127.0.0.1:${port}/`, title: declaration.canvases[0].displayName }),
		}),
	],
});

Demo, recorded in a dev build of the Agents window: https://raw.githubusercontent.com/ulugbekna/screenshots/main/attachments/2026/11/11/dormant-canvas-extension.mp4

Validation

  • ./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --run src/vs/platform/agentHost/test/electron-browser/agentHostProtocolClient.test.ts --run src/vs/workbench/contrib/chat/test/browser/aiCustomization/copilotCustomizationsWidget.test.ts: passed (3206 passing, 1 existing pending). With the source changes reverted, the 5 new tests fail.
  • npm run typecheck-client: passed
  • npm run eslint -- <changed TypeScript files>: passed
  • Manual check in a dev build of the Agents window, as in the demo above. In fresh chats, the live inventory reported dormant. It moved to running when the canvas was first opened, and went to disabled and back to dormant when toggled before first use. This check ran before the branch was updated to current main; the update conflicted only on an import line.

Note

In a chat that had already opened the canvas, disabling and re-enabling the extension started it immediately instead of leaving it dormant. This happened even after the canvas tab was closed. That is runtime behavior that this PR doesn't change, and I haven't confirmed whether the runtime intends it.

The Copilot runtime now reports `dormant` for extensions that declare their tools and canvases in an `extension.json` sidecar and start on first use. VS Code mapped the status to `unknown`, so the Canvases view labeled their canvases "Not Active" and never pruned their stale cached canvases.

Pass `dormant` through the agent host and the AHP client, and treat it like `running` when merging duplicate inventory entries, confirming an enable after reconciliation, and pruning cached canvas definitions.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 14:16

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

1 open issue
What changed in this PR

This PR updates VS Code’s agent host integration to treat dormant Copilot runtime extensions as enabled/settled (like running), ensuring canvases from lazy extensions appear “ready” and cached canvases are pruned correctly.

Changes:

  • Add dormant to AgentExtensionStatus and propagate it through the protocol/client instead of mapping to unknown.
  • Introduce and reuse isAgentExtensionEnabledAndSettled to treat running/dormant equivalently for reconciliation, inventory merge, and canvas-cache pruning.
  • Expand/adjust tests and spec text to cover dormant behavior.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​browser/​aiCustomization/​copilotCustomizationsWidget.test.ts Extends widget tests to cover pruning behavior for dormant inventories.
src/​vs/​workbench/​contrib/​chat/​browser/​aiCustomization/​copilotCustomizationsWidget.ts Uses the new helper so dormant extensions are treated as enabled/settled when pruning cached canvases.
src/​vs/​sessions/​copilot-customizations-spec.md Updates spec to document dormant and its semantics.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Adds coverage for listing dormant extensions and canvases without waiting for startup.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Adds merge/reconcile scenarios involving dormant.
src/​vs/​platform/​agentHost/​test/​electron-browser/​agentHostProtocolClient.test.ts Adds protocol parsing/forwarding coverage for dormant.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Maps runtime status strings to include dormant.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Uses helper for merge + reconciliation logic around dormant.
src/​vs/​platform/​agentHost/​common/​agentService.ts Re-exports isAgentExtensionEnabledAndSettled.
src/​vs/​platform/​agentHost/​common/​agent.ts Adds dormant to the status union and defines isAgentExtensionEnabledAndSettled.
src/​vs/​platform/​agentHost/​browser/​agentHostProtocolClient.ts Allows dormant through when decoding status from the wire.

Review effort: Lite

The comment sat above the whole status chain but only described the case where a `running` and a `dormant` copy merge, so it read as if it applied to every branch.

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.

4 participants