Adopt AHP 0.7.0 workingDirectories + primaryWorkingDirectory in agent host#326847
Merged
Conversation
Sync the generated agent host protocol copy to spec version 0.6.0 (agent-host-protocol @ 11f1a65e), which renames the singular `workingDirectory` on session/chat state to a `workingDirectories` array in preparation for multiroot session support. This change is a pure, behaviour-preserving property adoption across all consumers: sessions continue to use a single working directory. Reads of a single directory now use `workingDirectories?.[0]`, field-copy sites pass the array through unchanged, and writes from a single URI produce a one-element array. No multiroot client support is added here (no capability advertising, state actions, multi-folder workspaces, or UI); those land in a follow-up milestone. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…spaces-support-agents # Conflicts: # src/vs/platform/agentHost/test/node/protocol/agentHostE2ETestHelpers.ts
Contributor
There was a problem hiding this comment.
Pull request overview
Adopts AHP 0.6.0’s workingDirectories array while retaining single-directory behavior.
Changes:
- Syncs generated protocol definitions to
11f1a65e. - Migrates host consumers to read or emit the first array entry.
- Updates affected fixtures and tests.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts |
Updates mock session summaries. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListStore.ts |
Migrates session-list directory handling. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListController.ts |
Reads the primary directory. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts |
Migrates resolved-directory lookup. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostGenericConfigChips.ts |
Migrates chip directory lookup. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCustomizationService.ts |
Supplies the primary directory. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatInputPicker.ts |
Migrates picker directory lookup. |
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts |
Updates remote-provider fixtures. |
src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts |
Updates local-provider fixtures. |
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts |
Migrates provider metadata mapping. |
src/vs/platform/agentHost/test/node/sessionPermissions.test.ts |
Updates permission fixtures. |
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts |
Updates protocol-handler mocks. |
src/vs/platform/agentHost/test/node/protocol/agentHostE2ETestHelpers.ts |
Updates protocol assertions. |
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts |
Updates side-effect fixtures. |
src/vs/platform/agentHost/test/node/agentService.test.ts |
Updates service fixtures and assertions. |
src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts |
Updates state-manager tests. |
src/vs/platform/agentHost/test/node/agentHostPullRequestOperationHandler.test.ts |
Updates pull-request fixtures. |
src/vs/platform/agentHost/test/node/agentHostGitStateService.test.ts |
Updates Git-state fixtures. |
src/vs/platform/agentHost/test/node/agentHostFileCompletionProvider.test.ts |
Updates completion fixtures. |
src/vs/platform/agentHost/test/node/agentHostDiscardChangesOperationHandler.test.ts |
Updates discard-operation fixtures. |
src/vs/platform/agentHost/test/node/agentHostCommitOperationHandler.test.ts |
Updates commit-operation fixtures. |
src/vs/platform/agentHost/test/node/agentHostChangesetService.test.ts |
Updates changeset fixtures. |
src/vs/platform/agentHost/test/node/agentHostChangesetCoordinator.test.ts |
Updates coordinator fixtures. |
src/vs/platform/agentHost/test/node/agentConfigurationService.test.ts |
Updates configuration fixtures. |
src/vs/platform/agentHost/node/protocolServerHandler.ts |
Reads the primary create-session directory. |
src/vs/platform/agentHost/node/localCommands/bangLocalCommand.ts |
Migrates terminal working directory. |
src/vs/platform/agentHost/node/agentService.ts |
Migrates host state producers and consumers. |
src/vs/platform/agentHost/node/agentHostSyncOperationHandler.ts |
Migrates sync directory lookup. |
src/vs/platform/agentHost/node/agentHostStateManager.ts |
Migrates summary and state propagation. |
src/vs/platform/agentHost/node/agentHostReviewService.ts |
Migrates review directory lookup. |
src/vs/platform/agentHost/node/agentHostPullRequestOperationHandler.ts |
Migrates pull-request operations. |
src/vs/platform/agentHost/node/agentHostGitStateService.ts |
Migrates Git-state lookup. |
src/vs/platform/agentHost/node/agentHostFileCompletionProvider.ts |
Migrates completion lookup. |
src/vs/platform/agentHost/node/agentHostDiscardChangesOperationHandler.ts |
Migrates discard operations. |
src/vs/platform/agentHost/node/agentHostCommitOperationHandler.ts |
Migrates commit operations. |
src/vs/platform/agentHost/node/agentHostChangesetService.ts |
Migrates changeset computations. |
src/vs/platform/agentHost/node/agentConfigurationService.ts |
Migrates effective-directory resolution. |
src/vs/platform/agentHost/common/state/sessionState.ts |
Migrates state conversion and merging. |
src/vs/platform/agentHost/common/state/protocol/version/registry.ts |
Registers 0.6.0 actions. |
src/vs/platform/agentHost/common/state/protocol/common/commands.ts |
Syncs generated command metadata. |
src/vs/platform/agentHost/common/state/protocol/common/actions.ts |
Adds generated action types. |
src/vs/platform/agentHost/common/state/protocol/channels-session/state.ts |
Defines session directory arrays. |
src/vs/platform/agentHost/common/state/protocol/channels-session/reducer.ts |
Adds session directory reducers. |
src/vs/platform/agentHost/common/state/protocol/channels-session/commands.ts |
Migrates create-session parameters. |
src/vs/platform/agentHost/common/state/protocol/channels-session/actions.ts |
Defines session directory actions. |
src/vs/platform/agentHost/common/state/protocol/channels-root/state.ts |
Defines multiroot capability types. |
src/vs/platform/agentHost/common/state/protocol/channels-chat/state.ts |
Defines chat directory subsets. |
src/vs/platform/agentHost/common/state/protocol/channels-chat/reducer.ts |
Adds chat directory reducers. |
src/vs/platform/agentHost/common/state/protocol/channels-chat/commands.ts |
Adds initial chat directory subsets. |
src/vs/platform/agentHost/common/state/protocol/channels-chat/actions.ts |
Defines chat directory actions. |
src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts |
Registers generated action origins. |
src/vs/platform/agentHost/common/state/protocol/.ahp-version |
Pins the synced specification commit. |
src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts |
Migrates remote protocol mapping. |
Review details
- Files reviewed: 53/53 changed files
- Comments generated: 4
- Review effort level: Medium
- Reject the not-yet-supported multiroot working-directory client actions (session|chat/workingDirectorySet|Removed) in the handwritten dispatch path so a client cannot mutate the synchronized working-directory set without the agent actually reconfiguring its directory access. The protocol declarations remain; only the operational dispatch is deferred until multiroot lands. - Compare workingDirectories by array identity (not just the primary entry) in the state manager summary-equality check, matching the immutable reducers and SessionSummaryNotifier so secondary-directory changes still dirty the summary. - Update ISessionWithDefaultChat / mergeSessionWithDefaultChat API docs to describe a chat's workingDirectories subset overriding or inheriting the session's full set, fixing links to the removed singular members. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
connor4312
previously approved these changes
Jul 21, 2026
The `sessionAdded notification filters out sessions outside the workspace` test constructed session summaries with the removed singular `workingDirectory` field, so the production filter (which now reads `workingDirectories[0]`) saw no directory and dropped the in-workspace session. Update the two directly-built summaries to the `workingDirectories` array form. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Base:
|
…spaces-support-agents
sandy081
marked this pull request as ready for review
July 21, 2026 19:06
…spaces-support-agents
The createSession dispatch handler now reads the working directory from the renamed `CreateSessionParams.workingDirectories` array (AHP 0.6.0), but several node integration / e2e test call sites still sent the removed singular `workingDirectory` field. Since the field is silently ignored, sessions were created without a working directory and fell back to the default chats folder, failing the Agent Host E2E workspace/fileOperations/hostFeatures suites across all providers (wrong cwd cascades into file completions, renames, worktree resolution, and cd-prefix stripping). Send `workingDirectories: [dir]` from the shared `createProviderSession` helper and the remaining direct wire call sites so the requested directory reaches the session state again. The real VS Code client already sent the array form. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sandy081
enabled auto-merge (squash)
July 21, 2026 23:59
sandy081
disabled auto-merge
July 22, 2026 00:03
dmitrivMS
reviewed
Jul 22, 2026
dmitrivMS
left a comment
Contributor
There was a problem hiding this comment.
AI Review: Two inline findings added.
DonJayamanne
previously approved these changes
Jul 22, 2026
Re-sync the generated protocol copy to the multiroot spec at 148c716b (spec version 0.7.0) and adopt the two follow-up changes: - Capability flag renamed `MultipleWorkingDirectoriesCapability.immutablePrimary` -> `requiresPrimary`, with the new "agent needs one directory designated as its primary root" semantics. No consumers referenced the old name. - New optional `primaryWorkingDirectory` field at both the session level (CreateSessionParams / SessionMetadata -> SessionState + SessionSummary) and the chat level (CreateChatParams / ChatState + ChatSummary). Mirror it through the state<->summary projection layer exactly like `workingDirectories`: createSessionState / createChatState / chatSummaryFromState / mergeSessionWithDefaultChat, plus the state manager's summary projection, field-equality check, SessionSummaryNotifier diff, and markSessionPersisted propagation. The generated SessionChatUpdated partial-summary merge is field-agnostic, so it carries the new field automatically. Purely additive optional fields; no client multiroot behavior is added (consumers still read `workingDirectories[0]` as the single effective root). Also preserve the VS Code-local `CompletionItem.label` field (added in #326807, ahead of the spec) which the verbatim re-sync would otherwise drop. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR review feedback on the multiroot working-directory action gate: - Instead of silently dropping the four not-yet-supported session|chat/workingDirectorySet|Removed client actions (which never echoed the origin, leaving the client's optimistic write-ahead action pending until reconnect), emit a rejection envelope through the normal reconciliation path. Added AgentHostStateManager.rejectClientAction, which emits an ActionEnvelope carrying the original ActionOrigin and a rejectionReason without running the reducer (no synchronized state change), so the originating client rolls back its optimistic action. - Guard the write-ahead client reconcile (SessionStateSubscription / ChatStateSubscription) so a rejected envelope is never applied to confirmed state in any branch — this also prevents a broadcast rejection from leaking the rejected action into a non-origin client's state. - Add a table-driven test covering all four action types asserting no dispatch and exactly one rejection envelope preserving the original origin. - Simplify the create-session working-directory read to `URI.parse(params.workingDirectories[0])` now the branch proves index 0 exists. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roblourens
previously approved these changes
Jul 22, 2026
sandy081
marked this pull request as draft
July 22, 2026 06:00
Re-sync the protocol copy to spec ea279d99 (0.7.0) and adopt the refined primaryWorkingDirectory design: - Session has NO primary: `primaryWorkingDirectory` is removed from SessionState / SessionSummary. The session is just the equal-peer `workingDirectories` set. Dropped all session-level primary handling (createSessionState, the SessionSummaryNotifier diff, _toSummary, _summaryFieldsEqual, and markSessionPersisted propagation). - Primary is per-chat, read-only, fixed at chat creation: kept the ChatState <-> ChatSummary mirroring (createChatState / chatSummaryFromState) and carry the chat's own primary through the session+default-chat composite (ISessionWithDefaultChat gains its own primaryWorkingDirectory; the merge no longer falls back to a session primary). It is not sent via `session/chatUpdated` (the state manager only ever puts status/activity/title in those changes), so it never mutates post-creation. - Inputs `CreateSessionParams.primaryWorkingDirectory` (seeds the default chat's primary) and `CreateChatParams.primaryWorkingDirectory` are synced; capability `requiresPrimary` unchanged. Also re-preserve the VS Code-local `CompletionItem.label` field (#326807, ahead of the spec) that the verbatim re-sync drops. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sandy081
marked this pull request as ready for review
July 22, 2026 14:54
sandy081
enabled auto-merge (squash)
July 22, 2026 15:02
DonJayamanne
approved these changes
Jul 22, 2026
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
Syncs the generated agent host protocol copy to spec version 0.6.0 (
agent-host-protocol@11f1a65e), which renames the singularworkingDirectoryon session/chat state to aworkingDirectoriesarray in preparation for multiroot session support.This is milestone 1 of multiroot support: a pure, behaviour-preserving property adoption. Sessions continue to use a single working directory — no user-visible change.
What changed
scripts/sync-agent-host-protocol.ts. The singularworkingDirectoryis replaced byworkingDirectories?: URI[]on the session/chat state and summary types. (.ahp-version→11f1a65e.)x.workingDirectories?.[0]x.workingDirectories)dir ? [dir] : undefined(or[dir]in tests)Explicitly not in this PR
No multiroot client support is added here — no capability advertising (
multipleWorkingDirectories), noworkingDirectorySet/workingDirectoryRemovedstate actions, no multi-folder workspaces, and no UI. Those land in a follow-up milestone.Validation
tsc --project ./src/tsconfig.json --noEmit— cleannpm run valid-layers-check— cleanFollow-up
Once the spec PR (microsoft/agent-host-protocol#337) merges, repoint
.ahp-version/sync source from the spec-branch commit to the merged commit.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com