agentHost: sync workspace folders for existing sessions - #328953
Draft
DonJayamanne wants to merge 1 commit into
Draft
agentHost: sync workspace folders for existing sessions#328953DonJayamanne wants to merge 1 commit into
DonJayamanne wants to merge 1 commit into
Conversation
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>
Contributor
There was a problem hiding this comment.
🟡 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; |
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
turn/startworkspace rootsGuardrails
Validation
npm run typecheck-clientnpm run valid-layers-check