chatServiceImpl.ts ×7

Frontier kind: Code frontier

unlabeled · c_9f48fcc48fe1

9 tests · 71289 LOC · 309 files · introduces 0 tests · 35 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges35 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5996 ranges71289 lines · 309 files · Browse complete extent
All tests (intent)
9 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.

2 files ranked by introduced lines: 35 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts 32 introduced LOC · 7 ranges

Open complete file

1157 // `_materializeUntitledSession`) before processing the request.
1158 if (!model.hasRequests && isUntitledChatSession(sessionResource) && getChatSessionType(sessionResource) !== localChatSessionType) {
1159 > const materialized = await this._materializeUntitledSession(sessionResource, request, options, model); chatServiceImpl.ts
1160 > if (materialized) {
1161 model = materialized.model;
1162 sessionResource = materialized.sessionResource;
1163 newSessionResource = materialized.newSessionResource;
1164 }
1166 if (model.isReadOnly.get()) {
1167 return { kind: 'rejected', reason: 'Session is read-only', newSessionResource };
1232 */
1233 private async _materializeUntitledSession(untitledResource: URI, request: string, options: IChatSendRequestOptions | undefined, untitledModel: ChatModel): Promise<{ model: ChatModel; sessionResource: URI; newSessionResource: URI } | undefined> {
1234 > const inFlight = this._inFlightUntitledMaterializations.get(untitledResource); chatServiceImpl.ts
1235 > if (inFlight) {
1236 // A concurrent send is already materializing this untitled session.
1237 // Await its result and re-target the resulting real resource instead of
1253 return { model: realModel, sessionResource: realResource, newSessionResource: realResource };
1254 }
1256 > // Track the materialization in-flight (keyed by the original untitled
1257 > // resource) so a concurrent second send joins this one rather than creating
1258 > // a duplicate real session. Store synchronously, before any await, so a
1259 > // concurrent send reliably observes the in-flight materialization.
1260 > const materialized = new DeferredPromise<URI | undefined>();
1261 > this._inFlightUntitledMaterializations.set(untitledResource, materialized.p);
1262 > try {
1263 > const parsedRequest = this.parseChatRequest(untitledResource, request, options?.location ?? untitledModel.initialLocation, options);
1264 > const commandPart = parsedRequest.parts.find((r): r is ChatRequestSlashCommandPart => r instanceof ChatRequestSlashCommandPart);
1265 > const requestText = getPromptText(parsedRequest).message;
1266 >
1267 > // Snapshot the untitled session's options up front: they seed
1268 > // `createNewChatSessionItem` below and are pushed onto the real session
1269 > // once it loads. Capturing before those steps avoids reading them back
1270 > // after the untitled entry may have changed during materialization.
1271 > const initialSessionOptions = this.chatSessionService.getSessionOptions(untitledResource);
1272 >
1273 > const newItem = await this.chatSessionService.createNewChatSessionItem(getChatSessionType(untitledResource), { prompt: requestText, command: commandPart?.text, initialSessionOptions, untitledResource }, CancellationToken.None);
1274 if (!newItem) {
1275 materialized.complete(undefined);
1284 const tempRef = await this.loadRemoteSession(newItem.resource, untitledModel.initialLocation, CancellationToken.None);
1285 const realModel = tempRef?.object as ChatModel | undefined;
1286 > if (!realModel) { chatServiceImpl.ts
1287 throw new Error(`Failed to load session for resource: ${newItem.resource}`);
1288 }
1303 this.info('materializeUntitledSession', `Materialized untitled session ${untitledResource.toString()} into real session ${newItem.resource.toString()}`);
1304 return { model: realModel, sessionResource: newItem.resource, newSessionResource: newItem.resource };
1305 > } catch (err) { chatServiceImpl.ts
1306 // Resolve (not reject) so a concurrent waiter degrades to the normal
1307 // untitled path rather than inheriting this failure, then propagate the
1310 materialized.complete(undefined);
1311 throw err;
1312 > } finally { chatServiceImpl.ts
1313 > if (this._inFlightUntitledMaterializations.get(untitledResource) === materialized.p) {
1314 > this._inFlightUntitledMaterializations.delete(untitledResource);
1315 > }
1316 > }
1317 > }
1318
1319 private getAttachmentCapabilitiesForParser(chatSessionType: string, agent: IChatAgentData | undefined): IChatAgentAttachmentCapabilities | undefined {
src/vs/workbench/contrib/chat/test/common/mockChatSessionsService.ts 3 introduced LOC · 1 range

Open complete file

220
221 getSessionOptions(sessionResource: URI): ReadonlyChatSessionOptionsMap | undefined {
222 > const options = this.sessionOptions.get(sessionResource); mockChatSessionsService.ts
223 > return options && options.size > 0 ? options : undefined;
224 > }
225
226 getSessionOption(sessionResource: URI, optionId: string): string | undefined {