Skip to content

Agents - add review/unreview operation to the multi-file diff editor#324218

Merged
lszomoru merged 16 commits into
mainfrom
lszomoru/agent-host-review-changes-feature
Jul 3, 2026
Merged

Agents - add review/unreview operation to the multi-file diff editor#324218
lszomoru merged 16 commits into
mainfrom
lszomoru/agent-host-review-changes-feature

Conversation

@lszomoru

@lszomoru lszomoru commented Jul 3, 2026

Copy link
Copy Markdown
Member

No description provided.

lszomoru and others added 11 commits July 3, 2026 09:26
Add `IAgentHostGitService.overlayPathIntoTree(base, path, source)` which
builds a new tree equal to `base` with a single repo-relative path replaced
by (or removed to match) the content in `source`, using a throwaway
GIT_INDEX_FILE so the user's real index is untouched.

This is the file-level building block for the upcoming reviewed-ref based
"review changes" feature: mark reviewed = overlay from the working-tree
snapshot; unmark = overlay from the baseline tree.

Includes the `parseSingleLsTreeEntry` helper and real-git integration tests
covering modified, added, and removed paths, plus the non-git no-op case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extract the Branch Changes baseline resolution so the changeset service and
the upcoming review service cannot drift on which baseline they use:

- Add `IAgentHostGitService.resolveBranchBaselineCommit(workingDirectory,
  baseBranch?)` which resolves the merge-base commit-ish the Branch Changes
  diff is anchored on (origin/<base> preference, HEAD fallback, empty-tree
  fallback). `computeSessionFileDiffs` now delegates to the same private
  `_resolveBranchMergeBaseCommit` helper -- pure refactor, no behavior change.
- Add the pure `resolveDiffBaseBranchName(persisted, gitState)` helper for the
  base-branch-name precedence and use it from the changeset service.

Adds unit tests for both pure helpers and real-git integration tests for
`resolveBranchBaselineCommit`; existing `computeSessionFileDiffs` tests still
pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add `IAgentHostReviewService` and its node implementation, tracking which
files in a session's Branch Changes the user has reviewed as a session-private
synthetic git ref (`refs/agents/<sid>/reviewed`) whose tree snapshots the
reviewed content.

- `markFileReviewed` overlays the file's current working-tree content into the
  reviewed tree; `unmarkFileReviewed` resets it to the baseline content. Each
  action appends a parent-chained commit (first parent = baseline commit) and
  advances the ref; no-op mutations are skipped so the chain doesn't grow.
- `getReviewedPaths` derives review status from git trees: reviewed = Branch
  Changes files whose reviewed-tree content matches the working tree. Editing a
  reviewed file therefore auto-unreviews it.
- Mutations/reads are serialized per session; the reviewed ref is deleted on
  session data disposal. Operations no-op when not in a git work tree (a future
  milestone adds the non-git DB fallback).

Also adds the `diffTreePaths` git primitive used to compute review status, and
wires the service into the agent-host node and server entry points. Covered by
real-git integration tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add `AgentHostReviewFileOperationHandler` (mark/unmark, one instance per
direction) and `AgentHostReviewOperationContribution`, advertising the
`mark-as-reviewed` / `mark-as-unreviewed` resource-scoped operations for the
Branch Changes changeset and delegating to `IAgentHostReviewService`.

The handler resolves the session's working directory and base branch (via the
shared `resolveDiffBaseBranchName`) so review status is keyed on the same
baseline the Branch Changes diff uses.

Plumb the review service into `AgentService`'s inner DI (mirroring the
checkpoint service, defaulting to `NULL_REVIEW_SERVICE`) and register the
contribution. Covered by handler unit tests using a fake review service.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ngeset

Populate `ChangesetFile._meta.reviewed` for the Branch Changes changeset so the
client can render reviewed/unreviewed affordances per file:

- Inject `IAgentHostReviewService` into the changeset service and, when
  publishing the Branch changeset, look up the reviewed repo-relative paths and
  set `_meta.reviewed` per file (keyed by the file id's repo-relative path).
- Extract the base-branch resolution into a shared `_resolveBranchBaseBranch`
  helper reused by the diff computation and the review-status lookup.
- After a mark/unmark, the operation handler triggers `refreshBranchChangeset`
  so the updated `_meta.reviewed` is republished (the working tree is unchanged
  by a review toggle, so no file-watcher event would otherwise fire).

Adds a reusable `createNoopChangesetService` test helper, updates the handler
test to assert the refresh, and threads the new dependency through existing
agent-host test fakes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add `IAgentHostReviewService.copyReviewedRef(source, target, workingDirectory)`
which points the forked session's reviewed ref at the same commit as the
source's, so a fork starts with the parent's review progress. No-op when the
source has no reviewed ref or the directory is not a git work tree.

Wire it into the Copilot session-fork path (best-effort, after the forked
session's database is copied), and inject the review service into CopilotAgent.
Covered by a real-git integration test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 3, 2026 12:58
@lszomoru
lszomoru enabled auto-merge (squash) July 3, 2026 12:58
@lszomoru lszomoru self-assigned this Jul 3, 2026
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

@sandy081

Matched files:

  • src/vs/sessions/services/sessions/common/session.ts

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.

Pull request overview

This PR adds a per-file Mark as Reviewed / Mark as Unreviewed operation to the Agents-window multi-file diff editor for the Branch Changes changeset. Reviewed state is modeled server-side in the agent host as a session-private synthetic git ref (refs/agents/<sid>/reviewed) whose tree snapshots the reviewed content; a file counts as reviewed when its reviewed-tree content matches the current working tree (so re-editing a reviewed file auto-unreviews it). The per-file review status flows through the changeset _meta bag into IChatSessionFileChange and drives toolbar toggling in the multi-diff editor.

Changes:

  • New IAgentHostReviewService (+ node impl, operation handler, and operation provider) backed by new IAgentHostGitService primitives (overlayPathIntoTree, diffTreePaths, resolveBranchBaselineCommit), with fork ref copying and reviewed-ref cleanup on session disposal.
  • Plumb reviewed status through the changeset service into UI file-change types, and add the review/unreview file-toolbar menu items with in/notIn context-key toggling plus auto-collapse of a file on review.
  • Extensive new unit/integration tests and null-service fixtures across existing agent-host tests.
Show a summary per file
File Description
common/agentHostReviewService.ts New service interface, ref-name helper, and NULL_REVIEW_SERVICE (doc comment references a non-existent param).
node/agentHostReviewService.ts Reviewed-ref based implementation of mark/unmark/read/copy/dispose.
node/agentHostReviewFileOperationHandler.ts / agentHostReviewOperationProvider.ts Changeset operation handler + contribution for Branch changeset.
node/agentHostGitService.ts / common/agentHostGitService.ts New git primitives and shared resolveDiffBaseBranchName/baseline resolution.
node/agentHostChangesetService.ts Computes and publishes per-file reviewed status for Branch changeset.
node/agentService.ts / node/copilot/copilotAgent.ts / agentHostMain.ts / agentHostServerMain.ts Wire up review service; copy reviewed ref on fork.
common/meta/agentChangesetFileMeta.ts / chat/common/chatSessionsService.ts / sessions/.../session.ts Surface reviewed in file-change types and equality.
sessions/contrib/changes/browser/* Context keys, resolver context keys, toolbar toggling, collapse-on-review, hide review ops in tree.
editor/.../multiDiffEditorViewModel.ts / diffEditorItemTemplate.ts / style.css collapse/expand API, highlightToggledItems, action gap.
test/node/agentHostReviewFileOperationHandler.test.ts New handler tests (assertion key mismatch causes failures).
test/node/agentHostReviewService.integrationTest.ts / agentHostGitService*.test.ts / others New tests and null-fixture updates.

Review details

  • Files reviewed: 33/33 changed files
  • Comments generated: 4
  • Review effort level: Medium

Comment thread src/vs/platform/agentHost/test/node/agentHostReviewFileOperationHandler.test.ts Outdated
Comment thread src/vs/platform/agentHost/test/node/agentHostReviewFileOperationHandler.test.ts Outdated
Comment thread src/vs/sessions/contrib/providers/agentHost/browser/agentHostDiffs.ts Outdated
Comment thread src/vs/platform/agentHost/common/agentHostReviewService.ts
benibenj
benibenj previously approved these changes Jul 3, 2026
benibenj
benibenj previously approved these changes Jul 3, 2026
benibenj
benibenj previously approved these changes Jul 3, 2026
@lszomoru
lszomoru merged commit d44e5ba into main Jul 3, 2026
29 checks passed
@lszomoru
lszomoru deleted the lszomoru/agent-host-review-changes-feature branch July 3, 2026 14:43
@vs-code-engineering vs-code-engineering Bot added this to the 1.128.0 milestone Jul 3, 2026
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