Repository navigation
Canvases: keep Copilot sessions resident while canvases are open - #345767
Draft
Joaquín Ruales (jruales) wants to merge 1 commit into
Draft
Joaquín Ruales (jruales) wants to merge 1 commit into
Joaquín Ruales (jruales) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical asynchronous preflight races can allow session eviction to destroy open canvases because canvas and archive state are not revalidated after awaited checks.
2 open issues
What changed in this PR
This PR keeps Copilot chats resident while they project open canvases, preventing idle eviction from stopping the backing runtime and extension processes. It preserves live canvases rather than adding restoration after teardown.
Changes:
- Threads idle-versus-archived release reasons through residency checks and provider preflight.
- Vetoes idle release for chats with projected canvases while preserving archival cleanup.
- Adds focused tests and documents the canvas residency policy.
| File | Description |
|---|---|
src/vs/sessions/contrib/providers/agentHost/AGENT_HOST_SESSIONS_PROVIDER.md |
Documents canvas residency and archival exceptions. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests projected-canvas membership tracking. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Tests canvas release vetoes and archival exceptions. |
src/vs/platform/agentHost/test/node/agentSessionResidency.test.ts |
Tests idle and archived release reasons. |
src/vs/platform/agentHost/test/node/agentService.test.ts |
Tests archived peer-chat reason selection. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Exposes whether a chat projects canvases. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Adds the canvas-based idle release veto. |
src/vs/platform/agentHost/node/agentSessionResidency.ts |
Determines and forwards release reasons. |
src/vs/platform/agentHost/node/agentService.ts |
Passes release reasons with per-chat archival overrides. |
src/vs/platform/agentHost/common/agent.ts |
Extends the provider preflight contract with release reasons. |
Review effort: Balanced
Comment on lines
+398
to
+402
| const reason = this._releaseReason(sessionKey, expectedRecency); | ||
| if (!reason) { | ||
| return false; | ||
| } | ||
| if (!await release.canRelease(chats, reason)) { |
Comment on lines
+8522
to
+8525
| if (reason === 'idle' && target.hasProjectedCanvases) { | ||
| this._logService.info(`[Copilot:${target.sessionId}] Deferring idle release while a canvas is open`); | ||
| return false; | ||
| } |
Treat projected canvases as active work for idle residency release while allowing archived sessions and chats to release normally. Co-authored-by: Copilot App <[email protected]>
Joaquín Ruales (jruales)
force-pushed
the
jruales/canvas-residency-hold
branch
from
November 3, 2026 18:07
e969509 to
7e403ab
Compare
Contributor
This branch has not been deployed
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.

Relates to microsoft/vscode-internalbacklog#10570
Alternative to #345740.
Summary
When the Agent Host residency budget releases an inactive Copilot chat, it also stops the extension process backing any open canvases. Returning restores the transcript but not the live canvas provider; a new turn happens to resume it.
This alternative follows the simpler policy used by the Copilot App in
github/github-app#8574: treat a projected runtime canvas as active work. A Copilot chat with at least one projected canvas vetoes idle-pressure residency release, preserving the SDK session, extension process, live source URL, browser page state, and chat context. Archived sessions and archived peer chats still release normally.The release reason is threaded through provider preflight so the canvas hold applies only to idle MRU pressure, not archival cleanup. Once the final runtime canvas closes, the existing release retry makes the session eligible again.
Tradeoffs
microsoft/vscode-internalbacklog#10005.Validation
fnm 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.tsfnm exec --using=24.22.1 ./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --grep 'release preflight keeps idle chats with projected canvases resident|releaseChat releases only'fnm exec --using=24.22.1 ./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --grep 'reports projected canvases for idle residency release'fnm exec --using=24.22.1 ./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/agentService.test.ts --grep 'release preflight distinguishes archived peer chats|provider can defer idle release|idle eviction releases every catalog chat|archived Agent-Merge session is released'fnm exec --using=24.22.1 pnpm run typecheck-clientfnm exec --using=24.22.1 pnpm run eslint -- <9 changed TypeScript files>fnm exec --using=24.22.1 pnpm run valid-layers-checkgit diff origin/main...HEAD --checkNot run: full integration or smoke suites.
🤖 Written by GitHub Copilot on behalf of Joaquín Ruales (@jruales).