chatServiceImpl.ts ×13

Frontier kind: Code frontier

unlabeled · c_0155dccf43e2

35 tests · 71686 LOC · 309 files · introduces 0 tests · 91 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges91 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
6076 ranges71686 lines · 309 files · Browse complete extent
All tests (intent)
35 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.

3 files ranked by introduced lines: 91 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts 78 introduced LOC · 13 ranges

Open complete file

1167 return { kind: 'rejected', reason: 'Session is read-only', newSessionResource };
1168 }
1170 > const hasPendingRequest = this._pendingRequests.has(sessionResource);
1171 >
1172 if (options?.queue) {
1173 const queued = this.queuePendingRequest(model, sessionResource, request, options);
1176 }
1177 return queued;
1178 > } else if (hasPendingRequest) { chatServiceImpl.ts
1179 this.trace('sendRequest', `Session ${sessionResource} already has a pending request`);
1180 return { kind: 'rejected', reason: 'Request already in progress' };
1353
1354 private refreshFollowupsCancellationToken(sessionResource: URI): CancellationToken {
1355 > this._sessionFollowupCancelTokens.get(sessionResource)?.cancel(); chatServiceImpl.ts
1356 > const newTokenSource = new CancellationTokenSource();
1357 > this._sessionFollowupCancelTokens.set(sessionResource, newTokenSource);
1358 >
1359 > return newTokenSource.token;
1360 > }
1361
1362 private _sendRequestAsync(model: ChatModel, sessionResource: URI, parsedRequest: IParsedChatRequest, attempt: number, enableCommandDetection: boolean, defaultAgent: IChatAgentData, location: ChatAgentLocation, options?: IChatSendRequestOptions): IChatSendRequestResponseState {
1363 > const followupsCancelToken = this.refreshFollowupsCancellationToken(sessionResource); chatServiceImpl.ts
1364 > let request: ChatRequestModel | undefined;
1365 > const agentPart = parsedRequest.parts.find((r): r is ChatRequestAgentPart => r instanceof ChatRequestAgentPart);
1366 > const agentSlashCommandPart = parsedRequest.parts.find((r): r is ChatRequestAgentSubcommandPart => r instanceof ChatRequestAgentSubcommandPart);
1367 > const commandPart = parsedRequest.parts.find((r): r is ChatRequestSlashCommandPart => r instanceof ChatRequestSlashCommandPart);
1368 > const requests = [...model.getRequests()];
1369 > const isTerminalCommand = isTerminalCommandPrompt(parsedRequest.text, this.chatSessionService.getCapabilitiesForSessionType(getChatSessionType(sessionResource))?.terminalCommandPrefix);
1370 > const requestTelemetry = this.instantiationService.createInstance(ChatRequestTelemetry, {
1371 > agent: agentPart?.agent ?? defaultAgent,
1372 > agentSlashCommandPart,
1373 > commandPart,
1374 > sessionResource: model.sessionResource,
1375 > location: model.initialLocation,
1376 > options,
1377 > enableCommandDetection
1378 > });
1379 >
1380 > let gotProgress = false;
1381 > const requestType = commandPart ? 'slashCommand' : 'string';
1382 >
1383 > const responseCreated = new DeferredPromise<IChatResponseModel>();
1384 > let responseCreatedComplete = false;
1385 > function completeResponseCreated(): void {
1386 > if (!responseCreatedComplete && request?.response) {
1387 > responseCreated.complete(request.response);
1388 > responseCreatedComplete = true;
1389 > }
1390 > }
1391 >
1392 > const store = new DisposableStore();
1393 > const source = store.add(new CancellationTokenSource());
1394 > const token = source.token;
1395 > const sendRequestInternal = async () => {
1396 > const progressCallback = (progress: IChatProgress[]) => {
1397 if (token.isCancellationRequested) {
1398 return;
1420 completeResponseCreated();
1421 };
1423 > let detectedAgent: IChatAgentData | undefined;
1424 > let detectedCommand: IChatAgentCommand | undefined;
1425 >
1426 > // Gate /troubleshoot and the troubleshoot skill behind the file logging flag.
1427 > // agentDebugLog.enabled is deprecated; only fileLogging.enabled is authoritative.
1428 > {
1429 > const fileLoggingEnabled = this.configurationService.getValue<boolean>(AGENT_DEBUG_LOG_FILE_LOGGING_ENABLED_SETTING);
1430 > if (!fileLoggingEnabled) {
1431 const isTroubleshootCommand = agentSlashCommandPart?.command.name === TROUBLESHOOT_COMMAND_NAME;
1432 const hasTroubleshootSkill = options?.attachedContext?.some(v => {
1455 }
1456 }
1458
1459 // Collect hooks from hook .json files
1540 let rawResult: IChatAgentResult | null | undefined;
1541 let agentOrCommandFollowups: Promise<IChatFollowup[] | undefined> | undefined = undefined;
1542 > if (agentPart || (defaultAgent && !commandPart)) { chatServiceImpl.ts
1543 // --- Step 1: Create the request model immediately (before any awaits) ---
1544 // This fires RequestUiUpdated synchronously so the user sees their message right away.
1729 }
1730
1731 > if ((token.isCancellationRequested && !rawResult)) { chatServiceImpl.ts
1732 return;
1733 } else if (!request) {
1778 }
1779 }
1780 > } catch (err) { chatServiceImpl.ts
1781 this.logService.error(`Error while handling chat request: ${toErrorMessage(err, true)}`);
1782 if (request) {
1797 store.dispose();
1798 }
1799 > }; chatServiceImpl.ts
1800 > let shouldProcessPending = false;
1801 > const rawResponsePromise = sendRequestInternal();
1802 > // Note- requestId is not known at this point, assigned later
1803 > const cancellableRequest = this.instantiationService.createInstance(CancellableRequest, source, undefined, rawResponsePromise, options);
1804 > this._pendingRequests.set(model.sessionResource, cancellableRequest);
1805 > this.telemetryService.publicLog2<ChatPendingRequestChangeEvent, ChatPendingRequestChangeClassification>(ChatPendingRequestChangeEventName, { action: 'add', source: 'sendRequest', chatSessionId: chatSessionResourceToId(model.sessionResource) });
1806 > rawResponsePromise.finally(() => {
1807 > markChat(sessionResource, ChatPerfMark.RequestComplete);
1808 > clearChatMarks(sessionResource);
1809 > if (this._pendingRequests.get(model.sessionResource) === cancellableRequest) {
1810 this._pendingRequests.deleteAndDispose(model.sessionResource);
1811 this.telemetryService.publicLog2<ChatPendingRequestChangeEvent, ChatPendingRequestChangeClassification>(ChatPendingRequestChangeEventName, { action: 'remove', source: 'sendRequestComplete', requestId: cancellableRequest.requestId, chatSessionId: chatSessionResourceToId(model.sessionResource) });
1812 }
1813 > // Process the next pending request from the queue if any chatServiceImpl.ts
1814 > if (shouldProcessPending) {
1815 this.processNextPendingRequest(model);
1816 }
1817 > }); chatServiceImpl.ts
1818 > if (options?.userSelectedModelId && !options.isSystemInitiated) {
1819 this.languageModelsService.addToRecentlyUsedList(options.userSelectedModelId);
1820 }
1821 > this._onDidSubmitRequest.fire({ chatSessionResource: model.sessionResource, message: parsedRequest }); chatServiceImpl.ts
1822 > return {
1823 > responseCreatedPromise: responseCreated.p,
1824 > responseCompletePromise: rawResponsePromise,
1825 > };
1826 > }
1827
1828 processPendingRequests(sessionResource: URI): void {
src/vs/workbench/contrib/chat/common/chatService/chatServiceTelemetry.ts 11 introduced LOC · 1 range

Open complete file

279
280 constructor(private readonly opts: {
281 > agent: IChatAgentData; chatServiceTelemetry.ts
282 > agentSlashCommandPart: ChatRequestAgentSubcommandPart | undefined;
283 > commandPart: ChatRequestSlashCommandPart | undefined;
284 > sessionResource: URI;
285 > location: ChatAgentLocation;
286 > options: IChatSendRequestOptions | undefined;
287 > enableCommandDetection: boolean;
288 > },
289 > @ITelemetryService private readonly telemetryService: ITelemetryService,
290 > @ILanguageModelsService private readonly languageModelsService: ILanguageModelsService
291 > ) { }
292
293 complete({ timeToFirstProgress, totalTime, result, requestType, request, detectedAgent }: {
src/vs/workbench/contrib/chat/common/chatSessionsService.ts 2 introduced LOC · 1 range

Open complete file

322 */
323 export function isTerminalCommandPrompt(text: string, prefix: string | undefined): boolean {
324 > return !!prefix && text.startsWith(prefix) && text.slice(prefix.length).trim().length > 0; chatSessionsService.ts
325 > }
326
327 /**