Skip to content

agentHost: move never-run nested sessions and sessions not yet loaded - #342546

Merged
Sandeep Somavarapu (sandy081) merged 4 commits into
mainfrom
agents/fix-bug-f4-move-chats-feature
Oct 19, 2026
Merged

Sandeep Somavarapu (sandy081) merged 4 commits into
mainfrom
agents/fix-bug-f4-move-chats-feature

Conversation

@sandy081

Copy link
Copy Markdown
Member

Fixes two ways a nested session could not be moved with the Move Chats feature (behind chat.agentHost.moveChats.enabled, default off).

F4: a never-run peer chat could not be moved. A peer chat created by "New Nested Session" that never ran a turn has a legacy session_chats.is_read of NULL (peer creation writes no read state), while the verified per-chat aggregate says isRead: true (new chats are created idle and read). The catalog normalizer compared them strictly and refused the move with sessionNotReady ("Legacy peer state differs from verified per-chat source"). A NULL legacy is_read now reads as read; a real divergence (aggregate says unread) is still refused.

Sessions the host has not loaded could not be nested. The host publishes vscode.movable only for sessions it has loaded, so after a restart a single-chat session reported canMoveSessionUnder=false until opened, and moveSession did not restore its source (only moveChat restored its target). Design is "load at move time":

  • Client (canMoveSessionUnder): offers the nest for any unarchived single-chat session when the host supports vscode.sessionMove, from list data alone. It no longer reads vscode.movable (which can only be true or absent, so it cannot say "not movable"); no loading, no per-row subscriptions.
  • Host: moveSession (and the AHP moveChat source) restores an unloaded session inside the move sequencer via the existing restoreSession, then runs the normal checks, so the usual AgentChatMoveRefusedError reaches the user. A session that can't be restored is refused (notMovable / sessionNotReady) with nothing changed. Host publishing of vscode.movable is unchanged.

How to test

Unit tests (all passing together, 1820 tests):

  • scripts/test.sh --run src/vs/platform/agentHost/test/node/agentService.test.ts --run src/vs/platform/agentHost/test/node/agentHostDatabase.test.ts --run src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts → 1820 passing
  • npm run eslint -- <changed .ts files> → clean
  • npm run typecheck-client → clean (no errors)
  • Hygiene ran in the pre-commit hook → passed

Not run: Azure pipeline 111 e2e at the time of writing (queued after PR creation).

A legacy peer row that never recorded a read state has a NULL is_read, which
means read. The catalog normalizer compared it strictly to the verified
per-chat source (isRead: true for a new chat) and refused the move with
sessionNotReady. Treat NULL as read.

Co-authored-by: Copilot <[email protected]>
moveSession restores an unloaded source (and destination) before its checks, reusing the restore moveChat uses, so a refusal reaches the user as the usual warning. The client offers the nest drop for any unarchived single-chat session from list data alone instead of relying on vscode.movable, which the host publishes only for loaded sessions.

Co-authored-by: Copilot <[email protected]>
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.144.0 milestone Oct 19, 2026
Copilot AI balanced review requested due to automatic review settings October 19, 2026 13:36

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

Subagent eligibility and source residency protection need correction before approval.

2 open issues
What changed in this PR

Fixes Move Chats for never-run nested chats and sessions not yet loaded by the Agent Host.

Changes:

  • Treats missing legacy read state as read during catalog normalization.
  • Restores unloaded sessions at move time and derives client eligibility from cached list data.
  • Adds regression tests and updates provider documentation.
File Description
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Tests list-based move eligibility.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Updates session move eligibility.
src/​vs/​sessions/​contrib/​providers/​agentHost/​AGENT_HOST_SESSIONS_PROVIDER.md Documents load-at-move behavior.
src/​vs/​sessions/​common/​agentHostSessionsProvider.ts Updates eligibility contract documentation.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Tests unloaded-source moves and refusals.
src/​vs/​platform/​agentHost/​test/​node/​agentHostDatabase.test.ts Tests missing legacy read-state handling.
src/​vs/​platform/​agentHost/​node/​agentService.ts Restores sessions before move validation.
src/​vs/​platform/​agentHost/​node/​agentHostDatabase.ts Normalizes missing legacy read state.

Review effort: Balanced

@sandy081
Sandeep Somavarapu (sandy081) merged commit 741752a into main Oct 19, 2026
74 of 99 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the agents/fix-bug-f4-move-chats-feature branch October 19, 2026 14:12
Sandeep Somavarapu (sandy081) added a commit that referenced this pull request Oct 21, 2026
…3216)

canMoveSessionUnder counted subagent (tool-origin) chats, so a session with only its default chat plus that chat's subagents was not offered as a nest drop and moveSessionUnder refused it locally. The host already moves the default chat's subtree and excludes tool chats from the single-chat check, so count only non-tool chats.

Addresses the review comment on #342546.

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants