agentHostRepoInfoTelemetry.ts ×11

Frontier kind: Code frontier

unlabeled · c_b11a1b132eb7

7 tests · 21010 LOC · 80 files · introduces 0 tests · 28 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges28 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1775 ranges21010 lines · 80 files · Browse complete extent
All tests (intent)
7 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: 28 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostRepoInfoTelemetry.ts 28 introduced LOC · 11 ranges

Open complete file

127
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); agentHostRepoInfoTelemetry.ts
130 > if (!result) {
131 > result = this._captureSafely(context, sessionUri, telemetryMessageId, 'begin', workingDirectory, baseBranch, isContextCurrent);
132 > this._beginResults.set(telemetryMessageId, result);
133 > }
134 > await result;
135 > }
136
137 async reportEnd(context: IAgentHostRestrictedTelemetryContext, sessionUri: string, telemetryMessageId: string, workingDirectory: URI | undefined, baseBranch: string | undefined, isContextCurrent: () => boolean): Promise<void> {
161
162 private async _captureSafely(context: IAgentHostRestrictedTelemetryContext, sessionUri: string, telemetryMessageId: string, location: 'begin' | 'end', workingDirectory: URI | undefined, baseBranch: string | undefined, isContextCurrent: () => boolean): Promise<AgentHostRepoInfoResult | undefined> {
164 > return await this._capture(context, sessionUri, telemetryMessageId, location, workingDirectory, baseBranch, isContextCurrent);
165 > } catch (error) {
166 this._logService.warn(`[AgentHostRepoInfoTelemetry] Failed to capture ${location} repo info: ${error instanceof Error ? error.message : String(error)}`);
167 return undefined;
168 }
170
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)) { agentHostRepoInfoTelemetry.ts
173 return undefined;
174 }
178 this._gitService.getUntrackedPaths(workingDirectory),
179 ]);
180 > const upstreamRemote = gitState?.upstreamBranchName?.split('/')[0]; agentHostRepoInfoTelemetry.ts
181 > const fetchRemoteUrls = await this._gitService.getFetchRemoteUrls(workingDirectory, upstreamRemote);
182 const remote = fetchRemoteUrls
183 > ?.map(url => resolveRepoInfoRemote(url, this._gitHubEndpointService.getEnterpriseHost())) agentHostRepoInfoTelemetry.ts
184 > .find((candidate): candidate is IResolvedRepoInfoRemote => candidate !== undefined);
185 > if (!remote) {
186 return undefined;
187 }
188
189 > const baseBranch = persistedBaseBranch ?? gitState?.upstreamBranchName ?? gitState?.baseBranchName ?? (await this._gitService.getDefaultBranch(workingDirectory))?.name; agentHostRepoInfoTelemetry.ts
190 > const [headBranchName, headCommitHash] = await Promise.all([
191 > gitState?.branchName ? Promise.resolve(gitState.branchName) : this._gitService.getCurrentBranch(workingDirectory),
192 > this._gitService.resolveBranchBaselineCommit(workingDirectory, baseBranch),
193 > ]);
194 if (!headCommitHash) {
195 return undefined;
203 return this._report(telemetryContext, isContextCurrent, telemetryMessageId, location, repoInfo, 'virtualFileSystem', 0, 0, 0);
204 }
205 > if (safety.baselineCommitTimestamp === undefined || Date.now() - safety.baselineCommitTimestamp > MAX_MERGE_BASE_AGE_MS) { agentHostRepoInfoTelemetry.ts
206 return this._report(telemetryContext, isContextCurrent, telemetryMessageId, location, repoInfo, 'mergeBaseTooOld', 0, 0, 0);
207 }
208 > if (safety.commitCount === undefined || safety.commitCount >= MAX_DIFF_COMMITS) { agentHostRepoInfoTelemetry.ts
209 return this._report(telemetryContext, isContextCurrent, telemetryMessageId, location, repoInfo, 'tooManyCommits', 0, 0, 0);
210 }
233 return undefined;
234 }
235 > const untracked = new Set(untrackedPaths ?? []); agentHostRepoInfoTelemetry.ts
236 > const descriptors = fileDiffs.map(diff => this._describeFileDiff(repositoryRoot, diff, untracked));
237 > if (descriptors.some(descriptor => descriptor === undefined)) {
238 return undefined;
239 }
272 }
273 return await this._reportIfTreeUnchanged(telemetryContext, isContextCurrent, telemetryMessageId, location, repoInfo, workingDirectory, tree, 'success', safety.workspaceFileCount, fileDiffs.length, measurement.diffSizeBytes, fileRelativePaths, diffsJSON);
275
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> {