Skip to content

agentHost: refuse moving a chat whose working directory is missing - #342619

Merged
Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
agents/fix-move-chat-missing-folder
Oct 19, 2026
Merged

Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
agents/fix-move-chat-missing-folder

Conversation

@sandy081

Copy link
Copy Markdown
Member

Follow-up to #342546. moveChat of a nested chat whose working directory no longer exists on disk failed with an untyped SessionWorkingDirectoryMissingError, and jsonRpcErrorFrom sent its full err.stack to the client as the message. Promoting the same chat already refused correctly with sessionNotReady.

Root cause: _moveChat reads the moved chat's folders via _movedChatFolders / _movedSubtreeFolders, which call resolveChatState. That lazily loads the chat through the provider, which throws when the working directory is gone. Only the promote path wrapped its own read.

Fix: a small _resolveChatForMove helper turns a failed resolve into AgentChatMoveRefusedError(SessionNotReady, …). It is used by both folder readers and by the promote check. The refusal happens before anything changes. Behind chat.agentHost.moveChats.enabled (default off).

Validation:

  • scripts/test.sh --run …agentService.test.ts --run …agentHostDatabase.test.ts --run …localAgentHostSessionsProvider.test.ts: 1840 passing, 27 pending, 0 failing. The new test failed before the fix with the untyped error.
  • npm run typecheck-client: passed.
  • npm run eslint -- <changed files>: passed.
  • Hygiene (pre-commit hook): passed.
  • Not run: smoke and integration suites.

Resolving a chat's folders for a move rethrew the provider's untyped
SessionWorkingDirectoryMissingError. Refuse it as SessionNotReady before
anything changes, like promoting does.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix preserves promotion behavior and consistently handles resolution failures before move mutations, with regression coverage.

No open issues 🎉

What changed in this PR

Makes chat moves return a typed sessionNotReady refusal when chat history cannot load, including when its working directory is missing.

Changes:

  • Shares error handling across promotion and moved-chat folder resolution.
  • Adds regression coverage for move and promotion refusals while preserving chat ownership.
File Description
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Tests missing-directory refusals and unchanged ownership.
src/​vs/​platform/​agentHost/​node/​agentService.ts Centralizes chat-resolution failures into typed move refusals.

Review effort: Balanced

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