Repository navigation
agentHost: only real chats' folders count for archive/delete detaching and Git state - #341885
Merged
Sandeep Somavarapu (sandy081) merged 7 commits intoOct 16, 2026
Conversation
…chived chat folders Subagent and side chats have no folders of their own, so they counted as using the complete session workspace and prevented an archived chat's folders from ever being detached. They now use the folders of the chat that spawned them and are in use only while that chat is unarchived. Co-authored-by: Copilot <[email protected]>
Deleting a peer chat now removes its folders that no remaining chat uses from the aggregate session workspace, with the same rules as archiving. The deletion itself does not fail when this cleanup fails. Co-authored-by: Copilot <[email protected]>
Contributor
|
Base:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Folder-scope handling and deletion cleanup still have correctness gaps, including a race with chat creation.
4 open findings
What changed in this PR
Updates Agent Host folder detachment so spawned chats do not unnecessarily retain archived chats’ folders, and extends cleanup to peer-chat deletion.
Changes:
- Resolves folder usage through spawning chats.
- Adds deletion-time detachment with error logging.
- Adds regression tests for subagents and shared folders.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/agentService.test.ts |
Tests subagent folder usage and deletion cleanup. |
src/vs/platform/agentHost/node/agentService.ts |
Shares detachment logic across archive and delete paths. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
roblourens
previously approved these changes
Oct 15, 2026
…der use Subagents work in the folders of the chat that spawned them. Folder changes and chat hydration no longer compute Git state for subagent chats, which repeated the spawning chat's query once per subagent. Deciding which session folders are in use now ignores any folders pinned to a subagent and uses its spawning chat's folders instead, including when a folder prepared for a chat is released. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
dismissed
roblourens’s stale review
via
October 15, 2026 23:14
bf0be0a
Archiving or deleting a chat now also considers the folders of the subagents and side chats it spawned, so folders pinned only to them are detached too. Unarchiving attaches back the chat's and its side chats' folders, not its subagents', as a subagent's folders are never considered in use. Co-authored-by: Copilot <[email protected]>
…ach on every deletion Folders a chat being created validates, and folders prepared for a chat that is not published yet, are reserved so detaching an archived or deleted chat's folders cannot remove them. A preparation reservation ends when it is released or a chat working in the folder is created or moved there. Deleting a peer chat of a session that is not loaded restores the session first so its unused folders can be detached, and detaching now also runs when an ancillary clean-up step fails after the chat left the catalog. Co-authored-by: Copilot <[email protected]>
roblourens
previously approved these changes
Oct 15, 2026
Archiving and unarchiving update the session folders asynchronously, which can take longer than a fixed 10ms on slow CI agents. The tests now wait until the expected folders are reached and report the last value otherwise. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
dismissed
roblourens’s stale review
via
October 15, 2026 23:49
9d1c65e
…ved-chat-folders-subagents # Conflicts: # src/vs/platform/agentHost/test/node/agentService.test.ts
Ben Villalobos (benvillalobos)
approved these changes
Oct 16, 2026
Sandeep Somavarapu (sandy081)
deleted the
sandy081/agents/archived-chat-folders-subagents
branch
October 16, 2026 00:31
Sandeep Somavarapu (sandy081)
added a commit
that referenced
this pull request
Oct 16, 2026
…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]>
Sandeep Somavarapu (sandy081)
added a commit
that referenced
this pull request
Oct 16, 2026
… session (Move Chats, Block 4) (#341788) * agentHost: move a chat between normalized catalogs and reorder within 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]> * agentHost: carry a moved chat's central state to its new session (Block 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]> * agentHost: move registered chats between sessions in memory (Block 4) 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]> * agentHost: publish which chats can be moved, behind a setting (Block 4) 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]> * agentHost: implement moveChat for peers and in-session reorder (Block 4) 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]> * agentHost: harden chat moves after review (Block 4) - 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]> * agentHost: Block 4 review pass-2 fixes - 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]> * agentHost: a moved chat keeps its source's config (Block 4) 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]> * agentHost: promote a chat into a new session in the database and store (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]> * agentHost: promote a chat into a new session (Block 4) 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]> * agentHost: a moved chat's live state follows it (Block 4) - 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]> * agentHost: Block 4 review pass-3 fixes - 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]> * agentHost: a moved chat's runtime publishes no session state until it 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]> * agentHost: gate chat moves on the stored catalog authority, not the address (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]> * agentHost: allocate a promoted session's address in one place (Block 4) 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]> * agentHost: a moved chat's terminals are claimed by its new session (Block 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]> * agentHost: complete client tool calls on the chat's own runtime only (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]> * agentHost: resolve content access through the chat stored there (Block 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]> * agentHost: older clients see a chat only in the session it was created 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]> * Block 4: snapshot a chat's attachments in its recorded storage 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]> * Block 4: keep a deleted session's attachments while chats that moved 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]> * agentHost: a moved or promoted chat keeps its own config, never D1's 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]> * Block 4: keep showing a chat that moved to another session 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]> * Block 4 review pass-4 fixes - L2: deleting a session's data except its attachments treats what a concurrent full delete removed first as deleted. - L3: a chat is no longer a moved chat once it moves back to its origin or is deleted. Reading the origins of moved chats is retried once; while it fails, older clients see no chat that may have moved and the next session listing reads them again. - L4: the owner of a recorded storage is found through an index kept with the chat registry. - L5: the reload after a failed in-memory move is awaited and its failures are logged. - L6: no synchronous lookup of a default chat's storage falls back to the creation-time rule: creation uses it explicitly, everything else uses the recorded storage (skill completion now resolves it asynchronously). - 4b-L1: a row access of a chat deleted between finding it moved and finding its new owner is dropped and logged instead of throwing. - 4b-L2: work deferred until a chat's turn ends (Agent Merge notices, external histories) reads the chat's owner when it is delivered. - 4b-L3: the D1 pin also covers a property the moved chat never set while the target's default chat sets it. - 4b-L4: attachment tests for a chat moved on again and for deleting a session together with its last moved chat. Co-authored-by: Copilot <[email protected]> * Block 4: Mission Control follows chat moves Mirror streams are per session and already follow a chat's owner at emit time. The SDK namespace replicates only a session's default chat: - a chat promoted to a new session's default chat starts that session's SDK stream at promotion, from the start of its journal; - a default chat that moves under another session (where it is a peer) is replicated no more: its old stream is retired, without replaying its history. Both rules await the Mission Control owner's confirmation and are documented as such. Read-only content access also reaches the data of a session's loaded chats and of the session a moved chat came from. promoteChats records the new session's default chat before the owner change is reported, so listeners see the session complete. Co-authored-by: Copilot <[email protected]> * Block 4: move a single-chat session under another session (VS Code-internal) A session whose default chat is its only chat (with that chat's subagents) can move under another session of the same agent: its chat becomes a peer of the destination, keeping the session's database as its storage, and the session ends (its registration, catalog and central state are tombstoned in the same transaction; its data stays). It runs on the shared chat-move path, so the same validation, folder additions, config carry-over, admission hold and live-turn handling apply. Behind the chat-moves setting (default off). - Protocol: VS Code extension `vscode/moveSession` (every parameter required, `after` may be null), capability `vscode.sessionMove` (never on relay transports) and session `_meta['vscode.movable']`; other hosts never see it. - Required `IAgentService.moveSession` and `IAgentConnection.moveSession` (rejects with AgentHostSessionMoveUnsupportedError without a request when the host lacks the capability) in every implementation, and `canMoveSessionUnder` / `moveSessionUnder` on the Agent Host sessions provider. - Deleting a chat's storage keeps the attachments that chats moved out of that session still read. Co-authored-by: Copilot <[email protected]> * Block 4: restore the chat order a move or a reorder recorded A session's restore listed its default chat first and then persisted that order, so a chat a move or a reorder placed before the default chat lost its place at the first restart. Restoring a normalized catalog now orders the visible chats by their recorded order before the listing is persisted; chats the order doesn't list keep their places. Co-authored-by: Copilot <[email protected]> * Block 4: document moving chats in the agent host spec Adds AGENTS.md section 3c: what moves with a chat, how refusals and live moves behave, config and data rules, and what clients and Mission Control see. Co-authored-by: Copilot <[email protected]> * Block 4: a session that owns a worktree does not move under another session A session that ends by a move records no pending worktree removal (#6 records one only when a session is deleted), so a detached worktree the moved chat doesn't work in would stay claimed by the ended session. Refuse such a move with worktreeFolder; nothing changes. Co-authored-by: Copilot <[email protected]> * Block 4 review pass-5 fixes - L1: document that a session moved under another session ends and its chat follows the destination's session-level state like every peer; only its chatMutable values carry (AGENTS.md section 3c). - L2: comment the backend-only pairing of the chat move tracker. - L3: untracking a session drops its catalog even when it was reported only through update, and nothing is scheduled once the tracker is disposed; a provider test pins that a session the provider drops is untracked, so a session that ends by a move reports its chat moved. Co-authored-by: Copilot <[email protected]> * Block 4: promote a chat only once its first turn started No agent persists a chat's conversation before its first turn starts (Copilot defers the SDK session, Claude writes its transcript and Codex its rollout when the turn begins). A session whose default chat has none can't be restored: after a restart it stayed listed but never opened (probe P2-1). Like a brand-new session, which is durable only after its first send, a chat now becomes its own session only when its resolved history has a turn or one is running; otherwise the promotion is refused with notStarted and nothing changes. Co-authored-by: Copilot <[email protected]> * Block 4: don't take a promoted session for a never-created draft 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]> * Block 4: address review feedback on moving chats live - 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]> * Block 4: note that a moved chat's attachment keep-reference is interim Co-authored-by: Copilot <[email protected]> * Block 4: take the moved-chat origins off the session listing's path 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]> * Block 4: a moved chat's descendants keep their state; a promoted chat 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]> * Block 4b: copy a moved chat's pre-move attachments into its own storage 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]> * Block 4b: keep the origin's attachments while a moved chat lives (decision 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]> * Block 4: integrate Block 4a's older-build guard into moves, promotions 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]> * Block 4: a chat's folders in transit stay attached; a moved chat's folders 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]> * Block 4: review pass-6 fixes for the 4a integration and the folder reservation - 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]> * Block 4: a promoted session keeps its chat's title across a restart (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]> * Block 4b: a deleted chat's attachment copy record goes with it (B4-2) 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]> * Block 4: pass-7 review fixes for promoted titles and attachment copies - 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]> * Block 4: log expected move refusals at info, not as errors (B4-4) 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]> * Block 4: give the session pre-warmer the recorded default chat storage 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]> * Block 4: no moved-chat statements where no chat moved (perf) - 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]> --------- Co-authored-by: Copilot <[email protected]>
1 of 5 tasks
Sandeep Somavarapu (sandy081)
added a commit
that referenced
this pull request
Oct 21, 2026
… chats use (#343275) * agentHost: skip git spawn for missing working directories getRepositoryRoot spawned 'git rev-parse --show-toplevel' with cwd set to the working directory even when that folder had been deleted. The resulting 'spawn git ENOENT' has empty stderr, so it was never negatively cached and was re-probed and re-logged on every refresh. Check that the directory exists before spawning git and return undefined quietly without caching, so a worktree recreated at the same path is picked up by the next lookup. A spawn ENOENT for a directory that vanished after the check is handled the same way. * agentHost: limit session changes to the folders of chats in use The Branch summary computed and watched every folder any chat of a session ever had, including archived chats and the folders subagents are pinned to (often deleted worktrees). Each git-state refresh re-armed every one of those owners through refreshBranchChangeset, which clears what is known about an unavailable owner, so a session with many archived chats and subagents kept recomputing and re-broadcasting changeset status. Move the 'only chats in use count' rule (#341782, #341885) out of AgentService into getChatsInUse and apply it to the Branch summary owners, the summary working directories and the coordinator's branch summary subscriptions. AgentService behavior is unchanged. The default chat is always kept. Also stop two ways a round restarts itself: do not dispatch a changeset status that is already current, and do not recompute an owner whose computation already ended in an error from the summary update; an explicit refresh still retries it. Co-authored-by: Copilot <[email protected]> * agentHost: reconcile the branch summary when a chat is archived or unarchived The branch summary subscribes to the folders of the chats in use only, but nothing re-evaluated that set when a chat's archived state changed. Archiving left the chat's changeset and file watcher subscribed, and unarchiving left it unobserved until an unrelated refresh. Co-authored-by: Copilot <[email protected]> * agentHost: drop explanatory inline comments added with the missing-folder and in-use fixes Co-authored-by: Copilot <[email protected]> * agentHost: name the missing-directory and spawn ENOENT checks for what they detect Review feedback: _isDirectory returned true for stat failures other than ENOENT/ENOTDIR, and isSpawnNotFoundError also matched a missing working directory. Rename them to _isMissingDirectory (true only when the path is definitely not a directory) and isSpawnEnoentError. No behavior change. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
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.


Follow-up to #341782. In a real multi-chat session, archiving chats and running Developer: Update Session Folders with Chats removed no folders at all, and each folder change ran Git once per subagent chat.
Why
Subagent chats (origin
tool) work in the folders of the chat that spawned them, but the agent host treated them as independent chats:What changed
_getWorkingDirectoriesInUse) now considers only real chats' folders:Testing
agentService.test.ts: an inheriting subagent and a pinned subagent of the main chat, plus a pinned subagent of the archived chat, don't block removal.agentService.test.ts: archiving a chat removes folders only its subagent or side chat used; unarchiving re-attaches the side chat's folder but not the subagent's.agentService.test.ts: deleting a peer chat removes its unused folder and keeps a shared one.agentHostChangesetCoordinator.test.ts: a session folder change refreshes Git state for the inheriting user chat but not the subagent, and still refreshes the subagent's changes summary.npm run test-nodeforagentService,agentHostChangesetCoordinator,chatContributions,agentSideEffects,sessionWorkspaceConversionand the three agent host telemetry suites: all pass. On a loaded machine, a few existing timing-sensitive tests failed intermittently (a different test each run, never consistently). Repeating theagentServicesuite: 4 of 5 full runs passed.npm run typecheck-client,npm run eslinton the changed files, and hygiene (pre-commit): passed.