copilotAgent.ts ×15

Frontier kind: Code frontier

unlabeled · c_bebca80c4b96

79 tests · 51581 LOC · 300 files · introduces 0 tests · 48 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges48 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4949 ranges51581 lines · 300 files · Browse complete extent
All tests (intent)
79 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: 48 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/copilotAgent.ts 48 introduced LOC · 15 ranges

Open complete file

838 this._scheduledModelRefresh = scheduled;
839 this._modelRefreshSchedule.value = disposableTimeout(() => {
840 > void (async () => { copilotAgent.ts
841 > try {
842 > // A config-triggered restart clears `_client` before its
843 > // asynchronous `stop()` completes. Wait for that stop so this
844 > // refresh cannot resurrect the client midway through teardown.
845 > await this._clientStopping;
846 > if (this._scheduledModelRefresh !== scheduled) {
847 return;
848 }
849 > this._scheduledModelRefresh = undefined; copilotAgent.ts
850 > this._modelRefreshSchedule.clear();
851 > await this._startModelRefresh(scheduled.generation);
852 > } catch (err) {
853 this._logService.error(err, '[Copilot] Failed to schedule model refresh');
854 > } finally { copilotAgent.ts
855 > if (this._scheduledModelRefresh === scheduled) {
856 this._scheduledModelRefresh = undefined;
857 this._modelRefreshSchedule.clear();
858 }
859 > scheduled.deferred.complete(); copilotAgent.ts
860 > }
861 > })();
862 }, 0);
863 return scheduled.deferred.p;
865
866 private _startModelRefresh(generation: number): Promise<void> {
867 > const refresh = this._refreshModels(0, generation).finally(() => { copilotAgent.ts
868 > if (this._modelRefreshInFlight === refresh) {
869 > this._modelRefreshInFlight = undefined;
870 > }
871 > });
872 > this._modelRefreshInFlight = refresh;
873 > return refresh;
874 > }
875
876 private async _refreshModels(attempt = 0, generation = this._modelCatalogGeneration): Promise<void> {
877 > // A fresh refresh (e.g. a token change) supersedes any scheduled retry. copilotAgent.ts
878 > this._modelRefreshRetry.clear();
879 >
880 > // Once teardown has begun, skip the refresh entirely: a retry timer that
881 > // fires during the shutdown window would otherwise call `_ensureClient()`
882 > // and resurrect the SDK subprocess after `shutdown()` tore it down.
883 > if (this._shutdownPromise) {
884 return;
885 }
887 > const tokenAtRefreshStart = this._githubToken;
888 > if (!tokenAtRefreshStart) {
889 this._capiModels = [];
890 this._publishModels();
891 return;
892 }
893 > try { copilotAgent.ts
894 > const models = await this._listModels(tokenAtRefreshStart);
895 > if (this._githubToken === tokenAtRefreshStart && this._modelCatalogGeneration === generation) {
896 this._capiModels = models;
897 this._publishModels();
898 }
899 > } catch (err) { copilotAgent.ts
900 // Token rotated mid-flight — a newer refresh owns the result — or
901 // teardown began while the request was in flight, in which case a
1447
1448 private async _listModels(gitHubToken: string): Promise<IAgentModelInfo[]> {
1449 > this._logService.info('[Copilot] Listing models...'); copilotAgent.ts
1450 > const client = await this._ensureClient();
1451 > const { models } = await client.rpc.models.list({ gitHubToken });
1452 this._freeLongContextModels.clear();
1453 const preferLongContext = this._isPreferLongContextEnabled();
1480 this._logService.info(`[Copilot] Found ${result.length} models: ${result.map(m => m.name).join(', ')}`);
1481 return result;
1482 > } copilotAgent.ts
1483
1484 /**
2890 let capiUrl = env['VSCODE_AGENT_HOST_CAPI_URL_OVERRIDE'] || COPILOT_CAPI_URL;
2891 if (this._githubToken) {
2892 > try { copilotAgent.ts
2893 > const discovered = await this._copilotApiService.resolveApiEndpoint(this._githubToken);
2894 > if (discovered) {
2895 capiUrl = discovered;
2896 }
2897 > } catch (error) { copilotAgent.ts
2898 this._logService.debug(`[Copilot] CAPI endpoint discovery for proxy resolution failed; using ${capiUrl}: ${error instanceof Error ? error.message : String(error)}`);
2899 }
2900 > } copilotAgent.ts
2901
2902 try {