Agents - add review/unreview operation to the multi-file diff editor#324218
Merged
Conversation
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>
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @sandy081Matched files:
|
Contributor
There was a problem hiding this comment.
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 newIAgentHostGitServiceprimitives (overlayPathIntoTree,diffTreePaths,resolveBranchBaselineCommit), with fork ref copying and reviewed-ref cleanup on session disposal. - Plumb
reviewedstatus through the changeset service into UI file-change types, and add the review/unreview file-toolbar menu items within/notIncontext-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
benibenj
previously approved these changes
Jul 3, 2026
benibenj
previously approved these changes
Jul 3, 2026
benibenj
previously approved these changes
Jul 3, 2026
benibenj
approved these changes
Jul 3, 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.
No description provided.