Skip to content

Agents: move workspace-less sessions and chats in Move Chats (Block 9) - #343022

Merged
Sandeep Somavarapu (sandy081) merged 62 commits into
mainfrom
agents/move-chats-workspaceless
Oct 21, 2026
Merged

Sandeep Somavarapu (sandy081) merged 62 commits into
mainfrom
agents/move-chats-workspaceless

Conversation

@sandy081

@sandy081 Sandeep Somavarapu (sandy081) commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

What / why

Block 9 of Move Chats: sessions without a workspace ("workspace-less", WL) can now move like any other session, and chats can move between WL and foldered sessions. Includes the host side (move validation, scratch-folder rows, session-move recording, Claude recreate of a moved chat's missing folder, move_session tool texts) and the Agents-window client (provider, sessions list/actions, refusal texts, trust filtering of scratch folders).

Move matrix

Move Result
WL session → under a foldered session (Q10) allowed; its folder becomes its chat's recorded folder
Chat with a real folder → into a WL session (Q2) allowed; the WL session stays WL
Chat of a WL session → another session allowed unless its scratch folder is also used by another chat that stays (Q11)
Promote a chat working in a scratch folder (Q6) becomes a WL session
Promote the default chat, or a legacy nested chat sharing the session's folder refused (default chat / Workspaceless)
Chat with no folder refused (Workspaceless)
Missing scratch folder still moves; recreated on use for Copilot/Claude (Q9)
Missing provider-managed folder (Codex /tmp/vscode-agent-codex/...) refused (SessionNotReady)

Decisions

Q1 own folder, Q2 mixed, Q3 keep, Q4 withhold (resolved: no code needed, see below), Q5 document, Q6 chat-only, Q7 stay, Q8 quick, Q9 recreate for Copilot/Claude and refuse Codex tmp, Q10 allowed.
Q11 (a), Q12 (a), Q13 (c) forks share the source folder: coordinator decision, pending user confirmation.

M1 (Q4): a whole-session move tombstones the source session (tombstoneKey + deleted rows); 1.142/1.143 list only via the registry, which filters tombstones, and discovery registers with checkTombstone, so older builds don't list the moved-from session and can't delete a folder still in use.

Validation

On head 5c188d1 (Block 9 + 9d r4 + startup/restart/greeting/final fixes + HIGH-16, merged with origin/main):

Check Result
npm run typecheck-client clean except 2 errors in copilotSdkManagedSettings.integrationTest.ts caused by the local SDK being older (1.0.23) than main's 1.0.24 (install blocked by registry E401); environmental
eslint on the 97 changed .ts files vs origin/main passed
Agent-host unit tests (common, node, browser, electron-browser) 15,055 passing, 0 failing
Sessions browser tests (src/vs/sessions/**/test/browser) 7,237 passing, 0 failing
Workspace trust tests (agentHostWorkspaceTrust 10, plus workbench trust) 29 passing, 0 failing
./scripts/test-agent-host-e2e.sh (deterministic, strict replay) 134 passing, 1 failing: Copilot managed-permissions replay mismatch, because main re-recorded those fixtures for SDK 1.0.24 and the local SDK is 1.0.23 (environmental; CI uses 1.0.24). All other suites passed
Mutation checks (each fails its pinning test) Claude moved-chat recreate gate, Q11 shared-folder refusal, no-folder refusal, H1 in-flight allocation guard, H2 chat-only rule, M2 removing-row load, M3 republish, M4 host decision; 9d: placeholder never dropped with a turn, unsent-only delete without confirmation, folder/worktree release on a refused create; HIGH-9 orphan repair, HIGH-9 canonical chat identity, HIGH-11 persisted workspace-less marker; trust: the repository-trust gate
npm run transpile-client passed

Sub-block 9d: nested chat composer

The "New Chat" in a session uses the same composer as New Session, with the user's decisions:

  • No harness picker and no environment picker.
  • The folder is preselected to the parent session's folder (foldered session) or "No workspace" (workspace-less session).
  • For Git folders the user picks Folder or New Worktree plus a branch.
  • Single-folder agents are limited to the session's own folder (plus "No workspace" in a workspace-less session).
  • Old hosts and cloud sessions keep today's composer.

On send, the composer adopts its untitled chat: the client sends vscode/setChatWorkspace (createChat _meta vscode.chatWorkspace, gated by a capability), and the host re-creates the chat's backing in the chosen folder or new worktree. A refusal keeps the draft and says why; a failure fully releases the folder or worktree again. An untitled chat holding a turn is never dropped.

Round 3 fixed the two review items: re-applying a workspace now releases the previous folder or worktree, and persistence is rolled back after a failure.

Known residuals:

  • The needs-backing mark after a double failure is in-memory only (lost if the host restarts).
  • A non-primary folder used only by this chat is detached on re-apply even if it was attached for another reason (there is no per-chat "prepared" record).

Overnight live/real-data findings and fixes

  • Startup scratch publish: the listing publishes vscode.scratchFolders for catalog and fallback rows, and the session list waits for the scratch load.
  • The workspace-less session's own scratch folder is marked as scratch.
  • Inheriting chats never get another chat's scratch folder: movability, move-remaining, worktree plan, in-use, send-time folders, pinning and launch directories use one shared definition (publishedScratchFolders / inheritedChatFolders).
  • 9d round 4: the picker excludes scratch folders, Open Folder/Browse, republish after setChatWorkspace, the host refuses a scratch folder as kind folder (using the same shared scratch definition), clearer error messages, and workspace trust inheritance for a chat's own worktree.
  • HIGH-9: deleting a chat reclaims its scratch folder (canonical chat identity recorded first; the tombstone also releases the chat's own unused folders by folder), plus a startup repair of orphaned short-form rows (in-use guarded).
  • HIGH-11: the persisted workspace-less marker is applied explicitly on restore (conversion survives a restart).
  • Session restore publishes scratch folders (live Greeting finding): a session opened after a restart no longer shows its scratch chat as a folder or raises a trust prompt.
  • HIGH-12: a chat-only set_workspace (setChatWorkingDirectory) retires the chat's old scratch folder and republishes.
  • HIGH-16 (critical): getEffectiveWorkingDirectories uses the chat's recorded own folders from its catalog summary when its state isn't hydrated, so after a restart a scratch chat in a workspace session no longer resumes in the session's real folder. The other "not hydrated = folderless" readers were audited and are safe.
  • MED-13: a live send recreates a missing recorded scratch folder under the chats root (Copilot/Claude), and the pre-send check recreates a missing recorded scratch folder of the chat (non-removing row) before failing; MED-12 has a client test.

For reviewers: a chat's own worktree (a VS Code-created <repo>.worktrees/... folder) now inherits workspace trust from any trusted repository folder of the session, not only the session's project. This extends the existing project rule and is path-based like it; an untrusted repo still prompts. Tests pin the limits: untrusted repo, picked folders outside .worktrees, scratch folders and the isolated-session rule.

Known limits:

  • Downgrade (F3): a promoted ex-default workspace-less chat can't be opened in 1.143 and shows 0 turns in 1.142; nothing is lost.
  • The two round-3 residuals above.
  • Follow-up C29: record-based worktree trust and hiding sibling worktrees in the picker.
  • MED-17 (follow-up): a chat that already ran in a wrong folder via an intermediate build can resume there on the hydrated path.
  • LOW-15: picker duplicates via a /tmp symlink.
  • Q11–Q13: coordinator decision, pending user confirmation.

Overnight live/real-data summary: live testing and the real-data check found the startup scratch publish, the workspace-less session's own scratch marking, cross-chat scratch inheritance, delete reclaim and orphan repair (HIGH-9), conversion persistence (HIGH-11), retire on chat-only set_workspace (HIGH-12), unhydrated-state resume in the session folder (HIGH-16) and missing-scratch recreate (MED-13); all are fixed above.

Review and perf handling

  • H1: no clock-based staleness; in-flight allocations are tracked in memory, and unused allocating rows are reclaimed at startup.
  • H2: a workspace-less chat with its own folder gets a chat-only set_workspace; the session and other chats stay as they are.
  • M1: an allocating row whose folder is in use is promoted to owned.
  • M2: removing rows are loaded too, so a fork sharing a removed owner's folder stays workspace-less after a restart.
  • M3: after the startup load lands, identities of already-registered sessions are republished; createChat/restoreSession await the load.
  • M4: Copilot readers converted to the per-chat decision (table in the implementation status notes); the guard test pins that a host decision of "not workspace-less" overrides the stored session marker.
  • LOW: a commit failure no longer deletes a folder under a live chat; dead code removed; guard comments added.
  • Perf: the moved-session record uses a targeted lookup; isScratchFolderInUse is a payload scan (like worktreeInUseSql), off the hot path.
  • Downgrade: owned rows are ignored by 1.142/1.143; the effect is a disk leak only (scratch folders of chats deleted while downgraded stay until cleaned after re-upgrade).

Not run

  • Live test: PASS WITH FINDINGS (final @8c5271c5155: no open HIGH; MED-17 → follow-up)
  • Real-data check: PASS

Follow-up round: moves (chat and session) now republish vscode.scratchFolders for the target and source so a moved workspace-less chat never shows as a workspace chat; MCP start on a cold workspace-less chat keeps it workspace-less; scratch recreate is limited to folders under the chats root; the default chat of a workspace-less session accepts chat-only set_workspace; the post-load republish also invalidates the session list.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 20:45
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.144.0 milestone Oct 20, 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

Scratch cleanup can delete live chat files, and unresolved workspace classification, metadata projection, and movability defects affect the new behavior.

5 open issues
What changed in this PR

Extends Move Chats to workspace-less sessions, connecting host-side scratch-folder handling with the Agents Window’s chat actions and workspace presentation.

Changes:

  • Adds scratch-folder persistence, cleanup, and per-chat workspace-less classification.
  • Enables nested chats in quick chats and updates folder presentation and refusal messages.
  • Expands regression tests and documents the updated behavior.
File Description
src/​vs/​sessions/​SESSIONS.md Documents mixed chat workspaces.
src/​vs/​sessions/​SESSIONS_LIST.md Documents nested quick chats.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListChatMoveDnd.test.ts Tests quick-chat move eligibility.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsList.test.ts Tests actions and folder labels.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsActions.test.ts Updates action visibility expectations.
src/​vs/​sessions/​contrib/​sessions/​browser/​views/​sessionsList.ts Shows folder badges in quick chats.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsActions.ts Enables nested-chat actions for quick chats.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Tests mixed workspaces and move refusals.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostChatMoveErrors.test.ts Tests revised refusal messages.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Projects scratch-aware chat workspaces.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostChatMoveErrors.ts Explains workspace-less move refusals.
src/​vs/​sessions/​contrib/​providers/​agentHost/​AGENT_HOST_SESSIONS_PROVIDER.md Documents scratch-folder presentation.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​sessionsChatAccessibilityHelp.test.ts Tests new accessibility guidance.
src/​vs/​sessions/​contrib/​chat/​browser/​sessionsChatAccessibilityHelp.ts Explains nested quick chats and moves.
src/​vs/​sessions/​common/​agentHostSessionWorkspace.ts Adds scratch-aware workspace helpers.
src/​vs/​platform/​agentHost/​test/​node/​sessionWorkspaceConversion.test.ts Tests independent foldered-chat conversion.
src/​vs/​platform/​agentHost/​test/​node/​sessionStateCompatibilityFixtures.test.ts Updates database compatibility expectations.
src/​vs/​platform/​agentHost/​test/​node/​sessionServerTools.test.ts Tests foldered chats within quick chats.
src/​vs/​platform/​agentHost/​test/​node/​providerIntegration/​copilotCredentialSponsorship.integrationTest.ts Updates chat context fixtures.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Tests scratch recovery and customization scope.
src/​vs/​platform/​agentHost/​test/​node/​codex/​codexPrewarmEviction.test.ts Updates chat context fixtures.
src/​vs/​platform/​agentHost/​test/​node/​codex/​codexModelRefresh.test.ts Updates creation context.
src/​vs/​platform/​agentHost/​test/​node/​codex/​codexChatDiscovery.test.ts Updates discovery contexts.
src/​vs/​platform/​agentHost/​test/​node/​codex/​codexAgent.test.ts Updates context resolution fixtures.
src/​vs/​platform/​agentHost/​test/​node/​claudeAgent.test.ts Tests scratch-folder recreation.
src/​vs/​platform/​agentHost/​test/​node/​claudeAgent.integrationTest.ts Updates chat context helper.
src/​vs/​platform/​agentHost/​test/​node/​chatMetadataTestHelpers.ts Supports scratch database operations.
src/​vs/​platform/​agentHost/​test/​node/​agentSideEffects.test.ts Updates changeset catalog calls.
src/​vs/​platform/​agentHost/​test/​node/​agentHostWorktreeRemovalDatabase.test.ts Updates migration expectations.
src/​vs/​platform/​agentHost/​test/​node/​agentHostWorktreeCleanupService.test.ts Tests scratch cleanup and retries.
src/​vs/​platform/​agentHost/​test/​node/​agentHostSessionStateDatabase.test.ts Updates schema version expectations.
src/​vs/​platform/​agentHost/​test/​node/​agentHostSeams.test.ts Tests per-chat workspace classification.
src/​vs/​platform/​agentHost/​test/​node/​agentHostScratchFolderDatabase.test.ts Tests scratch persistence and ownership.
src/​vs/​platform/​agentHost/​test/​node/​agentHostDatabase.test.ts Updates schema and migration assertions.
src/​vs/​platform/​agentHost/​test/​node/​agentHostCustomizationEnablementService.test.ts Tests scratch-based customization scope.
src/​vs/​platform/​agentHost/​test/​node/​agentHostChatMovability.test.ts Tests shared scratch-folder restrictions.
src/​vs/​platform/​agentHost/​test/​node/​agentHostChangesetStrategy.test.ts Updates changeset catalog setup.
src/​vs/​platform/​agentHost/​test/​node/​agentHostChangesetService.test.ts Updates changeset catalog calls.
src/​vs/​platform/​agentHost/​test/​node/​agentHostChangesetCoordinator.test.ts Updates coordinator fixtures.
src/​vs/​platform/​agentHost/​test/​node/​agentChatContextTestUtils.ts Adds workspace-less context default.
src/​vs/​platform/​agentHost/​test/​common/​sessionWorkspacelessMeta.test.ts Tests scratch metadata helpers.
src/​vs/​platform/​agentHost/​test/​common/​changesetUri.test.ts Tests per-chat changeset classification.
src/​vs/​platform/​agentHost/​test/​common/​agentHostWorkspaceTrust.test.ts Tests scratch-folder trust filtering.
src/​vs/​platform/​agentHost/​node/​shared/​sessionServerTools.ts Checks workspace status per chat.
src/​vs/​platform/​agentHost/​node/​shared/​sessionMoveTools.ts Updates move guidance and refusals.
src/​vs/​platform/​agentHost/​node/​copilot/​prompts/​promptRegistry.ts Clarifies workspace-less context documentation.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Exposes launch workspace-less status.
src/​vs/​platform/​agentHost/​node/​compatibleAgentHostDatabase.ts Maps scratch ownership identities.
src/​vs/​platform/​agentHost/​node/​claude/​claudeAgent.ts Recreates missing scratch folders.
src/​vs/​platform/​agentHost/​node/​chatContributions/​sessionWorkspaceConversion/​sessionWorkspaceConversionService.ts Applies per-chat conversion eligibility.
src/​vs/​platform/​agentHost/​node/​agentHostWorktreeRemovalDatabase.ts Shares working-directory query logic.
src/​vs/​platform/​agentHost/​node/​agentHostWorktreeCleanupService.ts Reclaims eligible scratch folders.
src/​vs/​platform/​agentHost/​node/​agentHostStateManager.ts Tracks recorded scratch folders.
src/​vs/​platform/​agentHost/​node/​agentHostScratchFolderDatabase.ts Adds scratch-folder storage and queries.
src/​vs/​platform/​agentHost/​node/​agentHostDatabase.ts Integrates scratch migration and deletion.
src/​vs/​platform/​agentHost/​node/​agentHostCustomizationEnablementService.ts Uses default-chat workspace classification.
src/​vs/​platform/​agentHost/​node/​agentHostChatMovability.ts Checks shared scratch-folder usage.
src/​vs/​platform/​agentHost/​node/​agentHostChangesetService.ts Classifies changesets per chat.
src/​vs/​platform/​agentHost/​node/​agentChatContext.ts Derives per-chat workspace-less context.
src/​vs/​platform/​agentHost/​common/​state/​sessionState.ts Adds scratch-folder metadata helpers.
src/​vs/​platform/​agentHost/​common/​changesetUri.ts Accepts explicit workspace-less classification.
src/​vs/​platform/​agentHost/​common/​agentHostWorkspaceTrust.ts Excludes reported scratch folders.
src/​vs/​platform/​agentHost/​common/​agent.ts Extends the chat context contract.

Review effort: Balanced

…eless)

WIP for Block 9b: required per-chat workspaceless on the chat context, decided from recorded scratch folders and the session marker, never from a path or URI. Launch directories follow it.

Co-authored-by: Copilot <[email protected]>
…olders, mark promoted quick chats

Co-authored-by: Copilot <[email protected]>
…r; WL->WL and promotion marker tests

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

- New Nested Session and the agent host's multiple-chats capability no longer exclude quick chats.
- Read vscode.scratchFolders once per session _meta change: scratch folders are left out of
  session and chat workspaces, the changes scope roots and label homes; a chat with its own
  folder in a quick chat shows that folder.

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

Quick chats are no longer excluded as chat move sources or targets; the host decides with movable.
A workspace-less refusal now says whether the chat shares its scratch folder with another chat of
its session (read from summaries when explaining the refusal) or has no folder.

Co-authored-by: Copilot <[email protected]>
Quick chats with chats that brought their folder along stay in Chats; those chat rows show their
folder (and announce it), scratch chats show none.

Co-authored-by: Copilot <[email protected]>
…tes a moved chat's missing folder; WL move tests

Co-authored-by: Copilot <[email protected]>
…te published ones; commit failure keeps the folder

An allocation in flight is tracked in memory; an allocating row that is not in flight and not listed by any chat is reclaimed (at startup nothing is in flight), one that is listed becomes owned. A failure recording ownership after the chat was published no longer deletes the folder under it.

Co-authored-by: Copilot <[email protected]>
…h their own folders changes only that chat

Co-authored-by: Copilot <[email protected]>
…s before listing, drop dead scratch DB methods

A fork sharing a removed owner's folder stays workspace-less after a restart; listSessions waits for the load and sessions registered earlier republish their identities. The moved-session record checks one row instead of reading the table.

Co-authored-by: Copilot <[email protected]>
…n apply, clean refusals

- createChat and setChatWorkspace refuse a folder workspace naming a recorded scratch
  folder, a workspace-less session's own primary folder or a published scratch folder.
- Working-directory identities and vscode.scratchFolders are republished after an
  apply and on rollback, so a new scratch chat is shown and trusted as scratch at once.
- Refusals reach the client as the message only; the stack is logged on the host.
- Rolling back a chat without folders of its own leaves it without folders and
  re-creates its backing as createChat did, never in another chat's scratch folder.

Co-authored-by: Copilot <[email protected]>
The scratch-folder refusal for chat workspaces uses publishedScratchFolders, the one definition of a session's scratch folders.

Co-authored-by: Copilot <[email protected]>
…med them in another spelling

A scratch row allocated for a chat about to be created (createChat, and
setChatWorkspace through the same allocation) was written before the chat
had a storage identity, so it named the chat by its runtime spelling while
chats_v2 records the storage spelling. Deleting the chat tombstoned it, but
the tombstone's chat_uri match missed the row: the folder leaked.

- The allocation records the chat's storage identity before writing the
  row, so every row names its chat as its catalog row does.
- A chat's tombstone also marks `removing` the scratch rows of the folders
  it recorded that no other live chat lists, whatever chat they name.
- At startup, an owned row whose chat is live under no recorded spelling
  and whose folder nothing lists is released (rows of earlier builds).

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

A chat's recorded scratch folder deleted while the host runs was only recreated on restore. Copilot and Claude now recreate it (under the chats root only) before using a live chat. Codex still refuses.

Co-authored-by: Copilot <[email protected]>
…vider's stale true on restore

The restore merge spread the provider's metadata under the persisted one, but a false marker is the absence of the key, so a stale discovered true survived and was written back, undoing a whole-session conversion after a restart.

Co-authored-by: Copilot <[email protected]>
…ored workspace-less session lists a foldered chat

Co-authored-by: Copilot <[email protected]>
Restore published working-directory identities but not vscode.scratchFolders, so a restored session's live state made the client treat a scratch chat's own folder as a workspace.

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

The folder stayed listed on the session, so the clean-up pass kept it after the chat was deleted.

Co-authored-by: Copilot <[email protected]>
The pre-send working directory check refused it before the agent could recreate it.

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

A chat whose state was not hydrated yet counted as folderless, so its send
resolved the session's non-scratch folders and a scratch chat ran in the
user's repo. It now uses the folders recorded in its catalog summary.

Co-authored-by: Copilot <[email protected]>
@sandy081
Sandeep Somavarapu (sandy081) marked this pull request as ready for review October 21, 2026 03:59
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

TylerLeonhardt

Matched files:

  • src/vs/platform/agentHost/node/claude/claudeAgent.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsManagementService.ts
  • src/vs/sessions/services/sessions/common/sessionsManagement.ts
  • src/vs/sessions/services/sessions/common/sessionsProvider.ts
  • src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminal/test/browser/agentHostPty.test.ts

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.

4 participants