agentService.ts ×5

Frontier kind: Joint frontier

unlabeled · c_9bf570824290

1 test · 52596 LOC · 304 files · introduces 1 test · 57 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges57 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
5703 ranges52596 lines · 304 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 57 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentService.ts 57 introduced LOC · 5 ranges

Open complete file

969 // fork parameter and fall through to the regular create path.
970 if (config?.fork) {
971 > const sourceState = this._stateManager.getSessionState(config.fork.session.toString()); agentService.ts
972 > const sourceTurns = sourceState?.turns.slice(0, config.fork.turnIndex + 1) ?? [];
973 > if (sourceTurns.length === 0) {
974 config = { ...config, fork: undefined };
975 > } else { agentService.ts
976 > const turnIdMapping = new Map<string, string>();
977 > for (const t of sourceTurns) {
978 > turnIdMapping.set(t.id, generateUuid());
979 > }
980 > // The SDK fork boundary must be a concrete (SDK-backed) turn.
981 > // When the client forked at a host-injected local turn
982 > // (`/rename` / `!command`), redirect the agent to the preceding
983 > // concrete turn while still seeding the local turns up to the
984 > // fork point into the new session's protocol state below.
985 > const concreteForkTurnId = this._localTurns.resolveConcreteTurnId(buildDefaultChatUri(config.fork.session).toString(), config.fork.turnId);
986 > config = {
987 > ...config,
988 > fork: { ...config.fork, turnIdMapping, ...(concreteForkTurnId !== undefined ? { turnId: concreteForkTurnId } : {}) },
989 > };
990 > }
991 > }
992
993 // When importing a conversation, assign fresh UUID turn ids up front so
1062 // the source session's turns so the client sees the forked history.
1063 if (config?.fork) {
1064 > const sourceState = this._stateManager.getSessionState(config.fork.session.toString()); agentService.ts
1065 > const sourceChatUri = buildDefaultChatUri(config.fork.session).toString();
1066 > const newChatUri = buildDefaultChatUri(session).toString();
1067 > let sourceTurns: Turn[] = [];
1068 > if (sourceState && config.fork.turnIdMapping) {
1069 > const originalSlice = sourceState.turns.slice(0, config.fork.turnIndex + 1);
1070 > const mapping = config.fork.turnIdMapping;
1071 > sourceTurns = originalSlice.map(t => ({ ...t, id: mapping.get(t.id) ?? generateUuid() }));
1072 > // Re-persist forked local turns (`/rename`, `!command`) under the
1073 > // new session's default chat. `record` (keyed by turn id)
1074 > // overwrites any rows a DB copy carried with the SOURCE chat URI,
1075 > // and seeds the in-memory index for same-process fork/truncate.
1076 > this._persistForkedLocalTurns(session.toString(), sourceChatUri, newChatUri, originalSlice, sourceTurns, mapping);
1077 > }
1078 >
1079 > // Prefix the forked session's title so consumers (sidebar, chat
1080 > // model) can distinguish it from the source without each surface
1081 > // reinventing the convention. Avoid double-prefixing when a user
1082 > // forks an already-forked session.
1083 > const forkedTitlePrefix = localize('agentHost.forkedTitlePrefix', "Forked: ");
1084 > const sourceTitle = sourceState?.title;
1085 > const forkedTitle = sourceTitle
1086 > ? (sourceTitle.startsWith(forkedTitlePrefix) ? sourceTitle : `${forkedTitlePrefix}${sourceTitle}`)
1087 : localize('agentHost.forkedSessionFallback', "Forked Session");
1088 > const summary = this._buildInitialSummary(provider, session, config, created, forkedTitle); agentService.ts
1089 > const state = this._stateManager.createSession(summary);
1090 > state.config = sessionConfig;
1091 > this._stateManager.seedDefaultChatTurns(summary.resource, sourceTurns);
1092 > state.activeClients = config.activeClient ? [config.activeClient] : [];
1093 > if (initialCustomizations && initialCustomizations.length > 0) {
1094 state.customizations = [...initialCustomizations];
1095 }
1097 > // Refine the forked session's placeholder `Forked: …` title into one
1098 > // derived from the inherited chat. Forks seed pre-existing
1099 > // turns, so the normal first-message/first-turn title generation
1100 > // never fires for them — this is the fork-time equivalent.
1101 > if (sourceTurns.length > 0) {
1102 > this._sideEffects.generateForkedTitle(summary.resource, undefined, sourceTurns, forkedTitle, sourceTitle);
1103 > }
1104 } else if (config?.importConversation) {
1105 // An imported conversation arrives with pre-existing turns (assigned