claudeAgent.ts ×12

Frontier kind: Code frontier

unlabeled · c_6a85837aa2d5

18 tests · 55696 LOC · 346 files · introduces 0 tests · 49 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges49 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5412 ranges55696 lines · 346 files · Browse complete extent
All tests (intent)
18 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: 49 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/claudeAgent.ts 49 introduced LOC · 12 ranges

Open complete file

1276 return;
1277 }
1278 > const parsed = parseChatUri(chat); claudeAgent.ts
1279 > if (!parsed) {
1280 throw new Error(`[Claude] createChat: malformed chat URI ${chat.toString()}`);
1281 }
1282 > const session = URI.parse(parsed.session); claudeAgent.ts
1283 > const chatKey = chat.toString();
1284 > const parentSessionId = AgentSession.id(session);
1285 > let result: IAgentCreateChatResult | undefined;
1286 const queueKey = options?.sideChat ? chatKey : parentSessionId;
1287 await this._sessionSequencer.queue(queueKey, async () => {
1288 > const existing = this._chatBackings.get(chatKey); claudeAgent.ts
1289 > if (existing) {
1290 // Idempotent re-create: hand back the existing backing so the
1291 // orchestrator re-persists a consistent blob.
1293 return;
1294 }
1295 > const parentSession = await this._resolveParentSession(session, parentSessionId); claudeAgent.ts
1296 > const model = options?.model ?? parentSession.model;
1297 >
1298 > let sdkSessionId: string | undefined;
1299 > let sideChat: IPersistedChat['sideChat'];
1300 > if (options?.fork) {
1301 // If the fork point can't be resolved, fall through to a fresh
1302 // chat rather than inheriting the whole source backend.
1303 sdkSessionId = (await this._forkChat(session, options.fork))?.sessionId;
1304 > } else if (options?.sideChat) { claudeAgent.ts
1305 const forked = await this._forkChat(session, { source: options.sideChat.source, turnId: options.sideChat.providerAnchorTurnId ?? options.sideChat.turnId });
1306 sdkSessionId = forked?.sessionId;
1319 };
1320 }
1321 > sdkSessionId ??= generateUuid(); claudeAgent.ts
1322 >
1323 > // Record the live backing and hand the opaque blob back to the
1324 > // orchestrator to persist.
1325 > const backing: IPersistedChat = { sdkSessionId, ...(model ? { model } : {}), ...(sideChat ? { sideChat } : {}) };
1326 > this._chatBackings.set(chatKey, backing);
1327 > result = { providerData: encodeProviderData(backing), backingSession: AgentSession.uri(this.id, sdkSessionId) };
1328 >
1329 > // Seed the chat's own metadata overlay so a later lazy resume (this
1330 > // process or a restart) inherits the parent's parentSession.
1331 > await this._metadataStore.write(chat, {
1332 > ...(model ? { model } : {}),
1333 > ...(parentSession.agent ? { agent: parentSession.agent } : {}),
1334 > ...(parentSession.permissionMode ? { permissionMode: parentSession.permissionMode } : {}),
1335 > });
1336 > this._logService.info(`[Claude] Created additional chat ${chat.toString()} in session ${session.toString()}${options?.fork ? ' (forked)' : ''}`);
1337 });
1338 > return result; claudeAgent.ts
1339 }
1340
1383 */
1384 private async _resolveParentSession(session: URI, parentSessionId: string): Promise<{ workingDirectory: URI; project: IAgentSessionProjectInfo | undefined; model: ModelSelection | undefined; agent: AgentSelection | undefined; permissionMode: ClaudePermissionMode }> {
1385 > const parent = this._findAnySession(parentSessionId); claudeAgent.ts
1386 > let workingDirectory = parent?.workingDirectory;
1387 > let project = parent?.project;
1388 > if (!workingDirectory) {
1389 const sdkInfo = await this._sdkService.getSessionInfo(parentSessionId);
1390 workingDirectory = sdkInfo?.cwd ? URI.file(sdkInfo.cwd) : undefined;
1391 }
1392 > if (!workingDirectory) { claudeAgent.ts
1393 throw new Error(`[Claude] createChat: cannot resolve working directory for parent session ${session.toString()}`);
1394 }
1395 > if (!project) { claudeAgent.ts
1396 > try {
1397 > project = await projectFromCopilotContext({ cwd: workingDirectory.fsPath }, this._gitService);
1398 > } catch (err) {
1399 this._logService.warn(`[Claude] createChat: project resolution failed for ${session.toString()}; continuing without project`, err);
1400 }
1401 > } claudeAgent.ts
1402 > let overlay: IClaudeSessionOverlay = {};
1403 > try {
1404 > overlay = await this._metadataStore.read(session);
1405 > } catch (err) {
1406 this._logService.warn(`[Claude] createChat: parent overlay read failed for ${session.toString()}; continuing with defaults`, err);
1407 }
1408 > const permissionMode = readClaudePermissionMode(this._configurationService, session) ?? overlay.permissionMode ?? 'default'; claudeAgent.ts
1409 > return { workingDirectory, project, model: overlay.model, agent: overlay.agent, permissionMode };
1410 > }
1411
1412 /**