agentService.ts ×8

Frontier kind: Code frontier

unlabeled · c_7b7dc3b84ff1

25 tests · 51167 LOC · 304 files · introduces 0 tests · 37 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges37 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5272 ranges51167 lines · 304 files · Browse complete extent
All tests (intent)
25 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: 37 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentService.ts 37 introduced LOC · 8 ranges

Open complete file

1176
1177 async createChat(session: URI, chat: URI, options?: IAgentCreateChatOptions): Promise<void> {
1178 > const sessionKey = session.toString(); agentService.ts
1179 > const provider = this._findProviderForSession(session);
1180 > if (!provider) {
1181 throw new Error(`[AgentService] createChat: no provider for session ${sessionKey}`);
1182 }
1183 > if (!this._supportsChats(provider)) { agentService.ts
1184 throw new Error(`[AgentService] createChat: provider ${provider.id} does not support multiple chats`);
1185 }
1187 > // When forking, resolve the source chat's turns up to the fork point and
1188 > // mint fresh turn IDs for the new chat. The agent uses the mapping to
1189 > // remap per-turn data in the forked chat; the seeded turns make
1190 > // the new chat surface the forked history immediately.
1191 > let forkedTurns: Turn[] | undefined;
1192 > let forkedTitle: string | undefined;
1193 > let forkedSourceTitle: string | undefined;
1194 > let createOptions = options;
1195 > // Side chats validate and persist their provenance without seeding host-visible turns.
1196 > let sideChatOrigin: ChatOrigin | undefined;
1197 > if (options?.sideChat) {
1198 const resolvedSideChat = this._resolveSideChatOrigin(session, options.sideChat);
1199 sideChatOrigin = resolvedSideChat.origin;
1209 };
1210 }
1211 > if (options?.fork) { agentService.ts
1212 const sourceKey = options.fork.source.toString();
1213 const peerState = this._stateManager.getChatState(sourceKey);
1258 const createResult = await this._createChat(provider, chat, createOptions);
1259 const providerData = createResult?.providerData;
1260 > this._stateManager.addChat(sessionKey, chat.toString(), { agentService.ts
1261 > ...(forkedTitle !== undefined ? { title: forkedTitle } : options?.title !== undefined ? { title: options.title } : {}),
1262 > ...(forkedTurns !== undefined ? { turns: forkedTurns } : {}),
1263 > ...(providerData !== undefined ? { providerData } : {}),
1264 > ...(sideChatOrigin !== undefined ? { origin: sideChatOrigin } : {}),
1265 > });
1266 >
1267 > // Persist the new peer chat into the orchestrator-owned catalog so it is
1268 > // re-enumerated and re-materialized on the next restore without asking
1269 > // the agent. Side-chat provenance is persisted alongside providerData.
1270 > void this._persistPeerChat(session, chat, providerData, sideChatOrigin);
1271 >
1272 > // When the agent backs this peer chat with its own separately-enumerable
1273 > // SDK session (e.g. Claude), mark that session so it is filtered out of
1274 > // the top-level session list instead of leaking as a standalone session.
1275 > if (createResult?.backingSession) {
1276 this._markPeerChatBacking(createResult.backingSession, chat);
1277 }
1281 // turns, so the normal first-message/first-turn title generation never
1282 // fires for them — this is the fork-time equivalent.
1283 > if (forkedTurns && forkedTurns.length > 0 && forkedTitle !== undefined) { agentService.ts
1284 this._sideEffects.generateForkedTitle(sessionKey, chat.toString(), forkedTurns, forkedTitle, forkedSourceTitle);
1285 }
1286 > } agentService.ts
1287
1288 /**
1375 /** Whether `provider` can host additional (peer) chats. */
1376 private _supportsChats(provider: IAgent): boolean {
1377 > return !!provider.chats; agentService.ts
1378 > }
1379
1380 private async _createProviderSession(provider: IAgent, config: IAgentCreateSessionConfig | undefined, deferWorktreeCreation: boolean): Promise<IAgentCreateSessionResult> {