Ladislau Szomoru d44e5ba3d7 Agents - add review/unreview operation to the multi-file diff editor (#324218)
* Review changes (P1): add overlayPathIntoTree git primitive

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>

* Review changes (P2): extract shared Branch Changes baseline resolver

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>

* Review changes (P3): add reviewed-ref review service core

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>

* Review changes (P4): wire the review operation handler + provider

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>

* Review changes (P5): surface per-file review status on the Branch changeset

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>

* Review changes (P6): copy the reviewed ref on session fork

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>

* More refactoring/cleanup

* More changes to get things working

* Fix the actions in the toolbar

* Collapse multi-file diff item that is reviewed

* Remove precondition

* Fix tests + pull request feedback

* Fix hygiene

* Skip integration tests for now

* Make the UI snappier

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-03 14:43:28 +00:00

Visual Studio Code - Open Source ("Code - OSS")

Feature Requests Bugs Gitter

The Repository

This repository ("Code - OSS") is where we (Microsoft) develop the Visual Studio Code product together with the community. Not only do we work on code and issues here, but we also publish our roadmap, monthly iteration plans, and our endgame plans. This source code is available to everyone under the standard MIT license.

Visual Studio Code

VS Code in action

Visual Studio Code is a distribution of the Code - OSS repository with Microsoft-specific customizations released under a traditional Microsoft product license.

Visual Studio Code combines the simplicity of a code editor with what developers need for their core edit-build-debug cycle. It provides comprehensive code editing, navigation, and understanding support along with lightweight debugging, a rich extensibility model, and lightweight integration with existing tools.

Visual Studio Code is updated monthly with new features and bug fixes. You can download it for Windows, macOS, and Linux on Visual Studio Code's website. To get the latest releases every day, install the Insiders build.

Contributing

There are many ways in which you can participate in this project, for example:

If you are interested in fixing issues and contributing directly to the code base, please see the document How to Contribute, which covers the following:

Feedback

See our wiki for a description of each of these channels and information on some other available community-driven channels.

Many of the core components and extensions to VS Code live in their own repositories on GitHub. For example, the node debug adapter and the mono debug adapter repositories are separate from each other. For a complete list, please visit the Related Projects page on our wiki.

Bundled Extensions

VS Code includes a set of built-in extensions located in the extensions folder, including grammars and snippets for many languages. Extensions that provide rich language support (inline suggestions, Go to Definition) for a language have the suffix language-features. For example, the json extension provides coloring for JSON and the json-language-features extension provides rich language support for JSON.

Development Container

This repository includes a Visual Studio Code Dev Containers / GitHub Codespaces development container.

  • For Dev Containers, use the Dev Containers: Clone Repository in Container Volume... command which creates a Docker volume for better disk I/O on macOS and Windows.

    • If you already have VS Code and Docker installed, you can also click here to get started. This will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.
  • For Codespaces, install the GitHub Codespaces extension in VS Code, and use the Codespaces: Create New Codespace command.

Docker / the Codespace should have at least 4 cores and 6 GB of RAM (8 GB recommended) to run a full build. See the development container README for more information.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT license.

Description
2025-08-20 10:13:53 -05:00
Languages
TypeScript 77.7%
jsonc 18%
CSS 1.4%
JavaScript 0.7%
C 0.7%
Other 1.2%