Repository navigation
Canvases: restore canvases after idle session release - #345740
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved canvas lifecycle issues can lose continuity or pending close intent, leave closed canvases visible, remove reopened canvases, and delay dismissal until runtime restoration completes.
5 open issues
Record closes and remove membership before observation restoration · New Publish membership when no chat snapshot is available · New Preserve canvas continuity when disposing the last watch during resume · New Retain deferred closes when no projections remain · New Track deferred close acknowledgements to ignore stale events · New
What changed in this PR
This PR restores Agent Host canvas continuity after idle Copilot chat release, allowing users to recover canvases by reopening a chat without sending another message.
Changes:
- Retains source-less canvas handoffs and restores fresh sources on existing channels when a chat is observed.
- Adds release vetoes, deferred closes, and continuity invalidation for lifecycle changes.
- Adds focused regression tests and documents idle-release behavior separately from configuration refreshes and process restarts.
| File | Description |
|---|---|
src/vs/sessions/contrib/providers/agentHost/AGENT_HOST_SESSIONS_PROVIDER.md |
Documents canvas continuity and close semantics. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests handoff publication, invalidation, and deferred closes. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Tests observation restore, scoped credentials, cancellation, and retention. |
src/vs/platform/agentHost/test/node/chatContributions.test.ts |
Tests continuity invalidation when archiving chats. |
src/vs/platform/agentHost/test/node/agentSessionResidency.test.ts |
Tests latched release vetoes. |
src/vs/platform/agentHost/test/node/agentService.test.ts |
Tests hydrated canvas watches and execution context. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Reconciles handoffs, republishes state, and applies deferred closes. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Manages retained continuity and observation-triggered restoration. |
src/vs/platform/agentHost/node/chatContributions/sessionFlags/sessionFlagsContribution.ts |
Invalidates continuity on session archive. |
src/vs/platform/agentHost/node/chatContributions/chatArchive/chatArchiveContribution.ts |
Invalidates continuity on chat archive. |
src/vs/platform/agentHost/node/agentSessionResidency.ts |
Latches vetoes during asynchronous release. |
src/vs/platform/agentHost/node/agentService.ts |
Connects canvas watches, credentials, and release reasons. |
src/vs/platform/agentHost/common/agent.ts |
Defines provider contracts for release options and canvas continuity. |
Review effort: Balanced
Joaquín Ruales (jruales)
force-pushed
the
jruales-canvas-idle-restoration
branch
from
November 3, 2026 08:58
a3ed0f5 to
740e41a
Compare
Joaquín Ruales (jruales)
force-pushed
the
jruales-canvas-idle-restoration
branch
from
November 3, 2026 18:08
740e41a to
bb08f54
Compare
Contributor
|
Base:
|
Ulugbek Abdullaev (ulugbekna)
added a commit
that referenced
this pull request
Nov 3, 2026
Builds on the idle-release canvas continuity in #345740 so a chat's canvases also come back after the Agent Host process restarts (for example, after an update), without a model turn. - A live Copilot runtime reports its source-less canvas continuity (projections plus closes it still owes the runtime) whenever it publishes canvas state or membership; teardown and handoffs never report. - The agent persists it as `copilot.canvasContinuity` in the chat's storage, keyed to the chat and its SDK backing, sequenced per chat and bound to the continuity generation so archive and delete cannot be overwritten. - Observing or resuming a cold chat loads a matching record into the existing released continuity, so the canvases are republished on their original channels and reconciled with the runtime. Observing an archived chat discards it instead. Shutdown keeps the record. - A reopened instance no longer carries its earlier applied close into the next handoff, which dropped the canvas on the next restore. Co-authored-by: Copilot <[email protected]>
Joaquín Ruales (jruales)
force-pushed
the
jruales-canvas-idle-restoration
branch
from
November 4, 2026 06:54
bb08f54 to
b7071d6
Compare
Residency now latches a release veto: once the session stops being eligible during a release, it stays vetoed for the rest of that release instead of becoming eligible again before eviction. Providers receive the live `canContinue` check and a lazily computed release reason (`idle`, `archived`, or `other`), so they can stop releasing chats once the session becomes ineligible and later keep state only across idle releases. Co-authored-by: Copilot <[email protected]>
A canvas handoff can now carry close intent recorded while no runtime projected the canvas. A replacement session applies those closes when it reconciles the handoff with the canvases its runtime restored, keeps the closed instances unprojected, and retries closes that fail after it adopts the handoff, so a failing provider close never fails the resume. A fixed-ID reopen supersedes an earlier close, including one still being flushed, and late closed events cannot remove a reopened canvas. A replacement can also discard a handoff that is no longer current, and hosts can republish its projected canvas states before membership once the chat is registered. Co-authored-by: ulugbekna <[email protected]> Co-authored-by: Copilot <[email protected]>
An idle residency release used to tear down a chat's canvas providers and publish empty canvas membership; returning to the chat restored only its transcript until a new turn resumed the runtime. The Copilot provider now keeps a bounded, source-less canvas handoff for each idly released chat for the Agent Host process lifetime. Once a client observes the chat and contributes to it again, the provider resumes the runtime without a model turn, from that client's current customizations: a plugin disabled or removed while the chat was released is not relaunched. The runtime rehydrates its durable canvas instances and input, and VS Code republishes their fresh sources on the original canvas channels instead of reopening them. Closing a released canvas removes it from membership immediately and is applied when the runtime next resumes. Continuity is invalidated on chat deletion, backing replacement, owner change, a terminal restore failure, and eviction from the bounded cache, which never evicts the continuity it just retained. Co-authored-by: ulugbekna <[email protected]> Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna)
force-pushed
the
jruales-canvas-idle-restoration
branch
from
November 4, 2026 11:57
1150712 to
e730e14
Compare
Joaquín Ruales (jruales)
marked this pull request as ready for review
November 5, 2026 06:21
Archiving a chat or session clears the owning provider's retained idle canvas continuity, so an archived chat never restores its canvases. This covers chat and session archive actions, saved continuations, sessions and peer chats that are not loaded, and archive changes imported from older builds, and clears cross-provider peer chats through their own provider. Co-authored-by: Copilot <[email protected]>
Joaquín Ruales (jruales)
force-pushed
the
jruales-canvas-idle-restoration
branch
from
November 5, 2026 06:36
e730e14 to
10d912e
Compare
Joaquín Ruales (jruales)
marked this pull request as draft
November 5, 2026 06:56
Co-authored-by: Copilot App <[email protected]>
Joaquín Ruales (jruales)
marked this pull request as ready for review
November 5, 2026 08:05
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 5, 2026
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.

Fixes microsoft/vscode-internalbacklog#10570
Summary
When Agent Host residency released an inactive Copilot chat,
session.detachintentionally tore down the runtime's canvas and extension services, and VS Code published empty canvas membership. Returning to the chat restored its transcript but not its canvases; sending a new message happened to resume the runtime and made canvases return on new channels.This change keeps a bounded, source-less canvas handoff across an idle release for the Agent Host process lifetime. When a client observes the chat and contributes to it again, the Copilot provider resumes the runtime without a model turn, from that client's current customizations. The runtime rehydrates its own durable canvas instances and input, and VS Code republishes their fresh sources on the original canvas channels. VS Code does not replay the input or issue a second
canvas.open.Restoration waits for the client's contribution instead of retaining plugin roots or a custom-agent definition. A plugin disabled or removed while the chat was released is therefore not relaunched, standalone customization directories never reach SDK plugin directories, and repeated release/restore cycles behave like the first.
It also:
Process-restart restoration remains separate in #345872. The Agent Host sessions specification documents idle-release continuity separately from configuration refreshes and ordinary cold starts.
Commits
The history is organized for review, and each commit builds and passes the affected suites on its own:
agentHost: tell providers why and whether a chat release may continue: residency release veto latch and release reason.agentHost: carry deferred canvas closes across Copilot runtime handoffs: session-level handoff mechanics for deferred closes, discard, and republishing.agentHost: restore Copilot canvases after an idle residency release: provider continuity, client-driven restore, the host canvas watch, and the specification.agentHost: clear canvas continuity when chats or sessions are archived: archive invalidation.Validation
fnm exec --using=24.22.1 pnpm run typecheck-clientfnm exec --using=24.22.1 pnpm run build-fast --client-onlyfnm exec --using=24.22.1 ./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/agentSessionResidency.test.ts --run src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts --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/node/agentService.test.ts --run src/vs/platform/agentHost/test/node/chatContributions.test.tsfnm exec --using=24.22.1 pnpm run eslint <changed TypeScript files>git diff --checkAn earlier revision of this branch was verified live in an isolated authenticated Agents window with
VSCODE_AGENT_HOST_SESSION_RESIDENCY_LIMIT=1and a minimal canvas-only SDK plugin. Onmain, returning to an idly evicted chat restored its transcript without its canvas pill or tab. On the branch, returning without sending a message restored the existing pill, tab, and content on a fresh source. Grove's agent was discovered, but its extension encountered an unrelatedextension-permission-accesshandshake failure, so the minimal plugin was used to isolate the lifecycle under test.Not run: full integration or smoke suites,
pnpm run valid-layers-checkfor this revision, and a live re-verification of this revision, which now starts restoration once the observing client contributes (including two consecutive release/restore cycles and a plugin disabled while the chat is released).🤖 Written by GitHub Copilot on behalf of Joaquín Ruales (@jruales) and Ulugbek Abdullaev (@ulugbekna).