Skip to content

agentHost: sync workspace folders for existing sessions - #328953

Draft
DonJayamanne wants to merge 1 commit into
mainfrom
don/agents/dynamic-multi-root-working-directories
Draft

agentHost: sync workspace folders for existing sessions#328953
DonJayamanne wants to merge 1 commit into
mainfrom
don/agents/dynamic-multi-root-working-directories

Conversation

@DonJayamanne

Copy link
Copy Markdown
Contributor

Summary

  • synchronize existing Editor Window Agent Host sessions when multi-root workspace folders are added or removed
  • preserve the immutable primary directory and apply provider changes before confirming AHP state
  • update Claude through safe query rebuilds and Codex through same-thread turn/start workspace roots
  • support Remote Development URI mapping and current-folder reconciliation before prompts

Guardrails

  • limited to Editor Window sessions
  • excludes workspace-less, worktree-isolated, and multi-chat sessions
  • Copilot dynamic mutation remains disabled until its SDK exposes an accessible-roots API
  • reconciliation failures block the prompt instead of starting with stale access

Validation

  • all changed unit-test files pass
  • npm run typecheck-client
  • npm run valid-layers-check
  • hygiene checks for all changed TypeScript files
  • independent code review and rubber-duck review

Keep Editor Window Agent Host sessions aligned with multi-root workspace folder changes while preserving the primary directory. Apply provider updates before confirming AHP state, including Remote Development mapping and safe Claude/Codex runtime updates.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 4, 2026 12:28

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.

🟡 Not ready to approve

Provisional rebinding can retry indefinitely, and one-folder or older-protocol sessions are not safely reconciled.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds dynamic workspace-folder synchronization for eligible Editor Window Agent Host sessions, including remote URI translation and provider-specific updates.

Changes:

  • Adds awaitable AHP working-directory mutations with validation and reconciliation.
  • Updates Claude and Codex sessions to apply changed secondary roots.
  • Adds remote mapping and broad unit-test coverage.
File summaries
File Description
editorRemoteAgentHostServiceClient.test.ts Tests remote URI mapping.
agentHostWorkingDirectoryUri.ts Converts remote working-directory URIs.
editorRemoteAgentHostServiceClient.ts Maps remote session directories.
agentHostPty.test.ts Updates the connection mock.
agentHostUntitledProvisionalSessionService.test.ts Tests provisional folder changes.
agentHostSessionWorkingDirectorySynchronizer.test.ts Tests reconciliation and trust.
agentHostNewSessionFolderService.test.ts Tests desired-root computation.
agentHostUntitledProvisionalSessionService.ts Recreates provisional root sets.
agentHostSessionWorkingDirectorySynchronizer.ts Synchronizes existing sessions.
agentHostSessionHandler.ts Reconciles roots before prompts.
agentHostNewSessionFolderService.ts Computes stable desired root sets.
protocolServerHandler.test.ts Tests server action forwarding.
codexPrewarmEviction.test.ts Tests Codex root updates.
claudeAgent.test.ts Tests Claude query rebuilding.
agentService.test.ts Tests mutation validation and ordering.
remoteAgentHostProtocolClient.test.ts Tests awaitable remote dispatch.
agentSubscription.test.ts Tests optimistic action settlement.
protocolServerHandler.ts Enables session directory actions.
codexAgent.ts Applies roots to subsequent turns.
claudeAgentSession.ts Rebuilds queries with desired roots.
claudeAgent.ts Tracks desired Claude roots.
agentService.ts Validates and serializes mutations.
localAgentHostService.ts Exposes awaitable local dispatch.
sessionActions.ts Exports mutation action types.
agentSubscription.ts Adds awaitable optimistic actions.
agentService.ts (common) Extends provider and connection APIs.
remoteAgentHostProtocolClient.ts Dispatches and awaits action echoes.
nullAgentHostService.ts Implements the new null-service method.
Review details
  • Files reviewed: 28/28 changed files
  • Comments generated: 3
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment on lines +149 to +153
const rootState = registration.connection.rootState.value;
const agent = rootState && !(rootState instanceof Error)
? rootState.agents.find(candidate => candidate.provider === registration.provider)
: undefined;
return agent?.capabilities?.multipleWorkingDirectories?.immutablePrimary === true;
Comment on lines 581 to +584
const targetWorkingDirectory = oldEntry.workingDirectory ?? workingDirectory;
const targetWorkingDirectories = oldEntry.usesWorkspaceRootSet
? this._computeEntryWorkingDirectories(oldEntry)
: this._computeWorkingDirectories(targetWorkingDirectory, provider);
Comment on lines +144 to +147
const workspace = this._workspaceContextService.getWorkspace();
const multiRoot = readSessionMultiRootMetadata(state._meta);
if (!multiRoot || !URI.isUri(workspace.configuration) || !this._uriIdentityService.extUri.isEqual(URI.parse(multiRoot.workspaceFile), workspace.configuration)) {
return false;
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.

2 participants