claudeAgent.ts ×4

Frontier kind: Code frontier

unlabeled · c_6f77b0a3508f

3 tests · 56647 LOC · 346 files · introduces 0 tests · 34 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
4 ranges34 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5652 ranges56647 lines · 346 files · Browse complete extent
All tests (intent)
3 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: 34 introduced LOC across 4 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/claudeAgent.ts 34 introduced LOC · 4 ranges

Open complete file

824
825 if (turnId === undefined) {
826 > await this._removeAllTurns(session, sessionId, existing); claudeAgent.ts
827 > return;
828 > }
829
830 const messages = await this._sdkService.getSessionMessages(sessionId, { includeSystemMessages: true });
854 */
855 private async _removeAllTurns(session: URI, sessionId: string, existing: ClaudeAgentSession | undefined): Promise<void> {
856 > const info = existing ? undefined : await this._sdkService.getSessionInfo(sessionId); claudeAgent.ts
857 > const workingDirectory = existing?.workingDirectory ?? (info?.cwd ? URI.file(info.cwd) : undefined);
858 > if (!workingDirectory) {
859 // Mirror `_resumeSession` / fork: fail fast rather than recreate a
860 // provisional with no cwd that would only fail later at materialize.
861 throw new Error(`Cannot clear session ${sessionId}: workingDirectory missing (SDK cwd absent and no live session)`);
862 }
863 > let overlay: IClaudeSessionOverlay = {}; claudeAgent.ts
864 > try {
865 > overlay = await this._metadataStore.read(session);
866 > } catch (err) {
867 this._logService.warn(`[Claude:${sessionId}] overlay read failed during remove-all; continuing with defaults`, err);
868 }
870 > // `shutdownLiveQuery` awaits the subprocess's actual exit (and its final
871 > // transcript flush), so the on-disk `<id>.jsonl` is now stable and safe
872 > // to delete: no live writer can recreate it before the next turn
873 > // respawns a fresh `--session-id <id>`.
874 > await existing?.shutdownLiveQuery();
875 > this._sessions.deleteAndDispose(sessionId);
876 > await this._sdkService.deleteSession(sessionId);
877 >
878 > await this.createSession({
879 > session,
880 > workingDirectory,
881 > ...(overlay.model ? { model: overlay.model } : {}),
882 > ...(overlay.agent ? { agent: overlay.agent } : {}),
883 > ...(overlay.permissionMode ? { config: { [ClaudeSessionConfigKey.PermissionMode]: overlay.permissionMode } } : {}),
884 > });
885 > // Re-fetch (not reuse `existing`): `existing` is the OLD session, already
886 > // torn down by `deleteAndDispose` above, and is `undefined` entirely on
887 > // the cold path. `createSession` registered a fresh instance under the
888 > // same id — prune through that live session so a single path covers both
889 > // warm and cold remove-all.
890 > await this._findAnySession(sessionId)?.pruneAllTurns();
891 > this._logService.info(`[Claude:${sessionId}] truncateSession removed all turns (deleteSession + fresh same-id)`);
892 > }
893
894 // ---- Chat surface ------------------------------------------------------