agentHostRepoInfoTelemetry.ts ×13

Frontier kind: Code frontier

unlabeled · c_0bf91d6380ae

417 tests · 20633 LOC · 78 files · introduces 0 tests · 77 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges77 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1673 ranges20633 lines · 78 files · Browse complete extent
All tests (intent)
417 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: 77 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostRepoInfoTelemetry.ts 77 introduced LOC · 13 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentHostRepoInfoTelemetry.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 { Limiter } from '../../../base/common/async.js';
7 > import { Disposable } from '../../../base/common/lifecycle.js';
8 > import { relativePath } from '../../../base/common/resources.js';
9 > import { URI } from '../../../base/common/uri.js';
10 > import { ILogService } from '../../log/common/log.js';
11 > import { IAgentHostGitService } from '../common/agentHostGitService.js';
12 > import type { ISessionFileDiff } from '../common/state/sessionState.js';
13 > import { IAgentHostGitHubEndpointService } from './agentHostGitHubEndpointService.js';
14 > import type { AgentHostRepoInfoResult, AgentHostTelemetryReporter } from './agentHostTelemetryReporter.js';
15 > import type { IAgentHostRestrictedTelemetryContext } from './agentHostRestrictedTelemetry.js';
16 >
17 > const MAX_DIFFS_JSON_BYTES = 900 * 1024;
18 > const MAX_DIFFS_JSON_CHARS = 50 * 8192;
19 > const MAX_CHANGES = 100;
20 > const MAX_MERGE_BASE_AGE_MS = 30 * 24 * 60 * 60 * 1000;
21 > const MAX_DIFF_COMMITS = 30;
22 > const DIFF_PATCH_CONCURRENCY = 4;
23 > const MAX_DIFF_SIZE = 100_000;
24 >
25 > interface IRepoInfoContext extends IResolvedRepoInfoRemote {
26 > readonly headCommitHash: string;
27 > readonly headBranchName: string | undefined;
28 > }
29 >
30 > interface IRepoInfoFileDescriptor {
31 > readonly uri: string;
32 > readonly originalUri: string;
33 > readonly renameUri: string | undefined;
34 > readonly status: 'INDEX_ADDED' | 'MODIFIED' | 'DELETED' | 'INDEX_RENAMED' | 'UNTRACKED';
35 > readonly oldPath: string | undefined;
36 > readonly newPath: string | undefined;
37 > }
38 >
39 > type RepoInfoTelemetryReporter = Pick<AgentHostTelemetryReporter, 'reportRepoInfo'>;
40 >
41 > export interface IResolvedRepoInfoRemote {
42 > readonly remoteUrl: string;
43 > readonly repoId: string;
44 > readonly repoType: 'github' | 'ado';
45 > }
46 >
47 > /** Resolves a GitHub, GitHub Enterprise, or Azure DevOps fetch URL. */
48 > export function resolveRepoInfoRemote(remoteUrl: string, enterpriseHost: string | undefined): IResolvedRepoInfoRemote | undefined {
49 const scpMatch = remoteUrl.includes('://') ? undefined : /^(?:[^@\s]+@)?(?<host>[^:\s]+):(?<path>.+)$/.exec(remoteUrl);
50 let host: string;
103 };
104 }
106 > /** Measures a serialized diff payload using the two limits applied by the legacy extension. */
107 > export function measureRepoInfoDiffsJSON(diffsJSON: string): { readonly diffSizeBytes: number; readonly tooLarge: boolean } {
108 const diffSizeBytes = Buffer.byteLength(diffsJSON, 'utf8');
109 return {
112 };
113 }
115 > export class AgentHostRepoInfoTelemetry extends Disposable {
116 > private readonly _beginResults = new Map<string, Promise<AgentHostRepoInfoResult | undefined>>();
117 > private _isDisposed = false;
118 >
119 > constructor(
120 private readonly _reporter: RepoInfoTelemetryReporter,
121 @IAgentHostGitService private readonly _gitService: IAgentHostGitService,
125 super();
126 }
128 > async reportBegin(context: IAgentHostRestrictedTelemetryContext, sessionUri: string, telemetryMessageId: string, workingDirectory: URI | undefined, baseBranch: string | undefined, isContextCurrent: () => boolean): Promise<void> {
129 let result = this._beginResults.get(telemetryMessageId);
130 if (!result) {
134 await result;
135 }
137 > async reportEnd(context: IAgentHostRestrictedTelemetryContext, sessionUri: string, telemetryMessageId: string, workingDirectory: URI | undefined, baseBranch: string | undefined, isContextCurrent: () => boolean): Promise<void> {
138 const begin = this._beginResults.get(telemetryMessageId);
139 if (!begin) {
149 }
150 }
152 > clearTurn(telemetryMessageId: string): void {
153 this._beginResults.delete(telemetryMessageId);
154 }
156 > override dispose(): void {
157 this._isDisposed = true;
158 this._beginResults.clear();
159 super.dispose();
160 }
162 > private async _captureSafely(context: IAgentHostRestrictedTelemetryContext, sessionUri: string, telemetryMessageId: string, location: 'begin' | 'end', workingDirectory: URI | undefined, baseBranch: string | undefined, isContextCurrent: () => boolean): Promise<AgentHostRepoInfoResult | undefined> {
163 try {
164 return await this._capture(context, sessionUri, telemetryMessageId, location, workingDirectory, baseBranch, isContextCurrent);
168 }
169 }
171 > private async _capture(telemetryContext: IAgentHostRestrictedTelemetryContext, sessionUri: string, telemetryMessageId: string, location: 'begin' | 'end', workingDirectory: URI | undefined, persistedBaseBranch: string | undefined, isContextCurrent: () => boolean): Promise<AgentHostRepoInfoResult | undefined> {
172 if (!workingDirectory || !isContextCurrent() || (!telemetryContext.restrictedTelemetryEnabled && !telemetryContext.isInternal)) {
173 return undefined;
273 return await this._reportIfTreeUnchanged(telemetryContext, isContextCurrent, telemetryMessageId, location, repoInfo, workingDirectory, tree, 'success', safety.workspaceFileCount, fileDiffs.length, measurement.diffSizeBytes, fileRelativePaths, diffsJSON);
274 }
276 > private async _reportIfTreeUnchanged(telemetryContext: IAgentHostRestrictedTelemetryContext, isContextCurrent: () => boolean, telemetryMessageId: string, location: 'begin' | 'end', repoInfo: IRepoInfoContext, workingDirectory: URI, capturedTree: string, stableResult: 'success' | 'noChanges' | 'diffTooLarge', workspaceFileCount: number, changedFileCount: number, diffSizeBytes: number, fileRelativePaths?: string, diffsJSON?: string): Promise<AgentHostRepoInfoResult> {
277 const currentTree = await this._gitService.captureWorkingTreeAsTree(workingDirectory);
278 if (!currentTree || currentTree !== capturedTree) {
281 return this._report(telemetryContext, isContextCurrent, telemetryMessageId, location, repoInfo, stableResult, workspaceFileCount, changedFileCount, diffSizeBytes, fileRelativePaths, diffsJSON);
282 }
284 > private _describeFileDiff(repositoryRoot: URI, diff: ISessionFileDiff, untrackedPaths: ReadonlySet<string>): IRepoInfoFileDescriptor | undefined {
285 const beforeUri = diff.before?.uri;
286 const afterUri = diff.after?.uri;
310 };
311 }
313 > private _report(telemetryContext: IAgentHostRestrictedTelemetryContext, isContextCurrent: () => boolean, telemetryMessageId: string, location: 'begin' | 'end', repoInfo: IRepoInfoContext, result: AgentHostRepoInfoResult, workspaceFileCount: number, changedFileCount: number, diffSizeBytes: number, fileRelativePaths?: string, diffsJSON?: string): AgentHostRepoInfoResult {
314 if (this._isDisposed || !isContextCurrent()) {
315 return result;
333 return result;
334 }
336 >
337 function truncateRepoInfoDiff(diff: string, uri: string): string {
338 if (diff.length <= MAX_DIFF_SIZE) {