Skip to content

sessions: bring back pinned canvases after a restart - #348343

Merged
Ulugbek Abdullaev (ulugbekna) merged 3 commits into
mainfrom
ulugbekna-fix-pinned-canvas-reopen
Nov 15, 2026
Merged

Ulugbek Abdullaev (ulugbekna) merged 3 commits into
mainfrom
ulugbekna-fix-pinned-canvas-reopen

Conversation

@ulugbekna

@ulugbekna Ulugbek Abdullaev (ulugbekna) commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes pinned canvases in the Agents window that show "This canvas is no longer open in its chat" and never come back when selected, typically after an app restart.

Root cause

A pin persists only its canvas's identity, and reconnects by finding the same instance ID in its chat's canvas list. Two things can keep the chat from listing it again:

  1. A session that launched without canvases. A Copilot session decides at launch whether it runs canvases, and nothing changed that decision later. If a session resumed before the client's configuration enabled canvases (for example while the experiment-provided default of chat.canvases.enabled had not resolved yet at startup), it ran without canvases until something unrelated relaunched it. Opening its canvases failed with "Canvases are disabled for this session."
  2. A canvas the chat no longer has open. After an Agent Host restart, a lazily activated canvas provider stays dormant until something asks for its canvas, so the chat doesn't list it.

In both cases PinnedCanvasService marked the pin unavailable, and selecting it only looked for the canvas again. Nothing asked the chat to open it.

Fix

Commit 1 (sessions): a shown pin reopens its canvas. When a pin is shown and its chat's canvas list lacks its canvas, the pin asks the chat to open that instance again through ISessionsManagementService.openCanvas, then binds once the chat publishes it.

  • Each request is scoped to the session object it was made through. A request through a session that goes away or is replaced is abandoned, its late answer is ignored, and the pin asks again through the returning session.
  • After the chat reports the canvas opened, the pin waits up to 10 seconds for that instance, ignoring unrelated membership changes. The host can answer without publishing it, for example when a close superseded the open.
  • A failed open marks the pin unavailable and reports why. A declined extension consent (from agentHost: ask before a Copilot extension reads sensitive environment variables #348216) shows the standard warning, whose Try Again asks again and shows the pin. Showing the pin again retries.
  • openCanvas now takes only Pick<ISessionCanvasDefinition, 'canvasId' | 'extensionId'>, which is all providers use, so a pin can reopen without the chat's canvas definitions, which may not be listed yet after a resume.

Commit 2 (agentHost): a session with stale canvas enablement relaunches. The runtime refresh compares a session's launch-time canvas enablement with the current configuration.

  • A mismatch is a new refresh reason, canvasesEnabledChanged, so the session relaunches before its next turn. This also applies when canvases are turned off.
  • Opening a canvas relaunches an idle session first. A session with an active turn, or with background subagents that outlive their turn, isn't interrupted: the open reports canvases disabled, and the next turn relaunches it. (The subagent guard is a follow-up commit, from review.)
  • Listing canvases never relaunches a session.
  • isIdleRefreshOperation treats the openCanvas refresh like startMcpServer's: it never sends the chat's draft or takes a turn's cancellation token.
  • The setting description now says running sessions pick up changes.

Recordings

Recorded in Code OSS with a project-scoped demo canvas whose page shows when its provider process started.

Session resumed with canvases off, then canvases turned on, then the pin is selected. Before (commit 1 only): the reopen fails with "Canvases are disabled…".

race-before-host-fix.mp4

After (both commits): the session relaunches and the canvas is back.

race-after-fix.mp4

Lazily activated canvas after a full quit and relaunch. Before (main): the pin goes straight to unavailable.

before-fix.mp4

After: the pin reopens the canvas, and the provider starts at the moment of the click.

after-fix.mp4

Validation

  • pnpm run typecheck-client: passed.
  • pnpm run valid-layers-check: passed.
  • pnpm run oxlint on the changed files, and pnpm run precommit (hygiene) on each commit: passed.
  • ./scripts/test.sh --run src/vs/sessions/contrib/canvases/test/browser/pinnedCanvasService.test.ts --run src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasRegistryService.test.ts --run src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasService.test.ts --run src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts: 656 passing.
  • ./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/agentService.test.ts --run src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts: 4484 passing, 17 pending.
  • New tests:
    • pinnedCanvasService.test.ts covers:
      • a reopen answered before the canvas is published, with unrelated changes in between;
      • no publication in time, then a retry;
      • a session going away and returning;
      • a session replaced before its canvas list loads;
      • a never-loading canvas, with the wait still ending;
      • a failed open with a retry;
      • a declined consent, then Try Again.
    • copilotAgent.test.ts covers the relaunch sequence:
      • an open during a turn, or while background subagents run, reports canvases disabled without relaunching;
      • an open while idle relaunches with canvases;
      • turning canvases off relaunches at the next turn.
    • The tests for the changed behavior were checked to fail without the corresponding change.
  • End-to-end in Code OSS, as recorded above. After rebasing onto main, which brought in the extension-consent changes from agentHost: ask before a Copilot extension reads sensitive environment variables #348216, I re-ran the first scenario on this branch: the pin went from unavailable to live in about 2 seconds, and the host logged a refresh with operation=openCanvas.

Not covered: canvases that require input. A reopen sends no input, which works when the runtime still has the instance, but this hasn't been tried after a restart.

After a restart, a chat can lose a canvas it had open: a lazily activated
canvas provider stays dormant until something asks for its canvas, and a
session that ran without canvases has none. A pin whose chat no longer
listed its canvas showed "This canvas is no longer open in its chat", and
selecting it only looked for the canvas again, so it never came back.

When a shown pin's chat lacks its canvas, the pin now asks the chat to open
that instance again through ISessionsManagementService.openCanvas and binds
once the chat publishes it.

- Each request is scoped to the session object it was made through. A
  request made through a session that goes away or is replaced is
  abandoned, its late answer is ignored, and the pin asks again through the
  returning session.
- After the chat reports the canvas opened, the pin waits a bounded time
  for the chat to publish that instance, ignoring unrelated membership
  changes. The chat can answer without publishing it, for example when a
  close superseded the open.
- If the open fails or the canvas is not published in time, the pin shows
  as unavailable, the user is told why when the open failed, and showing
  the pin again retries.
- When the user declines the consent that the canvas's extension asks
  for, the pin shows as unavailable, and the warning's Try Again asks
  again and shows the pin.

openCanvas now takes only the canvas type identity (canvasId and
extensionId), which is all providers use, so a pin can reopen its canvas
without the chat's registered canvas types, which may not be listed yet
after a resume.

Co-authored-by: Copilot App <[email protected]>
A Copilot session decides whether it runs canvases when it launches. A
session that launched before the client's configuration enabled canvases,
for example while an experiment-controlled setting had not resolved yet at
startup, kept running without canvases until something unrelated relaunched
it. Opening its canvases failed with "Canvases are disabled for this
session.", so a pinned canvas could not be reopened.

The runtime refresh now compares a session's launch-time canvas enablement
with the current configuration:

- A mismatch is a new refresh reason, canvasesEnabledChanged, so the
  session relaunches before its next turn. This also applies when canvases
  are turned off.
- Opening a canvas relaunches an idle session first. A session with an
  active turn is not interrupted; the open reports canvases disabled and
  the next turn relaunches it.
- Listing canvases never relaunches a session.

A refresh for opening a canvas, like one for starting an MCP server, is
outside a turn: it never sends the chat's draft or takes a turn's
cancellation token.
The setting description now says that running sessions pick up changes.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 14, 2026 16:37
@ulugbekna
Ulugbek Abdullaev (ulugbekna) marked this pull request as ready for review November 14, 2026 16:43
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Joaquín Ruales (@jruales)

Matched files:

  • src/vs/sessions/contrib/canvases/browser/pinnedCanvasService.ts
  • src/vs/sessions/contrib/canvases/electron-browser/pinnedCanvasPage.ts
  • src/vs/sessions/contrib/canvases/test/browser/pinnedCanvasService.test.ts
  • src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasRegistryService.test.ts
  • src/vs/sessions/contrib/canvases/test/electron-browser/sessionCanvasService.test.ts

Sandeep Somavarapu (@sandy081)

Matched files:

  • src/vs/workbench/contrib/sessions/browser/sessionsManagementService.ts
  • src/vs/workbench/contrib/sessions/common/sessionsManagement.ts
  • src/vs/workbench/contrib/sessions/common/sessionsProvider.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/workbench/contrib/sessions/browser/sessionsManagementService.ts
  • src/vs/workbench/contrib/sessions/common/sessionsManagement.ts
  • src/vs/workbench/contrib/sessions/common/sessionsProvider.ts

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

The refresh path checks only hasActiveTurn before destroying the runtime, so changing canvas enablement and opening a canvas can stop running background subagents unless hasActiveSubagents is also checked.

1 open issue
What changed in this PR

Restores pinned canvases in the Agents window after restart by reopening missing instances through their owning chats and refreshing runtimes with outdated canvas enablement.

Changes:

  • Adds pin reopening, bounded publication waits, session-replacement handling, and consent retries.
  • Refreshes stale canvas runtimes before turns or idle canvas opens.
  • Narrows canvas-opening APIs to identity fields and updates tests, documentation, and recovery messaging.
File Description
src/​vs/​workbench/​contrib/​sessions/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Accepts canvas identity fields for opening.
src/​vs/​workbench/​contrib/​sessions/​providers/​agentHost/​AGENT_HOST_SESSIONS_PROVIDER.md Documents canvas enablement refreshes.
src/​vs/​workbench/​contrib/​sessions/​common/​sessionsProvider.ts Narrows the provider’s canvas-open contract.
src/​vs/​workbench/​contrib/​sessions/​common/​sessionsManagement.ts Narrows the management canvas-open contract.
src/​vs/​workbench/​contrib/​sessions/​browser/​sessionsManagementService.ts Aligns canvas-open delegation with the contract.
src/​vs/​workbench/​contrib/​sessions/​browser/​pinnedCanvases.ts Documents pin reopening behavior.
src/​vs/​sessions/​SESSIONS.md Documents pin recovery and request lifetimes.
src/​vs/​sessions/​contrib/​canvases/​test/​electron-browser/​sessionCanvasService.test.ts Updates canvas-open test types.
src/​vs/​sessions/​contrib/​canvases/​test/​electron-browser/​sessionCanvasRegistryService.test.ts Updates registry test types.
src/​vs/​sessions/​contrib/​canvases/​test/​browser/​pinnedCanvasService.test.ts Covers recovery, timeouts, replacements, and retries.
src/​vs/​sessions/​contrib/​canvases/​electron-browser/​pinnedCanvasPage.ts Updates unavailable-canvas recovery guidance.
src/​vs/​sessions/​contrib/​canvases/​browser/​pinnedCanvasService.ts Implements reopening and consent retry handling.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Tests enablement changes and runtime relaunches.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotSessionLauncher.ts Shares the canvas runtime enablement predicate.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotRuntimeRestartTelemetry.ts Adds the canvas enablement refresh reason.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Exposes launch-time canvas enablement.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Refreshes stale runtimes and handles idle operations.
src/​vs/​platform/​agentHost/​common/​agentHostStarter.config.contribution.ts Clarifies when running sessions apply setting changes.

Review effort: Balanced

…nvas

Opening a canvas relaunched an idle runtime whose canvas enablement was
stale, but the refresh only treated an active turn as busy. Background
subagents can outlive their turn and would stop with the runtime, so
such a runtime now keeps running: the open reports canvases disabled, and
the session relaunches at its next turn, as it does during a turn.

Co-authored-by: Copilot App <[email protected]>
@ulugbekna
Ulugbek Abdullaev (ulugbekna) added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit d03edc4 Nov 15, 2026
37 of 38 checks passed
@ulugbekna
Ulugbek Abdullaev (ulugbekna) deleted the ulugbekna-fix-pinned-canvas-reopen branch November 15, 2026 11:35
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 15, 2026
@ulugbekna Ulugbek Abdullaev (ulugbekna) added the canvases Issues related to Copilot canvases label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

canvases Issues related to Copilot canvases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants