Skip to content

feat: implement GitHub pull request operations in agent host#318256

Draft
DonJayamanne wants to merge 5 commits into
mainfrom
don/pr-changeset-action
Draft

feat: implement GitHub pull request operations in agent host#318256
DonJayamanne wants to merge 5 commits into
mainfrom
don/pr-changeset-action

Conversation

@DonJayamanne
Copy link
Copy Markdown
Contributor

@DonJayamanne DonJayamanne commented May 25, 2026

Fixes #317113

  • Refactor ProtocolServerHandler to delegate changeset operations to the agent service.
  • Introduce AgentHostOctoKitService for minimal GitHub REST client functionality.
  • Add tests for AgentHostPullRequestOperationHandler to ensure correct behavior for creating and managing pull requests.
  • Enhance session test helpers to support new Git operations.
  • Update logging and connection handling to include changeset operation invocation.
  • Ensure proper handling of GitHub API responses and error cases in tests.

- Refactor ProtocolServerHandler to delegate changeset operations to the agent service.
- Introduce AgentHostOctoKitService for minimal GitHub REST client functionality.
- Add tests for AgentHostPullRequestOperationHandler to ensure correct behavior for creating and managing pull requests.
- Enhance session test helpers to support new Git operations.
- Update logging and connection handling to include changeset operation invocation.
- Ensure proper handling of GitHub API responses and error cases in tests.
@DonJayamanne DonJayamanne force-pushed the don/pr-changeset-action branch from f0f41a8 to f5692fd Compare May 26, 2026 00:04
@DonJayamanne DonJayamanne changed the base branch from don/proposed-mite to main May 26, 2026 00:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 end-to-end support for invoking GitHub pull request–related “changeset operations” from the agent host, including a minimal GitHub REST client, git plumbing for committing/pushing, and operation contribution/handler wiring so the protocol server can delegate operation execution to the agent service.

Changes:

  • Route invokeChangesetOperation through AgentService and introduce a contribution/handler registry for changeset operations.
  • Add a minimal agent-host GitHub REST client (AgentHostOctoKitService) plus PR operation contribution/handler to create/reuse PRs.
  • Extend agent-host git service with commitAll, hasUpstream, and pushBranch, and add focused unit tests for the new behavior.
Show a summary per file
File Description
src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts Exposes invokeChangesetOperation on the workbench-side agent host service client.
src/vs/workbench/contrib/terminal/test/browser/agentHostPty.test.ts Updates terminal agent-host mock to include the new invokeChangesetOperation API.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/loggingAgentConnection.ts Logs calls/results for invokeChangesetOperation through the logging wrapper.
src/vs/platform/agentHost/test/node/shared/agentHostOctoKitService.test.ts Adds unit tests for the minimal GitHub REST client behavior/error handling.
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts Updates protocol server handler test mocks for new IAgentService surface.
src/vs/platform/agentHost/test/node/copilotGitProject.test.ts Updates git service test double with new git methods.
src/vs/platform/agentHost/test/node/copilotAgent.test.ts Updates git service test double with new git methods.
src/vs/platform/agentHost/test/node/agentService.test.ts Adds coverage for storing/retrieving the GitHub repo token via AgentService.
src/vs/platform/agentHost/test/node/agentHostPullRequestOperationProvider.test.ts Tests PR operation advertisement/hiding logic for GitHub-backed sessions.
src/vs/platform/agentHost/test/node/agentHostPullRequestOperationHandler.test.ts Tests PR operation handler flow: commit, push, reuse/create PR, cancellation, and error recovery.
src/vs/platform/agentHost/test/common/sessionTestHelpers.ts Extends noop git service helper with new git methods.
src/vs/platform/agentHost/node/shared/agentHostOctoKitService.ts Introduces minimal GitHub REST client for PR creation/lookup in agent host.
src/vs/platform/agentHost/node/protocolServerHandler.ts Delegates invokeChangesetOperation to AgentService instead of inline validation/no-handler error.
src/vs/platform/agentHost/node/agentService.ts Adds auth token cache + changeset operation contribution service + git-state service integration.
src/vs/platform/agentHost/node/agentHostSessionGitStateService.ts Extracts git-state attach/refresh + changeset catalogue decoration into a dedicated service.
src/vs/platform/agentHost/node/agentHostServerMain.ts Registers IAgentService in the agent-host server DI collection.
src/vs/platform/agentHost/node/agentHostPullRequestOperationProvider.ts Adds PR operation contribution: advertises “Create PR” operations and hides them optimistically after creation.
src/vs/platform/agentHost/node/agentHostPullRequestOperationHandler.ts Implements server-side PR creation handler: commit, push, find existing PR, create PR, return follow-up.
src/vs/platform/agentHost/node/agentHostMain.ts Registers IAgentService in the main agent-host DI collection.
src/vs/platform/agentHost/node/agentHostGitService.ts Adds commitAll, hasUpstream, and pushBranch to support PR creation workflow.
src/vs/platform/agentHost/node/agentHostChangesetOperationContributionService.ts New service managing contributions + operation handler registration + invocation validation/dispatch.
src/vs/platform/agentHost/node/agentHostChangesetOperationContributions.ts Registers default operation contributions (currently PR operations).
src/vs/platform/agentHost/electron-browser/localAgentHostService.ts Adds invokeChangesetOperation to the local IPC proxy client.
src/vs/platform/agentHost/common/changesetOperation.ts Defines common interfaces for operation contributions/handlers/registry/service.
src/vs/platform/agentHost/common/agentService.ts Adds GITHUB_REPO_PROTECTED_RESOURCE, getAuthToken, and invokeChangesetOperation to the shared API.
src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts Adds the JSON-RPC request plumbing for invokeChangesetOperation.
src/vs/platform/agentHost/browser/nullAgentHostService.ts Adds a not-supported stub for invokeChangesetOperation.

Copilot's findings

  • Files reviewed: 27/27 changed files
  • Comments generated: 2

* handlers) that need bearer tokens for resources not tied to a
* specific agent — typically {@link GITHUB_REPO_PROTECTED_RESOURCE}.
*/
getAuthToken(resource: string): string | undefined;
Copy link
Copy Markdown
Contributor Author

@DonJayamanne DonJayamanne May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auth token changes.

@DonJayamanne DonJayamanne marked this pull request as ready for review May 26, 2026 00:42
@DonJayamanne DonJayamanne marked this pull request as draft May 26, 2026 10:54
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.

Support Create PR Operations in Chagesets and Changes View of Agent Window

2 participants