Agents window: commit customization changes through core git instead copilot extension commands by vijayupadya · Pull Request #343149 · microsoft/vscode · GitHub
Skip to content

Agents window: commit customization changes through core git instead copilot extension commands - #343149

Open
Vijay Upadya (vijayupadya) wants to merge 3 commits into
mainfrom
sound-seahorse
Open

Vijay Upadya (vijayupadya) wants to merge 3 commits into
mainfrom
sound-seahorse

Conversation

@vijayupadya

Copy link
Copy Markdown
Contributor

What

The Agents window commits customization saves and deletions to the repository and the session worktree. Until now it did this by running github.copilot.cli.sessions.commitToRepository and github.copilot.cli.sessions.commitToWorktree, which are registered only by the legacy Copilot CLI session provider in extensions/copilot. Removing that provider would make every customization save or delete in a worktree session fail with "command not found".

This PR moves the git stage and commit into core, using the built-in git extension through IGitService, and fixes two bugs in the Customizations editor that stopped commits from happening in the Agents window.

Changes

  • Core git: IGitRepository.commitFiles(files, message, options?) stages files, including deletions, and commits. It is plumbed through IGitExtensionDelegate, MainThreadGitExtensionService, a new $commitFiles RPC and ExtHostGitExtensionService. Nothing to commit and not-a-git-repository resolve as no-ops. The extension host does this check because git error codes don't survive the RPC.
  • SessionsAICustomizationWorkspaceService: calls IGitService.openRepository(...).commitFiles(...) with { noVerify: true, signCommit: false } and the same commit message as before. A failed repo or worktree commit now shows a notification in every case, where before only some failures did.
  • Delete from the list did not commit: the list passes source in the action context, but the delete action read context.storage, so deleteFiles never ran. This has been broken since add ChatSessionCustomizationItem.source, clean up AICustomizationPromptsStorage #317555 renamed the field in the list widget. The action now reads source ?? storage. This also makes the plugin and built-in guards in that action work when invoked from the list.
  • Save did not commit: the Agents window defaults files.autoSave to afterDelay. Auto Save clears the dirty flag, so the editor's commit-on-exit never ran. Ctrl+S also never reached the file, because the management editor's save handler only handled built-in overrides.
    • A pending-commit flag is now tracked separately from the dirty state.
    • Ctrl+S saves and commits local customizations.
    • Commits are serialized so an explicit save and leaving the editor don't race.
    • Auto Save itself never commits.

Behavior notes

  • The legacy commitToWorktree also cleared worktree-change caches and refreshed the legacy session. That only applied to legacy copilotcli: sessions, so it is not carried over.
  • The old extension commands are untouched. They will be eventually removed with the legacy provider later

How to test

Launch with scripts\code.bat --agents <git-repo-folder> and start a worktree-isolated session on a repo. Check commits with git log --stat in both the repo and the worktree.

  1. Auto Save: edit an instruction, wait about 2 seconds, then Back to List. Expect one Update customization: <file> commit in each tree.
  2. Ctrl+S: edit, press Ctrl+S, then Back to List. Expect one commit per tree. Edit again before leaving to get a second commit.
  3. Delete: delete a customization from the list's context menu. Expect a removal commit in each tree. This works for instructions and for skills, which delete their folder.
  4. No-op: save without changing anything. Expect no commit and no error.
  5. Not a git repo: save in a plain folder. Expect the file to be written and no error.
  6. Hooks and signing: with a failing pre-commit hook and commit.gpgsign=true, the commit still succeeds.
  7. Failure: create .git/index.lock in the main repo. Expect the "couldn't apply it to the default branch" warning, and the worktree commit still succeeds.
  8. No Copilot extension: repeat 1 to 3 with --disable-extension GitHub.copilot-chat to confirm the old commands are not needed.

Unit tests are in aiCustomizationWorkspaceService.test.ts. They cover save and delete to repo and worktree, non-git folders, and the warning on a failed repo commit. I haven't added a test for the editor changes, because the existing management editor test harness doesn't stub the working-copy or commit services. They were checked manually with the scenarios above.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 07:06

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Moves Agents window customization commits off legacy Copilot CLI session-provider commands and into core git plumbing via IGitService, while fixing editor/list issues that prevented commits from triggering in common workflows (auto-save, Ctrl+S, delete).

Changes:

  • Add IGitRepository.commitFiles(...) and wire it through the git delegate + RPC boundary (main thread ↔ ext host).
  • Update customization workspace service to stage+commit via core git and improve failure notifications.
  • Fix customization management UI commit triggers: correct delete context source, add explicit save handling, and serialize commits.
File Description
src/​vs/​workbench/​contrib/​git/​common/​gitService.ts Introduces GitCommitOptions and new commitFiles API on repositories/delegate.
src/​vs/​workbench/​contrib/​git/​browser/​gitService.ts Implements commitFiles on the browser-side GitRepository wrapper.
src/​vs/​workbench/​contrib/​chat/​browser/​aiCustomization/​aiCustomizationManagementEditor.ts Fixes save/commit triggering for auto-save and Ctrl+S; serializes commits.
src/​vs/​workbench/​contrib/​chat/​browser/​aiCustomization/​aiCustomizationManagement.contribution.ts Fixes delete action context by reading source ?? storage.
src/​vs/​workbench/​api/​common/​extHostGitExtensionService.ts Adds $commitFiles implementation that stages and commits via the built-in git extension API.
src/​vs/​workbench/​api/​common/​extHost.protocol.ts Adds GitCommitOptionsDto and the $commitFiles RPC definition.
src/​vs/​workbench/​api/​browser/​mainThreadGitExtensionService.ts Plumbs commitFiles through main thread delegate to the ext host RPC.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​aiCustomizationWorkspaceService.test.ts Adds unit tests for committing saved/deleted customizations to repo + worktree and notifications.
src/​vs/​sessions/​contrib/​chat/​browser/​aiCustomizationWorkspaceService.ts Replaces legacy Copilot commands with IGitService.openRepository(...).commitFiles(...) and improves notifications.

Review effort: Lite

Comment thread src/vs/workbench/api/common/extHostGitExtensionService.ts

This branch has not been deployed

No deployments
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.

2 participants