Skip to content

Reconnect pinned canvases of a canvas-first session after a reload - #349986

Open
Ulugbek Abdullaev (ulugbekna) wants to merge 2 commits into
mainfrom
ulugbekna/canvas-first-restore
Open

Ulugbek Abdullaev (ulugbekna) wants to merge 2 commits into
mainfrom
ulugbekna/canvas-first-restore

Conversation

@ulugbekna

Copy link
Copy Markdown
Contributor

Follow-up to #349654, found while verifying the test plan item #349746.

Problem

A session started from the Canvases section has no turn. Its Copilot runtime persists no history before a turn, so the chat stays a draft on the Agent Host, also after a restart. Once that runtime is released (Developer: Reload Window, or turning chat.canvases.enabled off and on), its pinned canvas stayed Not connected, and selecting it showed "The canvas provider is temporarily unavailable." or "This canvas is no longer available.". Two gates stopped it from coming back:

  1. The host restores a chat's released canvases only for a client that contributes to the chat, and only the focused session publishes one. Showing a pin never did, so a pinned canvas of a session that is not focused never came back, with or without a message sent.
  2. Restoring the canvases of a draft was rejected (Canvas operation requires an initialized Copilot chat.), and the launch that started a draft did not take over its released canvases.

Change

Workbench:

  • BaseAgentHostSessionsProvider.observeChatCanvases, used only by a reconnecting pin, now also contributes this client to the session while held, as showing the session would. A new contribution always publishes, since the host drops contributions to a session it releases without telling the client.
  • PinnedCanvasService: a shown pin keeps observing its chat until its canvas has a source, so the chat can restore it. It also observes its canvas again when an earlier observation failed while the session was released.

Agent Host (Copilot):

  • A workspace-less draft may restore and close its canvases.
  • _materializeProvisional claims the chat's released canvas continuity, so the launch takes over its canvases, as a resume does. An early launch made without them is discarded (canvasContinuity).
  • CopilotAgentSession waits, bounded, for a just-launched runtime to register a canvas before reopening it, instead of failing with Canvas "…" is not registered.. It also no longer reopens a canvas that was closed while its runtime was released.

SESSIONS.md describes the new reconnect and restore behaviour.

Before: reload, then select the pin After: reload, then select the pin
before after

Takeoff canvas after chat.canvases.enabled off and on, then selecting its pin:

takeoff

How to test

With "sessions.list.canvasesSection": true in the Agents window:

  1. Hover Canvases, select +, and pick Takeoff or Session timeline. Send no message.
  2. Run Developer: Reload Window. The pin shows Not connected.
  3. Select the pin: it becomes Live and the canvas renders, without opening its chat.
  4. Set chat.canvases.enabled to false, wait about 15 seconds, set it back to true, then select the pin: it becomes Live again.
  5. Use Go to Chat and send a message. Reload and select the pin again: it reconnects (the chat now resumes).

Validation

  • Running Agents window (Code OSS from this branch): steps 1-5 with Session timeline, and steps 1-4 with Takeoff. Every pin came back Live; before the change, each stayed Not connected.
  • ./scripts/test.sh --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/copilotAgentSession.test.ts --run src/vs/sessions/contrib/canvases/test/browser/pinnedCanvasService.test.ts --run src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts --run src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts --run src/vs/sessions/contrib/canvases/test/browser/canvasActivityBar.test.ts: passed, 5099 tests. Each new or changed test fails without its fix.
  • pnpm run typecheck-client: passed.
  • pnpm run oxlint on the changed TypeScript files: passed.

…ter a reload

A session started from the Canvases section has no turn, so its Copilot runtime
persists no history and the chat stays a draft on the host, also after a
restart. Once its runtime was released (a window reload, or turning canvases
off and on), its pinned canvas stayed "Not connected":

- The host restores released canvases only for a contributing client, and only
  the focused session gets one; showing a pin never contributed.
- Restoring the canvases of a draft was rejected, and a draft's next launch did
  not take over its released canvases.

A reconnecting pin now contributes this client to its session and keeps
observing its chat until the canvas has a source, observing the canvas again
when an earlier observation failed while the session was released. The host
lets a workspace-less draft restore and close its canvases, and the launch that
materializes a draft takes over the canvases its released runtime had open.
Reopening a handed-over canvas waits for a just-launched runtime to register it,
and a canvas closed while released is no longer reopened.

Found while verifying #349746, a follow-up to #349654.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 21:29
@ulugbekna Ulugbek Abdullaev (ulugbekna) added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Nov 23, 2026

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

An unrelated registry change can exhaust the only retry and leave the canvas pin disconnected, and regression coverage does not exercise restoring a canvas-first draft without sending a message.

2 open issues
What changed in this PR

This follow-up restores pinned canvases after reload or runtime release, including canvas-first sessions that have not sent a message.

Changes:

  • Reconnecting pins contribute the client to their session and retain chat observation until a canvas source is available.
  • Workspace-less drafts reclaim released canvases, preserve closes, and retry reopening while extensions initialize.
  • Adds regression coverage and documents the reconnect lifecycle.
File Description
src/​vs/​workbench/​contrib/​sessions/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Publishes client contributions when observing a reconnecting pin’s chat.
src/​vs/​workbench/​contrib/​sessions/​common/​sessionsProvider.ts Documents the observation hook’s contribution behavior.
src/​vs/​sessions/​SESSIONS.md Explains pin reconnection and canvas-first draft restoration.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Tests repeated client contributions during observation.
src/​vs/​sessions/​contrib/​canvases/​test/​browser/​pinnedCanvasService.test.ts Tests retaining chat observation until a source appears.
src/​vs/​sessions/​contrib/​canvases/​browser/​pinnedCanvasService.ts Retains reconnect observation and retries failed canvas observations.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Tests draft canvas continuity and deferred closes across runtime release.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Adds registration-aware reopen retries and preserves settled closes.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Enables draft restore/close operations and transfers released canvas continuity.

Review effort: Balanced

…until one deadline

Another extension's registry change could consume the only retry while the
restored canvas was still unregistered. Each attempt now waits on a fresh
listener, and unavailable opens retry until a shared deadline.

Also cover restoring a released canvas-first draft without a send: a window
that observes and contributes to the chat brings its canvas back with a source
while no runtime receives a send.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants