copilotAgent.ts ×17

Frontier kind: Code frontier

unlabeled · c_a520b69567a4

31 tests · 52215 LOC · 300 files · introduces 0 tests · 74 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges74 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5150 ranges52215 lines · 300 files · Browse complete extent
All tests (intent)
31 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: 74 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/copilotAgent.ts 74 introduced LOC · 17 ranges

Open complete file

3419
3420 constructor(
3421 > workingDirectory: URI, copilotAgent.ts
3422 > userHome: URI,
3423 > private readonly _getClient: () => Promise<CopilotClient>,
3424 > private readonly _onDidRefresh: () => void,
3425 > @IFileService private readonly _fileService: IFileService,
3426 > @IAgentConfigurationService private readonly _configurationService: IAgentConfigurationService,
3427 > @ILogService private readonly _logService: ILogService,
3428 > @IInstantiationService instantiationService: IInstantiationService,
3429 > ) {
3430 > super();
3431 > this._discovery = this._register(instantiationService.createInstance(SessionCustomizationDiscovery, workingDirectory, userHome, URI.file));
3432 > this._settled = this._queueRefresh(false, 0);
3433 > this._register(this._discovery.onDidChange(() => {
3434 this._settled = this._queueRefresh(true);
3435 > })); copilotAgent.ts
3436 > this._register(this._configurationService.onDidRootConfigChange(() => {
3437 this._settled = this._queueRefresh(true);
3438 > })); copilotAgent.ts
3439 > }
3440
3441 override dispose(): void {
3442 > this._refreshPromise?.cancel(); copilotAgent.ts
3443 > this._refreshPromise = null;
3444 > super.dispose();
3445 > }
3446
3447 whenSettled(): Promise<void> {
3448 > return this._settled; copilotAgent.ts
3449 > }
3450
3451 currentCustomizations(): readonly DirectoryCustomization[] {
3452 > return this._customizations; copilotAgent.ts
3453 > }
3454
3455 private _queueRefresh(notify: boolean, delay = REFRESH_DEBOUNCE_MS): Promise<void> {
3456 > this._refreshPromise?.cancel(); copilotAgent.ts
3457 > this._refreshPromise = null;
3458 > this._pendingRefreshNotify = this._pendingRefreshNotify || notify;
3459 >
3460 > return this._refreshDelayer.trigger(() => {
3461 > const shouldNotify = this._pendingRefreshNotify;
3462 > this._pendingRefreshNotify = false;
3463 > const refreshPromise = this._refreshPromise = createCancelablePromise(async token => {
3464 > const didRefresh = await this._refresh(token);
3465 > if (didRefresh && shouldNotify) {
3466 this._onDidRefresh();
3467 }
3468 > }); copilotAgent.ts
3469 >
3470 > return refreshPromise.then(() => {
3471 > if (this._refreshPromise === refreshPromise) {
3472 > this._refreshPromise = null;
3473 > }
3474 > }, err => {
3475 if (this._refreshPromise === refreshPromise) {
3476 this._refreshPromise = null;
3480 }
3481 throw err;
3482 > }); copilotAgent.ts
3483 > }, delay);
3484 > }
3485
3486 private async _refresh(token: CancellationToken): Promise<boolean> {
3487 > try { copilotAgent.ts
3488 > const mode = this._configurationService.getRootValue(agentHostCustomizationConfigSchema, AgentHostConfigKey.SessionCustomizationDiscoveryMode)
3489 > ?? DEFAULT_SESSION_CUSTOMIZATION_DISCOVERY_MODE;
3490 > if (mode === 'discover') {
3491 const customizations = await this._discovery.discover(await this._getClient(), token);
3492 if (token.isCancellationRequested) {
3502 return true;
3503 }
3505 > const directories = await this._discovery.scan(token);
3506 > if (token.isCancellationRequested) {
3507 return false;
3508 }
3510 > if (this._directories && areDiscoveredDirectoriesEqual(this._directories, directories)) {
3511 return false;
3512 }
3514 > const customizations = await toDiscoveredDirectoryCustomizations(directories, this._fileService);
3515 > if (token.isCancellationRequested) {
3516 return false;
3517 }
3519 > // Don't update `_customizations` / `_directories` when cancelled.
3520 > // Otherwise a cancelled refresh could temporarily clear them and cause callers to see empty customizations.
3521 > this._customizations = customizations;
3522 > this._directories = directories;
3523 > return true;
3524 > } catch (err) {
3525 // Don't update `_customizations` / `_directories` when cancelled.
3526 // Otherwise a cancelled refresh could temporarily clear them and cause callers to see empty customizations.
4204 return undefined;
4205 }
4206 > if (!this._sessionDiscovered.value) { copilotAgent.ts
4207 > this._sessionDiscovered.value = this._instantiationService.createInstance(SessionDiscoveredEntry,
4208 > this._directory,
4209 > this._parent.getUserHome(),
4210 > () => this._parent.getClient(),
4211 > () => this._onDidPublish.fire({
4212 type: ActionType.SessionCustomizationsChanged,
4213 customizations: [...this.getCustomizations()],
4214 })
4215 > ); copilotAgent.ts
4216 > }
4217 > return this._sessionDiscovered.value;
4218 }
4219