agentHostCommitOperationHandler.ts ×10

Frontier kind: Code frontier

unlabeled · c_fa4a0ce750f9

490 tests · 23256 LOC · 102 files · introduces 0 tests · 44 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges44 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1917 ranges23256 lines · 102 files · Browse complete extent
All tests (intent)
490 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 44 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostCommitOperationHandler.ts 44 introduced LOC · 10 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentHostCommitOperationHandler.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { basename } from '../../../base/common/resources.js';
7 > import { CancellationToken } from '../../../base/common/cancellation.js';
8 > import { URI } from '../../../base/common/uri.js';
9 > import { localize } from '../../../nls.js';
10 > import { IAgentService } from '../common/agentService.js';
11 > import { IAgentHostGitHubEndpointService } from './agentHostGitHubEndpointService.js';
12 > import { parseChangesetUri } from '../common/changesetUri.js';
13 > import { type IChangesetOperationHandler } from '../common/agentHostChangesetOperationService.js';
14 > import type { InvokeChangesetOperationParams, InvokeChangesetOperationResult } from '../common/state/protocol/channels-changeset/commands.js';
15 > import { AHP_AUTH_REQUIRED, AHP_SESSION_NOT_FOUND, JsonRpcErrorCodes, ProtocolError } from '../common/state/sessionProtocol.js';
16 > import { readSessionGitState, type ISessionFileDiff, type SessionState } from '../common/state/sessionState.js';
17 > import { ILogService } from '../../log/common/log.js';
18 > import { IAgentHostGitService } from '../common/agentHostGitService.js';
19 > import { CopilotApiError, ICopilotApiService } from './shared/copilotApiService.js';
20 >
21 > const MAX_CHANGE_SUMMARY_PROMPT_CHARS = 20_000;
22 >
23 > export class AgentHostCommitOperationHandler implements IChangesetOperationHandler {
24 >
25 > public static readonly OPERATION_COMMIT = 'commit';
26 >
27 > constructor(
28 private readonly _getSessionState: (sessionKey: string) => SessionState | undefined,
29 private readonly _onCommitted: (sessionKey: string) => Promise<void>,
34 @ILogService private readonly _logService: ILogService,
35 ) { }
37 > async invoke(params: InvokeChangesetOperationParams, token: CancellationToken): Promise<InvokeChangesetOperationResult> {
38 const abortController = new AbortController();
39 if (token.isCancellationRequested) {
47 }
48 }
50 > private async _invoke(params: InvokeChangesetOperationParams, token: CancellationToken, signal: AbortSignal): Promise<InvokeChangesetOperationResult> {
51 const parsed = parseChangesetUri(params.channel);
52 if (!parsed) {
134 return { message: { markdown: localize('agentHost.changeset.commit.committed', "Committed changes with message: `{0}`", message.split('\n')[0]) } };
135 }
137 > private _buildCommitMessagePrompt(workingDirectory: URI, branchName: string | undefined, diffs: readonly ISessionFileDiff[]): { role: 'system' | 'user'; content: string }[] {
138 const changeSummary = this._summarizeDiffsForPrompt(diffs);
139 return [
158 ];
159 }
161 > private _summarizeDiffsForPrompt(diffs: readonly ISessionFileDiff[]): string {
162 const lines: string[] = [];
163 for (const diff of diffs) {
181 return lines.join('\n');
182 }
184 > private _displayUri(uri: string): string {
185 try {
186 const parsed = URI.parse(uri);
190 }
191 }
193 > private _cleanCommitMessage(raw: string): string {
194 let text = raw.trim().replace(/\r\n/g, '\n');
195 const fenced = /^```(?:text|gitcommit)?\s*([\s\S]*?)\s*```$/i.exec(text);
199 return text;
200 }
202 > private _isAuthFailure(err: unknown): boolean {
203 if (err instanceof CopilotApiError) {
204 return err.status === 401 || err.status === 403;
208 && /\b(auth|authorization|unauthorized|forbidden|token|copilot endpoint discovery|copilot session token mint)\b/i.test(message);
209 }
211 > private _throwIfCancelled(token: CancellationToken): void {
212 if (token.isCancellationRequested) {
213 throw new ProtocolError(JsonRpcErrorCodes.InternalError, localize('agentHost.changeset.commit.cancelled', "Commit operation was cancelled."));
214 }
215 }