Repository navigation
Description
Does this issue occur when all extensions are disabled?: N/A (Agent Host core code path)
- VS Code Version: Code - Insiders 1.142.0-insider (f4dfb91). The code path is unchanged on
mainat 38d9885. - OS Version: macOS 27.0.1 (arm64)
When a message send makes the Agent Host refresh a Copilot chat's session configuration, every canvas open in that chat closes in the Agents window and doesn't come back.
Steps to Reproduce:
- Enable
chat.canvases.enabledand, in the Agents window, start a new local Copilot session in a new worktree. - Have the agent open a canvas (
open_canvas) in the first turn. It opens as a tab in the side pane. - Send a follow-up message in the same chat.
Expected: The canvas stays open. At most it's briefly unavailable while its provider reconnects, as with an extension reload.
Actual: The canvas tab closes and doesn't reopen. The runtime still has the instance open: invoke_canvas_action calls on it keep succeeding, and calling open_canvas again with the same instanceId brings it back, as a new tab.
agenthost.log shows the send restarting the SDK session. The same pattern was observed in two chats:
11:01:11.457Z [Copilot:…] Session configuration changed, refreshing session: operation=sendMessage, …, reason=clientPluginsChanged
11:01:11.459Z [Copilot:…] SDK session disconnect RPC started …
11:01:11.514Z [Copilot:…] Preparing SDK session: kind=resume …
The Agents window's AHP log shows the host publishing an empty canvas list at the same instant:
11:01:11.459Z s2c chat/canvasesChanged (no canvases)
11:01:11.459Z c2s unsubscribe ahp-canvas:/…
Root cause
_refreshSessionConfigurationdestroys the live SDK session and resumes it whenever the chat's configuration snapshot changed.destroySessioncalls_clearCanvasProjection, which publishesChatCanvasesChangedwith no canvases. The Agents window treats this as authoritative membership and closes the canvas editors.- The replacement session's
initializeSessionadds every instance inwrapper.session.openCanvasesto_ignoredRestoredCanvasInstanceIds, and projection starts out not ready, so the runtime's rehydrationsession.canvas.openedevents are dropped. Nothing re-projects the canvas, even though the runtime still has it open.
This follows the documented contract ("A new SDK residency starts with an empty projected canvas collection and does not restore prior open canvases"), but a configuration refresh of a chat that's in use is currently treated as a new residency.
Why the refresh happens in this flow
- The synced customization bundles are identified by
createScopeAuthority, which is${sessionType}-${hash(scope roots)}. The host materializes each bundle under a path derived from its URI. - A new worktree session starts with the repository folder as its customization scope. Once the worktree is known, the scope is re-acquired for the worktree folder.
- So the bundle's
id/uriand directory change even though its contentnoncedoesn't. parsedPluginsEqualthen reports a difference, and the next send restarts withclientPluginsChanged.- These logs predate Agent Host: stop delivering standalone customizations as plugin content #340079. After it, both the synced and the standalone bundle identity still include the scope hash.
Proposed fix
Hand the canvas projection over across a configuration refresh instead of clearing it:
- Before destroying the live session for a refresh, capture its projected canvases, and don't publish an empty collection.
- Keep each canvas resource stable per
instanceId, so the Agents window keeps the same tab. Publish the carried state without aurl(shown as temporarily unavailable) until the provider reconnects. - Resume with
ResumeSessionConfig.openCanvases, and don't ignore carried instances in the replacement session.- Let
session.canvas.openedpublish the new URL. - Reconcile with
openCanvases/rpc.canvas.list()once projection is ready, because rehydration can happen before that.
- Let
- Drop carried canvases the runtime didn't restore. Publish an empty collection only if the resume fails.
- Cold residencies (eviction, host restart) keep starting empty. Update the contract in
AGENT_HOST_SESSIONS_PROVIDER.mdaccordingly. - Tests: a refresh keeps the canvas resource, never publishes an empty collection, and publishes the new URL without waiting for a user message.
Caveat: even with the hand-off, the refresh restarts the canvas extension process; the canvas URL changes. The canvas therefore reloads and loses any in-memory state. Avoiding that means avoiding the restart:
- Don't restart when the bundle content is unchanged. Either make the bundle identity independent of the scope roots, or materialize bundles by content. This alone fixes the flow above.
- Longer term, apply client customization changes to the live session, e.g. with
session.plugins.reload({ reloadExtensions: false })orsession.options.update, instead of restarting. This still needs validation against the runtime.
Related
- Canvases also close when switching sessions (editor working-set swap in the Agents window). That's a separate renderer bug, being fixed separately.
- Residency eviction of an inactive session also drops its canvases. That's separate and not covered here.
- Agent Host loses conversation context when config refresh resume falls back to createSession #336587 and Agents window stalls after Copilot runtime panic during MCP/plugin refresh #337470 also concern configuration refresh/restart, but not canvases.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
agentHost: keep open canvases across session configuration refreshes (#…
federicobrancasi commentedon Oct 18, 2026
🤖 How to verify: the video for this fix is in this comment, with related fixes. It walks through the steps in real VS Code Insiders, checking each result in the app.
anthonykim1 commentedon Oct 19, 2026
Verified on macOS 26.7.1 arm64 using VS Code Insiders 1.143.0-insider (
a0c6520313624aceb3f3a80eff7932be6a00405a) with its bundled@github/copilot-sdk1.0.23-preview.5.In the Agents window, I had a local Copilot session create a small project canvas (TPI Counter) and open it in the first turn. Before each follow-up I added a new workspace instructions file, so the send refreshed the session configuration with
reason=clientPluginsChanged, the same reason as in the logs above. I polled the canvas tab about every 100 ms during each turn and checked the Agents window's AHP log.Verified:
Session configuration changed, refreshing session: operation=sendMessage … reason=clientPluginsChanged, thenSDK session disconnect RPC started,Preparing SDK session: kind=resumeandSDK resumeSession settled: outcome=successResults:
chat/canvasesChangedor unsubscribe the canvas. It sentcanvas/stateChangedfor the same instance without a URL right after the refresh, and with a URL once the resume finished (about 0.7 seconds)Open canvases no longer close when a send refreshes the session configuration in current Insiders.