Repository navigation
agentHost: keep lazily activated canvases open across runtime refreshes - #347946
Merged
Ulugbek Abdullaev (ulugbekna) merged 1 commit intoNov 12, 2026
Merged
Ulugbek Abdullaev (ulugbekna) merged 1 commit into
Ulugbek Abdullaev (ulugbekna) merged 1 commit into
Conversation
The Agent Host disconnects and resumes a chat's Copilot runtime session in place after a configuration refresh, a telemetry revocation, or an idle release. It hands the chat's open canvases to the replacement and keeps those the resumed runtime lists as open. The runtime can now start an extension lazily, and on resume it keeps a restored canvas of such an extension hidden from `canvas.listOpen` until a host opens the same instance again. The Agent Host removed those canvases, which closed the user's canvas tabs. Keep each canvas's open input privately in the projection and carry it in the handoff. When a handed-over canvas is missing from the resumed runtime's open canvases but still declared, keep it projected as unavailable and reopen it in the background with its instance ID and input. The runtime treats this as a reopen, so it starts the extension without recording a new first open. The reopen doesn't delay the resume or the turn, and its timeout leaves the canvas unavailable without desynchronizing the session; a late reopen still arrives as an opened event. Co-authored-by: Copilot <[email protected]>
Dirk Bäumer (dbaeumer)
approved these changes
Nov 12, 2026
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Only local validation is reported for the bundled-runtime lazy-extension lifecycle test; required packaged Electron integration runs on Windows, Linux, and macOS, including repeated lifecycle runs, still need confirmation before merging.
No open issues 🎉
What changed in this PR
Preserves open canvases from lazily activated extensions when the Agent Host replaces a Copilot runtime session, extending the earlier dormant-extension support.
Changes:
- Retains canvas input privately across runtime handoffs without exposing it in published state.
- Reopens still-declared canvases in the background, keeping tabs unavailable until recovery completes without delaying resume or desynchronizing the session on timeout.
- Adds unit and SDK integration coverage for recovery, failures, close races, input preservation, and first-open telemetry.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/copilotSdkCanvas.integrationTest.ts |
Adds a lazy-provider fixture and verifies same-client resume and reopen behavior. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests handoff recovery, timeouts, failures, close races, and private input retention. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Preserves input and performs bounded background recovery of handed-over canvases. |
Review effort: Balanced
Ulugbek Abdullaev (ulugbekna)
deleted the
ulugbekna/agents/dormant-canvas-preservation-fix
branch
November 12, 2026 17:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #347629.
The Copilot runtime can start an extension lazily (github/copilot-agent-runtime#28873). An extension that declares its canvases in an
extension.jsonsidecar with"initialization": "module"starts on first use.The Agent Host sometimes replaces a chat's runtime session in place: after a configuration refresh, after telemetry is revoked, or when an idle chat is released and later resumed. It hands the chat's open canvases to the replacement, then keeps the ones the resumed runtime lists as open. On resume, the runtime keeps a restored canvas of a lazily activated extension out of
canvas.listOpenuntil a host opens the same instance again. The Agent Host removed those canvases, so the user's canvas tab closed on the next refresh.Changes
CanvasState.canvas.list:canvas.open, using the same instance ID and input. The runtime treats this as a reopen: it starts the extension, publishes the canvas with a new URL, and records no new first open, so first-open telemetry is unaffected.How to test
COPILOT_HOMEto an empty folder and add thedormant-demoextension from agentHost: treat dormant canvas extensions as enabled and settled #347629 toextensions/dormant-demo/inside it.chat.canvases.enabled. Start a Copilot chat on a folder in the Agents window, and open Dormant Demo..github/agents/probe.agent.md, to the folder and send a message. The Agent Host log showsSession configuration changed, refreshing sessionwithreason=clientPluginsChanged.extension.json. Its canvas also stays open.Demo, recorded in a dev build of the Agents window: first without this change (the Dormant Demo tab closes), then with it (both a lazily activated and an eagerly started canvas stay open and come back from new extension processes with their input). https://raw.githubusercontent.com/ulugbekna/screenshots/main/attachments/2026/11/12/dormant-canvas-runtime-refresh.mp4
Validation
./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts: passed (2784 passing, 1 existing pending). With the source change reverted, 5 of the 6 new tests fail. The sixth, a close during the reopen, passes either way../scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/copilotSdkCanvas.integrationTest.ts: passed (4 passing). The new test records the runtime behavior against the bundled runtime. After a resume on the same client, a lazily activated extension staysdormant, and its canvas is missing fromopenCanvasesandlistOpen. Opening the same instance ID again brings the canvas back with its input and records no new first open. The test doesn't run the Agent Host, so it passes without this change.pnpm run typecheck-client: passed.pnpm run oxlint <changed files>: passed.main, which didn't change these files.Notes
openCanvaseslist passed tosession.resumewhen it decides which restored canvases to rehydrate. If it starts honoring that list, or offers a rehydrate call that reuses the stored input, this reopen could become simpler.