Repository navigation
agentHost: keep open canvases across session configuration refreshes - #341518
Ulugbek Abdullaev (ulugbekna) merged 3 commits into
Conversation
A send that refreshes a chat's session configuration destroys its SDK session and resumes a replacement. Destroying the session cleared its canvas projection and published an empty canvas list, so the Agents window closed every open canvas, and the replacement then ignored the canvases the runtime restored. The refresh now hands the projected canvases to the replacement. They keep their resources, so their tabs stay open, and they show as temporarily unavailable until the new runtime serves them again. The replacement reconciles them with the canvases the runtime reports open. Membership changes stay unpublished until the refresh adopts the replacement that survives restore retries; if the refresh fails, the canvases close as before. Fixes #340508 Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Failed listOpen reconciliation can leave stale unavailable canvas membership indefinitely.
1 open finding
What changed in this PR
Preserves canvas tabs while Agent Host refreshes a Copilot session’s configuration.
Changes:
- Transfers canvas projections between SDK sessions.
- Reconciles restored canvases and preserves stable resources.
- Adds unit, integration, and contract coverage.
| File | Description |
|---|---|
AGENT_HOST_SESSIONS_PROVIDER.md |
Documents refresh handoff behavior. |
copilotSdkCanvas.integrationTest.ts |
Tests runtime canvas restoration. |
copilotAgentSession.test.ts |
Covers handoff lifecycle and reconciliation. |
copilotAgent.test.ts |
Covers refresh orchestration and failure paths. |
copilotAgentSession.ts |
Implements projection transfer and reconciliation. |
copilotAgent.ts |
Coordinates handoff across session refreshes. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
If the replacement runtime could not report its open canvases, the refresh still adopted every handed-over canvas, so canvases the runtime had not restored stayed open as unavailable tabs. A timed-out request also left the session marked for resync while the send used it. Let the failure fail initialization instead, as a failed canvas registry listing already does. The refresh then discards the session and closes the handed-over canvases. Co-authored-by: Copilot <[email protected]>
|
Base:
|
…cile" This reverts commit e2c03bf. Failing the replacement session turned a failed or slow open-canvas listing into a failed send, and closed every canvas, including the ones the runtime had restored. A canvas the runtime did not restore staying as an unavailable tab until a later refresh reconciles it is the smaller problem. Co-authored-by: Copilot <[email protected]>
|
Heads-up Ulugbek Abdullaev (@ulugbekna): the unchanged Both canvas lifecycle tests passed in 40 local repetitions with the same bundled SDK/runtime. No root cause established, and no canvas code or assertions changed. Flagging the intermittent resume-snapshot result rather than weakening the test. No CI rerun was triggered. 🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll). |

Fixes #340508
When a send refreshes a chat's session configuration (for example after its customizations change), the Agent Host destroys the chat's SDK session and resumes a replacement. Destroying the session cleared its canvas projection and published an empty canvas list, so the Agents window closed every open canvas, and the replacement then ignored the canvases the runtime restored.
The refresh now hands the projected canvases to the replacement:
CopilotAgentSession.takeCanvasProjection()releases the old session's canvases and republishes them without a source, so they keep their resources (and their tabs) and show as temporarily unavailable.CopilotAgentholds the handoff per chat while the refresh runs. The replacement is created with it, keeps those canvases instead of ignoring them on resume, accepts the runtime's rehydration events, and reconciles them withrpc.canvas.listOpenonce its extensions settle.starting,live,released) plus a per-canvas hand-over mark, replacing two flags and a parallel set.The canvas contract in
AGENT_HOST_SESSIONS_PROVIDER.mdnow describes the refresh handoff.How to test
chat.canvases.enabled. In the Agents window, start a local Copilot session in a folder..github/instructions/test.instructions.mdto the folder, then send another message.The canvas tab stays open, is briefly unavailable, and then reloads from the new runtime. Before this change, the tab closed.
Validation
./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --grep "canvas|config-driven session refresh": 29 passing../scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts: 1,731 passing, 14 failing locally. The failures are in tests unrelated to canvases and refreshes that depend on machine state, such as existing~/.copilot/session-stateentries or a/home/testhome directory../scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/copilotSdkCanvas.integrationTest.ts: passed, including the new test that keeps an open canvas across a resume on the real Copilot runtime.npm run typecheck-client: passed.npm run eslint -- <changed .ts files>: no problems.main: two consecutive refreshes, with one and then two canvases open. Every tab stayed open and reloaded from the new runtime, and the host published no emptychat/canvasesChanged. A canvas opened after the first refresh got its own tab.