Skip to content

Canvases: keep Copilot sessions resident while canvases are open - #345767

Draft
Joaquín Ruales (jruales) wants to merge 1 commit into
mainfrom
jruales/canvas-residency-hold
Draft

Joaquín Ruales (jruales) wants to merge 1 commit into
mainfrom
jruales/canvas-residency-hold

Conversation

@jruales

Copy link
Copy Markdown
Contributor

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

  • The residency limit remains a soft cap: sessions with open runtime canvases may overflow the default limit of 10.
  • The hold follows provider canvas membership, not editor visibility. Under the current VS Code canvas semantics, dismissing only the editor tab can leave the provider instance open and therefore resident; the separate close-lifetime question is tracked by microsoft/vscode-internalbacklog#10005.
  • This does not restore canvases after an Agent Host process restart. It avoids the idle teardown rather than adding durable restoration.

Validation

Command Result
fnm exec --using=24.22.1 pnpm run build-fast --client-only Passed
fnm exec --using=24.22.1 ./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/agentSessionResidency.test.ts Passed — 21 tests
fnm 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' Passed — 2 tests
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' Passed — 1 test
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' Passed — 4 tests
fnm exec --using=24.22.1 pnpm run typecheck-client Passed
fnm exec --using=24.22.1 pnpm run eslint -- <9 changed TypeScript files> Passed
fnm exec --using=24.22.1 pnpm run valid-layers-check Passed
git diff origin/main...HEAD --check Passed

Not run: full integration or smoke suites.

🤖 Written by GitHub Copilot on behalf of Joaquín Ruales (@jruales).

Copilot AI balanced review requested due to automatic review settings November 3, 2026 09:25

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

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]>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 6b68d3fe Current: 95f0bed6

Changed (2)

sessions/inbox/inboxNotificationsView/Evidence/Light
Before After
before after
sessions/inbox/inboxNotificationsView/EvidenceNarrow/Light
Before After
before after

This branch has not been deployed

No deployments
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.

2 participants