Repository navigation
Agent host: move chats between sessions and promote a chat to its own session (Move Chats, Block 4) - #341788
Merged
Sandeep Somavarapu (sandy081) merged 48 commits intoOct 16, 2026
Conversation
Contributor
|
Base:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
6 open findings
Pending preparation remains bound to the previous session after a move · New Transfer input state on owner-change notifications · New Avoid recreating streams for chats moved from ended sessions · New Preserve departed chat slots when pairing late session moves · New Invalidate stale fallback bookmarks on chat selection · New Serialize editor retargeting across consecutive chat moves · New
What changed in this PR
Adds gated chat relocation support across Agent Host storage, runtime services, and client views.
Changes:
- Introduces move capabilities, eligibility checks, and persistence contracts.
- Preserves chat-owned state and follows moved conversations in clients.
- Adds regression tests and lifecycle documentation.
| File | Description |
|---|---|
| src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts | Updated as part of this pull request. |
| src/vs/workbench/contrib/terminal/test/browser/agentHostPty.test.ts | Updated as part of this pull request. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts | Updated as part of this pull request. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHost/agentHostChatMoveTracker.test.ts | Updated as part of this pull request. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHost/agentHostChatMoveEditors.test.ts | Updated as part of this pull request. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListController.ts | Updated as part of this pull request. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListContribution.ts | Updated as part of this pull request. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatMoveTracker.ts | Updated as part of this pull request. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatMoveEditors.ts | Updated as part of this pull request. |
| src/vs/sessions/SESSIONS.md | Updated as part of this pull request. |
| src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts | Updated as part of this pull request. |
| src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts | Updated as part of this pull request. |
| src/vs/sessions/services/sessions/common/sessionsProvider.ts | Updated as part of this pull request. |
| src/vs/sessions/services/sessions/common/sessionsManagement.ts | Updated as part of this pull request. |
| src/vs/sessions/services/sessions/browser/visibleSessions.ts | Updated as part of this pull request. |
| src/vs/sessions/services/sessions/browser/sessionsService.ts | Updated as part of this pull request. |
| src/vs/sessions/services/sessions/browser/sessionsManagementService.ts | Updated as part of this pull request. |
| src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.ts | Updated as part of this pull request. |
| src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts | Updated as part of this pull request. |
| src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts | Updated as part of this pull request. |
| src/vs/sessions/contrib/providers/agentHost/AGENT_HOST_SESSIONS_PROVIDER.md | Updated as part of this pull request. |
| src/vs/sessions/contrib/chat/test/browser/sessionWorkspacePicker.test.ts | Updated as part of this pull request. |
| src/vs/sessions/common/agentHostSessionsProvider.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/shared/editArcReporter.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/sessionStorageIdentity.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/sessionPermissions.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/sessionDataService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/sandboxConfigForSdk.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/missionControlSdkEventSource.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/missionControlHost.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/customizations/claudeCommandSlashCompletion.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/copilotShellTools.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/copilotAgent.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/codex/codexCreateChat.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/claudeAgent.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentSessionRegistry.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostTerminalManager.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostSkillCompletionProvider.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostCustomizationEnablementService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostChatMovability.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostChatInputService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostChangesetOperationService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostChangesetCoordinator.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostCatalogReconciliationService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/electron-browser/agentHostProtocolClient.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/common/sessionTestHelpers.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/common/agentHostSessionStateChatMove.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/shared/worktreeIsolation.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/sessionPermissions.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/sessionDataService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/missionControl/missionControlSdkEventSource.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/missionControl/missionControlHost.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/missionControl/MISSION_CONTROL.md | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/copilot/copilotSessionSandbox.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/copilot/agentHostSandboxEngine.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/compatibleAgentHostDatabase.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/codex/codexAgent.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/workspaceContext/workspaceContextContribution.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/sessionWorkspaceConversion/sessionWorkspaceConversionService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/queueDrain/queueDrainContribution.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/chatInput/chatInputContribution.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentMergeController.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostTerminalManager.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostSkillCompletionProvider.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostSessionStateDatabase.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostChatRowStore.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostChatMovability.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostChatInputService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostChangesetCoordinator.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentConfigurationService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/electron-browser/localAgentHostService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/vscodeSandboxPaths.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/state/sessionState.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/sessionDataService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/meta/vscode/agentHostSessionMoveMeta.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/meta/agentHostSessionMoveMeta.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/agentService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/agentHostStarter.config.contribution.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/agentHostSessionStateStore.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/agentHostExtensionProtocol.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/agentHostChatMove.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/browser/nullAgentHostService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/browser/agentHostProtocolClient.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/AGENTS.md | Updated as part of this pull request. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sandeep Somavarapu (sandy081)
force-pushed
the
agents/move-chats-feature-block4-design
branch
from
October 16, 2026 01:04
6ce7ecb to
c87abb3
Compare
… one (Block 4) Adds the agent-host.db primitives for moving chats: - moveChatV2 moves a visible non-default chat with its private descendants to another normalized catalog in one transaction. It records the origin session before the first move, keeps storage, pins the chat's folders when asked, bumps both catalog revisions, re-projects the older-build session_chats rows and marks both list payloads dirty. - reorderChatV2 places a visible chat after an anchor (or first). Both keep every catalog's visible orders a contiguous zero-based sequence: older builds reject a catalog with gaps and then can't open the session (downgrade probe with Insiders and 1.142). Co-authored-by: Copilot <[email protected]>
…ck 4) A chat move now commits the catalog move and the chats' central state in one agent-host.db transaction: - every moved chat's session_chat_state row moves to the target, never as its default chat, with the moved chat pinned to its folders; its row mirror bases in the source go (a moved chat gets no older-build row copies); - the per-folder git, GitHub and base-branch rows of the moved chat's folders come along: re-keyed when no chat staying in the source uses the folder, copied when one does. A row the target already has wins, and then the source keeps its own, so recorded pull requests and base branches are never dropped. The session state store's moveChat holds both sessions (in one order, so two moves can't deadlock), flushes their pending mirrors, commits, and refreshes both loaded states. It writes nothing to either session's session.db. Co-authored-by: Copilot <[email protected]>
AgentHostStateManager.transferChats moves a chat and its descendants to another session once the move is committed: it reassigns their owners (3c's reassignChatOwner), then dispatches session/chatRemoved on the source and session/chatAdded plus session/chatsReordered on the target, all synchronously so nothing runs between a chat leaving one session and joining the other. The chats keep their state, changesets, canvases and in-progress turn; the active-turn set and both sessions' summaries follow. A deleted chat is unregistered before its removal is dispatched, while a moved chat is still registered, so session/chatRemoved listeners tell the two apart with isChatRegistered. A moved chat keeps its changesets and file monitors, workspace-context preparation, isolation state and pending Agent Merge notices, and its blocked-input marker moves to its new session. Co-authored-by: Copilot <[email protected]>
Adds the experimental chat.agentHost.moveChats.enabled setting (default off), mirrored into the host's chatMoves.enabled root config. AgentHostChatMovability keeps ChatSummary.movable and ChatState.movable current: a chat is movable when moves are enabled and it isn't its session's default chat, a tool-spawned chat (it moves with its parent) or a hidden chat. It follows registration, owner changes, default chat changes and the setting, publishing session/chatUpdated and chat/movableChanged. Chat state and catalog summaries now carry movable. Co-authored-by: Copilot <[email protected]>
AgentService.moveChat validates the whole move first, adds the moved chat's folder to the target (pinning the target's inheriting chats), commits the catalog and central state in one transaction, then transfers the chats in memory. Refusals carry a stable reason, which the protocol handler returns as InvalidParams data. Promotion is refused until it lands. Co-authored-by: Copilot <[email protected]>
- A committed move always completes in memory: the store's post-commit reload never throws (a failed reload drops the cached model so it reloads on next use), and memory follows the database's moved chats in its order, with an anchor that disappeared falling back to first place. - session/chatRemoved listeners ask the state manager for a typed ChatRemovalReason (moved or deleted) instead of inferring it. - Tests: a reload failure after commit, moves in both directions at once (store and service), a moved peer's later edits writing no older-build copies, and the rule that a target's folder row wins while the source keeps its own. Co-authored-by: Copilot <[email protected]>
- moveChat reads the catalog revisions before validating, holds the admission of the moved chats' queued turns and keeps both sessions resident, then checks the move again after adding folders and right before committing; a refusal or failure removes the added folders. - A queued turn of a moved chat starts once the move is done, in the chat's new session (holdChatAdmission, consulted by the queue drain). - After the commit the in-memory move never fails the request; memory follows the database's placement (moveChatV2 now reports the moved chats in placement order and the target's resulting order). - The worktree check includes the session's resolved worktree; a session being disposed or deleted is refused as not ready. - Tests: every refusal reason, the undo of an added folder, changes made while folders are added, placement order with two visible descendants, and the held queued turn. Co-authored-by: Copilot <[email protected]>
The moved chat's effective value in its source session, for every property a chat may set for itself in the target, becomes its own value right after the move, so it keeps working as it did; its subagents inherit through it. Host-owned values are left to the target. Co-authored-by: Copilot <[email protected]>
…e (Block 4) promoteChatV2 registers the new session in both registries, creates its normalized catalog with the promoted chat as its default chat followed by its visible descendants, compacts the source, records the origin session and creates the new session's imported central state (the chat as its default chat, pinned to its folders, its session values and the folder state it carries), all in one transaction. The store holds both sessions and refreshes the source. A session whose default chat stores elsewhere has no database at its URI: neither its session values nor its chats' rows are mirrored there. Co-authored-by: Copilot <[email protected]>
AHP moveChat to a new session now promotes a peer chat and its descendants: the host mints a session of the same agent, commits it with the chat as its default chat, then creates it in memory and moves the chats there synchronously (state manager promoteChats), announcing it to clients. The chat keeps its runtime, which relaunches under the new session at its next turn. The new session starts with the chat's folders and its source's config with the chat's own values over it. The promoted chat records its own storage, and restore passes a default chat's recorded storage to its provider, so the new session never reads a database at its own URI. A chat without a recorded conversation of its own is refused. Movability is published after a chat joins its new session's catalog. Co-authored-by: Copilot <[email protected]>
- Both sessions' customizations are republished after a move or a promotion, so MCP entries a moved runtime published under its source and the chat's folder customizations follow it. - Deferred work kept for a chat (Agent Merge notices, external history, history watches) follows its owner when it moves, so it waits on the new owner's activity and survives the old owner ending. - A chat-row read or write addressed to a session the chat moved out of runs in its new owner, so it never writes a copy into the old session's database or its mirror bookkeeping. Co-authored-by: Copilot <[email protected]>
- M1: a session's default chat is looked up in its recorded storage everywhere: the loaded central state, else the catalog for a session that is not loaded (external title, teardown, provider disposal), so a promoted session never looks for its default chat in a database at its own URI, also after a restart. - L1: the config a moved chat takes along is written to its own database before the commit (and restored if the move is refused), so a crash after the commit keeps it. - L2: when memory can't follow a committed move, both sessions' loaded state is dropped so it loads from the database on next use. - L3: the target's catalog revision is re-read before the last checks. - L4: a promoted session is announced with its default chat not movable. - L5: a chat's applied sandbox state moves with it; a promoted chat's is its new session's. Co-authored-by: Copilot <[email protected]>
… relaunches (Block 4) Once a chat moved, the session-level MCP and customization state its running provider process publishes describes a configuration its new session does not have, so it is published to neither session until the next turn relaunches the process with the new owner's (C6): Copilot drops launch actions once the launch owner is not the chat's owner, and Codex publishes no MCP state while its thread was started for another owner. Claude publishes only plugin customizations, to the current owner. Co-authored-by: Copilot <[email protected]>
…ddress (Block 4) Moves, promotions and reorders change normalized catalogs only. They are now allowed whenever every catalog they touch has normalized authority, which the database checks in the same transaction that applies them, whatever a session's address or compatibility identity: historical copilotcli:, claude: and codex: sessions with normalized catalogs can move chats. A legacy or missing catalog is refused (notReady, reported as legacyCatalog). Registering and normalizing a catalog stay gated by the compatibility window as before. Co-authored-by: Copilot <[email protected]>
A promoted session is stored natively (no compatibility identity), unlike a session created for a client. Keeping its allocation in one helper makes giving it one a single call if that is decided. Co-authored-by: Copilot <[email protected]>
…lock 4) A chat's terminals belong to its runtime, not to its session. When it moves, every live terminal (shell or output-only) whose session claim names it is claimed by its new session (terminal/claimed), so clients show it there, and deleting the previous session leaves it running. Co-authored-by: Copilot <[email protected]>
…(Block 4) Copilot routed a client tool call completion whose chat and spawning chat have no runtime to the runtime of its owner's session-backed chat. That runtime never made the call, and after a move it is another session's chat. The completion is now dropped (traced) instead, as Claude and Codex already do. Co-authored-by: Copilot <[email protected]>
…k 4) A session-db, git-blob or pending-edit-content URI embeds the storage of the data it names. Access resolves that storage to its live owner: a chat's owner, a session itself, else the owner of the registered chat recorded as storing there. A moved single-chat session's database stores a chat another session owns, so its content stays readable without deriving an owner from the address. Co-authored-by: Copilot <[email protected]>
…d in (Block 4) A client without vscode.ahpChatUris derives a chat's session from its URI. It now sees a chat only in the session it was created in: a moved chat disappears from it (its removal from its first session is still delivered) and a promoted session, whose default chat came from another session, is hidden. The host knows where each moved chat came from: the first move records it, and the catalog's origin sessions are loaded at startup (before any listing), so no owner is derived from an address. Co-authored-by: Copilot <[email protected]>
A chat's attachment snapshots are now written under its recorded storage (the session's data dir for the default chat, unchanged; a peer's own dir), so they move and are deleted with the chat. The directories a chat may read snapshots from are its owner, its recorded storage and, for a moved chat, the session it was created in (the recorded origin, never parsed from a URI). They feed the attachment rewriter's known roots, the Copilot SDK and host sandbox read roots and the read auto-approval / snapshot-write deny. Co-authored-by: Copilot <[email protected]>
…out of it live Deleting a session keeps its attachments directory while a live chat whose recorded origin (chats_v2.origin_session_uri) is that session exists; the moved chat still reads the attachments it took there. Deleting a moved chat (as a peer or with its session) releases its origin's kept attachments once the origin is deleted and no live moved chat names it, so nothing leaks. Both checks read recorded data, so they hold across restarts. ISessionDataService.deleteSessionDataExcept deletes all but the named children of a data directory. Co-authored-by: Copilot <[email protected]>
…seed (Block 4) Pins that neither a move nor a promotion goes through 3b's D1 seeding (createChat / seedChatConfig): a chat seeded in its source keeps its own values in the target even when the target's default chat uses others, and a promoted session starts from the source's config with the chat's own values on top. Co-authored-by: Copilot <[email protected]>
A host moves a chat by removing it from one session's catalog and adding it to another's under the same backend chat URI. AgentHostChatMoveTracker pairs the two, in either order, by the backend chat (never by parsing its URI); promotion maps to the new session's main chat. - Agents window: the Agent Host sessions provider tracks every cached session and reports the required ISessionsProvider.onDidMoveChat (the Copilot Chat provider never moves chats). The sessions service keeps showing a moved chat: the slot that showed it, also after it fell back because the removal arrived first, shows the chat's new session with the chat active, announced to screen readers. - Main window: the Agent Host session list recognizes moves the same way and replaces each open chat editor of the moved chat in place. Co-authored-by: Copilot <[email protected]>
A sessionProvisional marker means there is no conversation at the session's own storage. That's no evidence for a session whose catalog records its default chat stored elsewhere, as a promoted session's is: 1.141 marks such a session it can't resolve (probe P2-2), and so does this build's catalog reconciliation. Once marked, the session was hidden and reported as never created for good whenever the agent couldn't describe it yet. The marker is now ignored when reading for such a session, and the reconciliation doesn't write it. A normalized draft, whose default chat stores at the session, still stays hidden (#321269). Co-authored-by: Copilot <[email protected]>
- Chat input: a check that completes after its chat moved settles the chat under its current owner, not the session it started in. A moved chat's input state is carried once its new owner lists it, also when its session ends by moving it under another session (which never removes the chat); writing it to an owner that doesn't list the chat yet dropped the chat's live state. - Mission Control: a session that still advertises a default chat now owned by another session starts no new stream. - Agents window: a session removed before its chat's move is known leaves its slot to the session the chat moved to; the fallback bookmark is forgotten once another chat becomes active. - Chat editors: retargeting is serialized, so a chat that moves again finds its editors where the previous move put them. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
The first session listing waited for the origins of moved chats, a scan of chats_v2, although only clients that place a chat by its URI (no vscode.ahpChatUris) need them. The origins now load in the background from startup: only those clients' listings wait for them, and they stay fail-closed while the origins are unknown. Until a chat first moved, the load reads one metadata row (written by the move) instead of scanning chats_v2; no schema change. Co-authored-by: Copilot <[email protected]>
… keeps its input state Moving a chat with its subagents (or a session with them) reassigned every owner first and then added the chats to the target one at a time: the first add's catalog sync invalidated the chats the target didn't list yet, dropping their live state. Chats in transfer are now exempt. Promotion now sets the new session's catalog before it reassigns owners, so what reacts to the owner change sees the chats it takes: a blocked chat's input state follows it into the new session. Co-authored-by: Copilot <[email protected]>
After a peer move, a promotion or a session move commits, a background job copies the files the moved chat's messages (and its subagents') attached in its origin, i.e. their recorded snapshot URIs under the origin's attachments directory, into the chat's own storage under the same relative paths: through a temporary file, skipping files already there, 8 files per step with a yield in between, recording its progress in agent-host.db metadata (no migration). A restart resumes it once the chat's session is restored. A host resource read of a copied file the origin no longer has (deleted, also by an older build) reads the copy. A chat whose copy is complete no longer keeps its origin's attachments; one moved with its session copies nothing and keeps counting. Co-authored-by: Copilot <[email protected]>
…ision B) Provider-native tools still read a moved chat's pre-move attachments at their original paths, so the origin keeps its attachments directory while any moved chat lives, also once the chat's copy is complete. The copy protects the files from deletions by older builds, and host reads fall back to it. Releasing on completion stays implemented behind RELEASE_COPIED_ATTACHMENT_ORIGINS, switched off. Co-authored-by: Copilot <[email protected]>
…s and reorders Stacked on Block 4a. Each move, session move, promotion and reorder now follows 4a's contract for writes that re-project normalized catalogs (agentHostChatCatalogV2.md): - before validating, it waits for the in-flight peer-store writes of every session it touches (whenSessionsIdle), converts a legacy catalog to normalized authority, and imports what older builds changed (reconcileOlderBuildCopy); - in its transaction, guardOlderBuildEdits refuses an older build's edit of any chat list it re-projects (both sessions of a move); the edit is imported and the write tried once more; - it records the projection it writes (projected_revision), and once committed schedules the older-build copy of the sessions it changed (new AgentHostPeerChatStore.scheduleOlderBuildCopyPublish), so older builds see a moved chat where it is now and record it as left. 4a converts every session, so the authority-1 legacyCatalog refusal now remains only for a session 4a can't convert yet (its provider can't vouch for it, or its conversion is parked). Co-authored-by: Copilot <[email protected]>
…lders follow #341885 Main's #341885 reserves the folders of chats being created or moved, so archiving or deleting a chat doesn't detach them from the session workspace before the chat is published. Moves now use that: - the folders a moving chat brings are reserved in the destination from the moment the move takes its chat's turns until the destination lists the chat; a refused move ends the reservation before it removes the folders it added; - the folders prepared in the destination are consumed once the chat lands there, so they are in use rather than reserved forever, and archiving or deleting the moved chat there detaches them; - like a deleted chat, a chat that moved out (peer move or promotion) leaves its source no folder no remaining chat uses: the folders' Git and GitHub state already went with it. A session move ends its source. Co-authored-by: Copilot <[email protected]>
…servation - A move retried after importing older-build edits reads the source's folders and remaining chats again when it commits: a chat an older build added in the source on the moving chat's folder keeps that folder's Git state (copied, not moved away). - A reorder checks its anchor again after preparing, so an anchor an import removed is an invalid anchor rather than a conflict. - A comment says why a folder the move prepares is reserved twice. - Removes an orphaned doc comment. - Tests: promotion and reorder each refuse an older build's edit at the database, and apply once it's imported; a retry keeps a sibling's folder state; a refused move leaves the destination's folders unreserved and detachable. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
force-pushed
the
agents/move-chats-feature-block4-design
branch
from
October 16, 2026 03:09
c87abb3 to
a2ff30b
Compare
…B4-1) After a promotion the new session's own title keys were never written, so a restart restored and listed it by the agent's summary (its first prompt). The promotion now persists the chat's title and recorded title source (user, agent or auto) as the new session's title after the commit. 4a's older-build copy reads the same session keys, so publishing and importing it changes nothing. Co-authored-by: Copilot <[email protected]>
The chatAttachmentCopy:<chat> record in agent-host.db outlived its chat until the next startup pruned it. Every chats_v2 tombstone (a removed private chat, a peer removed from its catalog with its private descendants, a deleted or excluded session's chats) now deletes the record in the same transaction. A copy step is recorded only while its chat is live: a copy running when its chat is deleted stops, records nothing and reports no completion, and stops before a step if the chat is no longer registered, so it doesn't recreate the deleted storage. A restart resumes no copy for a deleted chat. Co-authored-by: Copilot <[email protected]>
- Attachment copy: a chat unloaded while its copy runs resumes once it is restored. Recording its progress tells it from a deleted chat (only a live chat's is recorded), whose copy stops and is forgotten. - Promoted session title: the source is the chat's after the commit, or 'user' for a rename known in memory only. The title is written through the ordered list-visible state write, which also updates the session's catalog row that older builds read, and is skipped if the new session was renamed meanwhile. Co-authored-by: Copilot <[email protected]>
A chat or session move the host refuses (notMovable, destinationSingleFolder, legacyCatalog, conflict, …) is an expected outcome, but ProtocolServer logged it at [error] with a stack. Refusals now travel as a typed protocol error and are logged at info with their reason and message; unexpected failures stay errors. Clients see the same InvalidParams error with its reason. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Main's pre-warmer (#341698) read the default chat's storage through _defaultChatStorageResource, which Block 4 split. Use the known recorded storage, or the creation-time rule for a draft's default chat not recorded yet. Co-authored-by: Copilot <[email protected]>
- The database caches whether any chat ever moved (the chatsV2Moved marker, read once per process; a move sets it). Without one, listing moved chats or attachment origins, reading attachment copy records at startup and deleting a chat's copy record on tombstone run no statement. - The chat row store asks whether a chat moved out of a session only when a chat ever moved. - Whether a deleted storage keeps its attachments for chats that moved out of it is answered from the moved chats' origins in memory when they are known; only an origin of a live moved chat reads the catalog. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
marked this pull request as ready for review
October 16, 2026 05:25
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
October 16, 2026 05:25
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Ladislau Szomoru (@lszomoru)Matched files:
Anthony Kim (@anthonykim1)Matched files:
|
Dmitriy Vasyura (dmitrivMS)
approved these changes
Oct 16, 2026
Sandeep Somavarapu (sandy081)
deleted the
agents/move-chats-feature-block4-design
branch
October 16, 2026 05:35
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Block 4 of Move Chats: the agent host can move chats between sessions, and promote a chat to its own session, live, while a turn is running. It builds on Block 3a (central chat catalog), Block 3b (#341714, per-chat config), Block 3c (#341734, owner-split provider seam) and Block 4a (#341904, older-build reconciliation), all merged. The UI actions come in Block 5; this PR adds the host operations and what existing clients need to follow a move.
Everything is behind the setting
chat.agentHost.moveChats.enabled(mirrored into the host root configchatMoves.enabled), default off. With it off, no chat is published as movable,moveChatis refused withdisabled, andvscode/moveSessionis neither advertised nor handled.What Block 4 adds
AHP
moveChat(the stub inprotocolServerHandler.tsis replaced):afteranchor;newSession).The chat moves together with its host-managed descendants (subagents, found by their recorded parent chain). Chat URIs,
ChatOriginand the chat's own database stay unchanged; ownership is re-pointed.ChatSummary.movableis published and recomputed when it changes.VS Code-internal
vscode/moveSession(capabilityvscode.sessionMove, session_meta['vscode.movable']): moves a session whose default chat is its only chat under another session. AHP says the default chat is never movable, so this is a separate, gated session-level operation rather than a protocol change. The session's chat becomes a peer of the destination and keeps its data (the ended session'ssession.dbbecomes that chat's storage). The source session is tombstoned in the same transaction.Data (3a model):
Config (3b):
chatMutablevalues as its own, written before the commit;Live moves (3c late-bound owner):
Restore follows the recorded chat order (
chats_v2.chat_order), so a chat moved or reordered before the default chat stays there after a restart.Clients:
vscode.ahpChatUrissee a chat only in the session it was created in;AgentHostChatMoveTracker, requiredISessionsProvider.onDidMoveChat, with a polite screen-reader announcement);ISessionsProvidergainscanMoveSessionUnder/moveSessionUnderfor Block 5.Attachment migration after a move (Block 4b). After a move, a background job copies the files the moved chat's messages attached in its origin (their recorded snapshot URIs, never the whole folder) into its own storage under the same relative paths. It writes through a temporary file and skips files already copied. It records its progress in
agent-host.db(metadata, no migration), so a restart resumes it once the chat's session is restored. It runs 8 files per step and yields in between. A host read of a copied file the origin no longer has, for example because an older build deleted it, reads the copy. The origin still keeps its attachments while any moved chat lives, because provider-native tools read the original paths; releasing on completion is implemented but switched off (RELEASE_COPIED_ATTACHMENT_ORIGINS).Docs:
src/vs/platform/agentHost/AGENTS.md§3c "Moving Chats"; a paragraph inAGENT_HOST_SESSIONS_PROVIDER.md.Integration with Block 4a (older builds)
Every move, session move, promotion and reorder follows 4a's contract for writes that re-project normalized catalogs (
agentHostChatCatalogV2.md):whenSessionsIdle), converts a legacy catalog to normalized authority, and imports what older builds changed (reconcileOlderBuildCopy).guardOlderBuildEditsrefuses an older build's edit of any chat list the write re-projects: both sessions of a move or session move, the source of a promotion, the session of a reorder. Nothing is written; the edit is imported and the write tried once more. Each write records the projection it writes (projected_revision).AgentHostPeerChatStore.scheduleOlderBuildCopyPublish), so older builds see a moved chat where it is now, and its source records it as left for 4a's neutralizing import.Folders of a moving chat (#341885)
Main's #341885 reserves the folders of chats being created or moved, so archiving or deleting a chat doesn't detach them before the chat is published. Moves use it:
Refusals
A refused move changes nothing. Requests are validated, re-validated after every await and once more right before the commit. The typed reason (
AgentChatMoveRefusal) is returned in the protocol error'sdata.reason:disablednotMovabledestinationNotFoundinvalidAnchorafteranchor isn't a visible chat of the destinationdifferentProvidersessionArchivedsessionNotReadysessionQuarantinedconversionInProgressworktreeFoldervscode/moveSession, the source records any worktree (#6 records a worktree removal only when a session is deleted)workspacelessagentMergeOwnervscode/moveSessiondestinationSingleFolderlegacyCatalogconflictunsupportednotSingleChatvscode/moveSessionon a session with other chatsnotStartedThe chat's folder is added to the destination's folders when it isn't already one of them.
Behaviour notes
chatMutableconfig. Only itschatMutablevalues carry over. Promotion differs because its destination is a new session, which starts from the source's.attachments/while a chat that moved out of it lives, also once the copy is complete; the reference is recorded once and survives restarts.chatAttachmentCopy:<chat>) is deleted with the chat in the same transaction, for every way a chat is deleted. A copy still running when its chat is deleted stops and records nothing, and a restart resumes no copy for a deleted chat (live finding B4-2). A chat merely unloaded mid-copy resumes once it is restored.vscode.ahpChatUrissee a chat only in the session it was created in. If the moved-chat origins can't be read, the host retries once, then hides conservatively.ahp-session:/<uuid>, no compat identity), which differs from agentHost: preserve writable session downgrade compatibility #340980's allocation rule because promotion bypassesprepareSessionStorage. The allocation is isolated in_allocatePromotedSessionso switching to a compat identity is a small change; Block 4a plans it.sessionProvisional:marker ("no conversation at the session's own storage") is ignored for a session whose catalog records its default chat stored elsewhere, as a promoted session's is. Older builds (1.141) and the catalog reconciliation would otherwise hide it and report it as never created. Crash-orphaned drafts stay hidden (Seeing the new session in the sessions list #321269).Known follow-ups
cleanupOrphanedDatagap.peerChatBacking, empty sanitized-name folders).How to test
chat.agentHost.moveChats.enabledand open the Agents window with a local agent host.moveChat,vscode/moveSession) or through the unit and E2E tests below. Check that:Validation
Run at load < 20 with
COPILOT_*unset, on heada2ff30b8a39(on main38f4504f233). Locally,build-fastrefuses to run because main's Copilot SDK bump (preview.1) couldn't be installed (npmregistry401), so tests ran onnpm run transpile-clientoutput.npm run typecheck-clienteslinton the 99 changed.tsfilesnpm run valid-layers-check./scripts/test.sh --runGlob "vs/platform/agentHost/test/node/**/*.test.js"./scripts/test.sh --runGlob "vs/platform/agentHost/test/{common,browser}/**/*.test.js"./scripts/test.sh --runGlob "vs/platform/agentHost/test/electron-browser/**/*.test.js"./scripts/test.sh --runGlob "vs/sessions/**/*.test.js"./scripts/test.sh --runGlob "vs/workbench/contrib/chat/test/browser/agentSessions/**/*.test.js"npm run test-agent-host-e2e -- --jobs 2(strict replay, all providers)main(38f4504f233) without this PR, so they're environmental (the uninstalled SDK bump).Mutation checks accompany the main rules: refusals, the D1 pin, the attachments keep/release, the authority gate, restore order, worktree recording, tracker untracking, each 4a guard, import, retry and publish, and the folder reservations. Each mutation fails its test.
Later fixes (B4-1 promoted-session title, B4-2 attachment-copy record cleanup, B4-4 refusals logged at info, the perf fix, and Agent Merge's #341698 pre-warmer adaptation) each have their own tests and mutations; the full agentHost node suite on those heads: 11535 passing.
Live (Agents window, transpile-client builds, genuine commit-verified stable 1.140.0 / 1.141.2 / 1.142.0):
Perf (quiet ABBA vs 4a-on-main at 2k/10k sessions, plus a re-count on the final head vs main):
agent-host.dbstatements as main, 0 session.db opens;Real user data (a copy, 24 GB): Block 4 vs main lists and opens identically with no new log errors. Real moves couldn't be exercised: the real sessions are archived, worktree-bound or live, and every attempt was refused cleanly with no data change. An old-build open plus rename round trip on the Block-4-touched copy lost nothing.
Reviews: passes 1–8 SHIP (no HIGH/MEDIUM open).