Skip to content

sessions: add a Canvases section that starts a session with a canvas - #349654

Merged
Ulugbek Abdullaev (ulugbekna) merged 6 commits into
mainfrom
ulugbekna/canvas-first-sessions-v2
Nov 22, 2026
Merged

Ulugbek Abdullaev (ulugbekna) merged 6 commits into
mainfrom
ulugbekna/canvas-first-sessions-v2

Conversation

@ulugbekna

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

Copy link
Copy Markdown
Contributor

Why

In the Agents window, a canvas can only be opened from a chat that has already been started, so trying one means sending a message first. This lets a user start a session from a canvas instead, from a Canvases section in the sidebar.

What changed

  • agentHost: a workspace-less draft chat can list its canvases without starting. The runtime launches early, the way a draft is pre-warmed, and nothing is persisted or announced. Opening a canvas in the draft starts it the way a first send would, reusing that runtime. Listing waits briefly for extensions to settle, then lists what registered, so an extension stuck starting can't hide the others.
  • sessions: ISessionsProvider.createCanvasDraft / ISessionsManagementService.createCanvasDraft return an unlisted quick chat that lists canvases and opens one, starting the session under the canvas name. The Agent Host provider shares the session-starting code that a first send already runs. Disposing the draft, or a canvas failing to open, leaves nothing behind.
  • sessions: ISessionCanvasCatalogService remembers the last listed canvas types per profile, so the picker fills in immediately.
  • sidebar: with the new experimental sessions.list.canvasesSection setting (off by default), pinned canvases move under a Canvases header right after Automations, indented one level. With a separate navigation list, the header and its pins are rows of that list; otherwise it is a collapsible section of the sessions tree. Its New Canvas... action, on the header's toolbar and context menu, picks a canvas, starts a session with it without a message, pins it and shows it full-page. With the setting off, the sidebar is unchanged.

Canvases section with two pinned canvases

Recording: New Canvas → Kusto, New Canvas → Session timeline, switch between pins

Scope

Workspace-less (quick chat) sessions on the local Agent Host only. A draft with a workspace still waits for its first send, which creates its worktree. Only canvases from user or plugin extensions that open without input are offered.

Tradeoffs

  • The picker lists canvases from a hidden draft rather than a new session-independent host call, which would need a protocol change.
  • The section is behind a setting because it changes the sidebar for everyone who has canvases enabled.

Verification

  • ./scripts/test.sh --run sessions list, canvas catalog, sessions management, session navigation, local Agent Host provider and pinned canvas suites: 1847 passing.
  • ./scripts/test.sh --run copilotAgent.test.ts --run agentService.test.ts --grep "canvas|GC-disposed|warm": 102 passing, including new tests for listing in a draft, waiting for a late extension, a stuck extension, and consent requested while a draft lists canvases.
  • ./scripts/test.sh --run sessionsManagementService.test.ts --grep "canvas draft": 2 passing, including disposal while a draft's canvas is unpublished.
  • pnpm run typecheck-client, pnpm run oxlint on the changed files and pnpm run valid-layers-check: clean.
  • Manually in a Code OSS Agents window on a fresh profile: with the setting off the sidebar matches main. With it on, New Canvas... lists canvases without any chat, cancelling discards the draft, and picking Kusto then Session timeline starts two sessions without a message, pins both and switches between them. After review fixes, right-clicking the Canvases header offers New Canvas..., which opens a Session timeline canvas in a new session. With sessions.sidebar.separateNavigation on, Canvases sits under Automations in the navigation list, choosing it opens the picker, and the new pin shows indented under it.

A workspace-less draft chat can now list the canvases it can open
without being started: the host launches its runtime early, as it
pre-warms a chat, and lists from it without persisting or announcing
anything. Opening a canvas in the draft materializes it the way its
first send does, claiming that runtime, so a canvas can be the first
content of a session. A draft with a workspace still waits for its
first send, which creates its worktree.

A materialized session is no longer an unused draft, so empty-session
GC never deletes a canvas session that has no turn yet.

Co-authored-by: Copilot <[email protected]>
`ISessionsProvider.createCanvasDraft` creates an unlisted quick chat of a
session type that runs canvases. The draft lists the canvases it can
open without being started; opening one starts it on the host and lists
the session under the canvas name, sharing the graduation a first send
runs. Disposing the draft before a canvas opens, or a canvas that does
not open, deletes it.

`ISessionsManagementService.createCanvasDraft` routes to the first
provider that supports it, leaves the composer draft alone, and its
`open` resolves to the canvas once its chat publishes it.

Co-authored-by: Copilot <[email protected]>
`ISessionCanvasCatalogService` keeps, per profile, the canvas types a
canvas draft last listed that can start a session (user and plugin
extensions that open without input), so New Canvas can offer them at
once while a new draft lists the installed ones again.

Co-authored-by: Copilot <[email protected]>
… with a canvas

With the new experimental `sessions.list.canvasesSection` setting, off
by default, pinned canvases sit under a Canvases section in the
sessions tree, in both sidebar layouts, which shows a placeholder while
nothing is pinned and hides while chat or canvases are disabled. Its
New Canvas... action lists the installed canvases through a canvas
draft, so no chat is needed first, showing the remembered ones
meanwhile, along with ways to create or browse canvases. Picking one
starts the draft as a session whose first content is that canvas,
without sending a message, then pins the canvas and shows it full-page.
When the canvas cannot be pinned, its session opens instead.
Cancelling discards the draft. With the setting off, pinned canvases
are listed as before.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 10:23

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

Pending-consent flows can reject valid approvals and leave drafts unmaterialized, while disposal races can retain observations and return canvas references through disposed services.

3 open issues
What changed in this PR

This PR adds canvas-first sessions to the Agents window, letting users open a canvas without sending a message first. The sidebar experience is experimental and disabled by default.

Changes:

  • Allow workspace-less Agent Host drafts to discover canvases and become persistent sessions when a canvas opens.
  • Add a cached canvas catalog and a New Canvas picker that starts, pins, and displays the selected canvas.
  • Introduce the optional Canvases sidebar section, with supporting lifecycle tests and documentation.
File Description
src/​vs/​workbench/​contrib/​sessions/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Creates canvas drafts and shares session graduation logic.
src/​vs/​workbench/​contrib/​sessions/​common/​sessionsProvider.ts Defines the provider canvas-draft contract.
src/​vs/​workbench/​contrib/​sessions/​common/​sessionsManagement.ts Defines managed canvas drafts and reference ownership.
src/​vs/​workbench/​contrib/​sessions/​browser/​views/​sessionsListActions.ts Excludes Canvases from section archive actions.
src/​vs/​workbench/​contrib/​sessions/​browser/​views/​sessionsList.ts Adds the Canvases section and nested pinned rows.
src/​vs/​workbench/​contrib/​sessions/​browser/​sessionsManagementService.ts Routes draft creation and waits for canvas publication.
src/​vs/​workbench/​contrib/​sessions/​browser/​sessionsConfiguration.ts Registers the default-off experimental setting.
src/​vs/​sessions/​SESSIONS.md Documents canvas-first session lifecycle and ownership.
src/​vs/​sessions/​SESSIONS_LIST.md Documents sidebar placement and catalog behavior.
src/​vs/​sessions/​services/​sessions/​test/​browser/​sessionsManagementService.test.ts Tests draft publication and observation ownership.
src/​vs/​sessions/​services/​sessions/​test/​browser/​sessionNavigation.test.ts Updates the management-service mock.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsList.test.ts Tests section visibility, placement, and pinned rows.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Tests canvas draft creation, opening, and cleanup.
src/​vs/​sessions/​contrib/​canvases/​test/​browser/​sessionCanvasCatalogService.test.ts Tests catalog filtering and persistence.
src/​vs/​sessions/​contrib/​canvases/​electron-browser/​sessionCanvases.contribution.ts Registers the catalog service and new action.
src/​vs/​sessions/​contrib/​canvases/​electron-browser/​sessionCanvasActions.ts Exports discovery entries for picker reuse.
src/​vs/​sessions/​contrib/​canvases/​electron-browser/​newCanvasSessionAction.ts Adds the picker and start, pin, and display flow.
src/​vs/​sessions/​contrib/​canvases/​common/​sessionCanvas.ts Defines catalog APIs and canvas eligibility.
src/​vs/​sessions/​contrib/​canvases/​browser/​sessionCanvasCatalogService.ts Persists eligible canvas types per profile.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Tests draft listing, runtime reuse, and restart behavior.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Tests protection from unused-draft collection.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Adds bounded waiting for extension registration.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Enables canvas discovery and opening in workspace-less drafts.
src/​vs/​platform/​agentHost/​node/​agentService.ts Marks materialized sessions as used before their first turn.
src/​vs/​platform/​agentHost/​node/​agentHostStateManager.ts Exposes the session-used marker for materialization.

Review effort: Balanced

- A draft whose canvas extension asked for consent while it listed canvases now starts before it asks, so the user's answer reaches an initialized chat and the session is announced.
- Waiting for a draft's canvas to publish stops, and releases its observation, when the sessions management service is disposed.
- New Canvas is also offered from the Canvases section's context menu, like other section creation actions.

Co-authored-by: Copilot <[email protected]>
@ulugbekna
Ulugbek Abdullaev (ulugbekna) added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 03cc76c Nov 22, 2026
38 checks passed
@ulugbekna
Ulugbek Abdullaev (ulugbekna) deleted the ulugbekna/canvas-first-sessions-v2 branch November 22, 2026 18:35
Wing K.Y (wingwkyuen) pushed a commit to tcgoidc/vscode that referenced this pull request Nov 24, 2026
…icrosoft#349986)

* fix(sessions): reconnect pinned canvases of a canvas-first session after 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 microsoft#349746, a follow-up to microsoft#349654.

Co-authored-by: Copilot <[email protected]>

* fix(agentHost): retry a restored canvas open on each registry change 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 <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 24, 2026
…fter a reload (cherry-pick #349986) (#350071)

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

* fix(sessions): reconnect pinned canvases of a canvas-first session after 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.



* fix(agentHost): retry a restored canvas open on each registry change 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.



---------


(cherry picked from commit 25e7ea7)

Co-authored-by: Copilot <[email protected]>
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.

3 participants