Skip to content

agentHost: scope changesets to chat working folders - #337263

Merged
Sandeep Somavarapu (sandy081) merged 16 commits into
mainfrom
sandy081/sessions-chat-changeset-ownership
Sep 23, 2026
Merged

Sandeep Somavarapu (sandy081) merged 16 commits into
mainfrom
sandy081/sessions-chat-changeset-ownership

Conversation

@sandy081

@sandy081 Sandeep Somavarapu (sandy081) commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR allows chats created within an Agent Host session to use folders or worktrees that differ from the session's original workspace. Those locations become part of the containing session while repository state and operations remain scoped to each chat's effective folder set.

Chats targeting the same folders share repository state, while chats targeting different folders remain independent. The client presents the session-owned cumulative Session Changes in every chat alongside chat-scoped Branch, Uncommitted, Turn, and Compare changes, preserving the existing session-wide changes experience across restarts and peer chats.

The implementation also keeps pull request, Agent Merge, review, commit, discard, and other Git workflows aligned with the correct folder owner, while maintaining compatibility with existing and legacy sessions.

Validation

Validated with client type checking, hygiene and layer checks, focused unit suites, the Agent Host protocol integration test, and diff checks.

Copilot AI balanced review requested due to automatic review settings September 22, 2026 11:53
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.140.0 milestone Sep 22, 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.

Copilot review overview

🟡 Changes recommended

Chat Git-state fallback, legacy protocol handling, stale state cleanup, and serialized refresh latency remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 4 Medium severity

Open (4)
What changed in this PR

Scopes Agent Host changesets and repository operations to their owning chat while retaining session-level aggregation and checkpoints.

Changes:

  • Adds per-chat changeset protocol/state projection.
  • Routes Git, review, and Changes view behavior through the active chat.
  • Adds coverage for chat-owned changesets and repository state.
File Description
src/​vs/​sessions/​services/​sessions/​common/​session.ts Adds chat changesets.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostSessionChangesets.test.ts Tests chat catalogue projection.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Exposes chat changesets.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostSessionChangesets.ts Creates chat-scoped changesets.
src/​vs/​sessions/​contrib/​changes/​test/​browser/​changesViewService.test.ts Tests active-chat switching.
src/​vs/​sessions/​contrib/​changes/​browser/​changesViewService.ts Uses active-chat workspace and changesets.
src/​vs/​platform/​agentHost/​test/​node/​agentSideEffects.test.ts Updates dual-scope expectations.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Updates Git refresh expectations.
src/​vs/​platform/​agentHost/​test/​node/​agentHostSyncOperationHandler.test.ts Supplies Git-state dependency.
src/​vs/​platform/​agentHost/​test/​node/​agentHostStateManager.test.ts Tests chat catalogue state.
src/​vs/​platform/​agentHost/​test/​node/​agentHostReviewService.test.ts Tests chat-owned review state.
src/​vs/​platform/​agentHost/​test/​node/​agentHostReviewService.integrationTest.ts Updates review-service setup.
src/​vs/​platform/​agentHost/​test/​node/​agentHostGitStateService.test.ts Tests isolated chat Git state.
src/​vs/​platform/​agentHost/​test/​node/​agentHostDiscardChangesOperationHandler.test.ts Tests post-discard refresh.
src/​vs/​platform/​agentHost/​test/​node/​agentHostChangesetService.test.ts Tests chat-scoped computations.
src/​vs/​platform/​agentHost/​test/​node/​agentHostChangesetOperationService.test.ts Tests chat operation filtering.
src/​vs/​platform/​agentHost/​test/​node/​agentHostChangesetCoordinator.test.ts Tests chat refresh coordination.
src/​vs/​platform/​agentHost/​test/​common/​changesetUri.test.ts Tests owner/session URI parsing.
src/​vs/​platform/​agentHost/​node/​chatContributions/​checkpointAndChangeset/​checkpointAndChangesetContribution.ts Publishes chat and aggregate changes.
src/​vs/​platform/​agentHost/​node/​agentSideEffects.ts Routes tool edits by chat.
src/​vs/​platform/​agentHost/​node/​agentService.ts Initializes chat changesets.
src/​vs/​platform/​agentHost/​node/​agentHostSyncOperationHandler.ts Syncs the owner repository.
src/​vs/​platform/​agentHost/​node/​agentHostStateManager.ts Stores chat catalogues.
src/​vs/​platform/​agentHost/​node/​agentHostReviewService.ts Separates chat review state.
src/​vs/​platform/​agentHost/​node/​agentHostGitStateService.ts Tracks per-chat Git state.
src/​vs/​platform/​agentHost/​node/​agentHostDiscardChangesOperationProvider.ts Refreshes after discard.
src/​vs/​platform/​agentHost/​node/​agentHostDiscardChangesOperationHandler.ts Discards in owner workspace.
src/​vs/​platform/​agentHost/​node/​agentHostCommitOperationHandler.ts Commits in owner repository.
src/​vs/​platform/​agentHost/​node/​agentHostCheckoutOperationHandler.ts Checks out in owner repository.
src/​vs/​platform/​agentHost/​node/​agentHostChangesetService.ts Computes chat-scoped changesets.
src/​vs/​platform/​agentHost/​node/​agentHostChangesetOperationService.ts Scopes and refreshes operations.
src/​vs/​platform/​agentHost/​node/​agentHostChangesetCoordinator.ts Coordinates chat lifecycle refreshes.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​version/​registry.ts Versions new chat actions.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​common/​actions.ts Registers chat actions.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-chat/​state.ts Adds chat catalogue state.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-chat/​reducer.ts Reduces new chat actions.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-chat/​actions.ts Defines new chat actions.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-changeset/​state.ts Documents chat ownership.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​action-origin.generated.ts Updates generated action origins.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​.ahp-version Updates protocol revision.
src/​vs/​platform/​agentHost/​common/​changesetUri.ts Separates owner and session URIs.
src/​vs/​platform/​agentHost/​common/​agentHostGitStateService.ts Exposes owner Git state.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sandy081
Sandeep Somavarapu (sandy081) force-pushed the sandy081/sessions-chat-changeset-ownership branch from 457285e to 8ca1b83 Compare September 22, 2026 22:48
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 2cd40986 Current: 41490349

Changed (34)

sessions/sessionChatInputToolbar/SessionChatPills_ChangesSingleFile/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ChangesSingleFile/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ChangesMultipleFiles/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ChangesMultipleFiles/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ChangesOnlyInsertions/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ChangesOnlyInsertions/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ChangesOnlyDeletions/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ChangesOnlyDeletions/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ExternalMarkdownPreview/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ExternalMarkdownPreview/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_WorkspaceMarkdown_NoPreview/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_WorkspaceMarkdown_NoPreview/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ExternalMarkdownMultiple_PrimaryCreated/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ExternalMarkdownMultiple_PrimaryCreated/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ExternalMarkdown_PrimaryEdited/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ExternalMarkdown_PrimaryEdited/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_CompletedSessionChanges/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_CompletedSessionChanges/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_BackgroundWithChanges/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_BackgroundWithChanges/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_Compact/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_Compact/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ResponsiveWide/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ResponsiveWide/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ResponsiveNarrow/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_ResponsiveNarrow/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_NotAgentHost_Hidden/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatPills_NotAgentHost_Hidden/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatView_ChangesPill/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatView_ChangesPill/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatView_ChangesAndExternalPreview/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatView_ChangesAndExternalPreview/Light
Before After
before after
sessions/sessionChatInputToolbar/SessionChatView_ReadOnlyPills/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatView_ReadOnlyPills/Light
Before After
before after

Publish independent changeset catalogues for each chat and route changes, Git state, repository operations, and review state through the owning chat workspace while preserving session-wide checkpoints, summaries, and mutation safety.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refresh chat and aggregate Git state concurrently, prevent session Git fallback for chats, evict removed-chat Git state, and preserve the legacy session catalogue fallback when chat catalogues are unavailable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Read focused changes, changesets, operations, review state, and status pills from the owning chat without falling back to aggregate session state. Preserve session-wide catalogues for lists, lifecycle reporting, telemetry, and draft-session repository preparation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make each chat the sole catalogue owner from draft creation onward while sessions retain only aggregate change summaries. Route chat-rooted subscriptions and operations through the containing session without duplicating selectable state.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Publish cumulative session changes separately from chat-owned changesets, scope picker visibility and ordering to the active chat, and keep last-turn changes accurate across peer chat databases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the final split between session-wide and chat-owned selectable changesets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Align session test doubles and catalogue expectations with the restored session-owned Session Changes entry.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Record the expected chat changeset catalogue notification in provider AHP traffic after restoring session-owned changesets.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081
Sandeep Somavarapu (sandy081) force-pushed the sandy081/sessions-chat-changeset-ownership branch from 15a99d8 to bb82077 Compare September 23, 2026 05:32
Share Branch Changes across chats that use the same folder while retaining checkpoint-based active-chat changes. Route Git operations, blob reads, reviews, summaries, and monitoring through the owning folder and preserve the Sessions changes UI behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Restore non-Git chat changes, folder-owned operation refreshes, stable summaries and catalogues, and multi-root review-ref lifecycle behavior. Keep changes pills and session workflow operations aligned with the active chat scope.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081 Sandeep Somavarapu (sandy081) changed the title agentHost: scope changesets to chats agentHost: scope changesets to chat working folders Sep 23, 2026
Keep coalesced full recomputes from inheriting incremental turn state, and distinguish non-Git scopes from transient Git failures so incomplete worktree summaries are not persisted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve restored peer state before computing chat changes and preserve compatibility with legacy session-owned changeset catalogues. Avoid duplicate operation refreshes and remove the obsolete Branch computation path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep Session Changes session-owned and project it into every chat while preserving chat-scoped repository and turn changesets. Remove the obsolete host-side Chat Changes production path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081
Sandeep Somavarapu (sandy081) marked this pull request as ready for review September 23, 2026 14:47
@vs-code-engineering

vs-code-engineering Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Kyle Cutler (@kycutler)

Matched files:

  • extensions/vscode-api-tests/src/singlefolder-tests/browser.tools.test.ts

Joaquín Ruales (@jruales)

Matched files:

  • extensions/vscode-api-tests/src/singlefolder-tests/browser.tools.test.ts

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/sessions/browser/parts/mobile/contributions/mobileChangesView.ts
  • src/vs/sessions/browser/parts/mobile/mobileTitlebarPart.ts
  • src/vs/sessions/contrib/layout/browser/singlePane/singlePaneExistingSessionStrategy.ts
  • src/vs/sessions/contrib/layout/test/browser/desktopSessionLayoutController.test.ts
  • src/vs/sessions/contrib/layout/test/browser/layoutControllerTestUtils.ts

Remove the unused session-level changeset publication and obsolete Chat Changes identity so every chat consumes the provider-projected Session Changes catalogue. Harden the affected cross-platform and asynchronous CI tests by using platform-native paths and waiting for the observable completion conditions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Component fixtures still mocked the removed session-level changes and changesets. Provide main-chat changes to session list fixtures and implement getChatChanges on agent feedback service mocks so the fixtures render again.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081
Sandeep Somavarapu (sandy081) merged commit a8c1541 into main Sep 23, 2026
33 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the sandy081/sessions-chat-changeset-ownership branch September 23, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants