worktreeIsolation.ts ×11

Frontier kind: Joint frontier

unlabeled · c_b38501fd7e51

1 test · 24750 LOC · 98 files · introduces 1 test · 42 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges42 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
2153 ranges24750 lines · 98 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: 42 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/shared/worktreeIsolation.ts 42 introduced LOC · 11 ranges

Open complete file

585 */
586 async cleanupWorktreeOnArchive(sessionUri: URI, sessionId: string): Promise<void> {
587 > return this._sequencer.queue(sessionId, () => this._cleanupWorktreeOnArchive(sessionUri, sessionId)); worktreeIsolation.ts
588 > }
589
590 private async _cleanupWorktreeOnArchive(sessionUri: URI, sessionId: string): Promise<void> {
591 > const meta = await this._readWorktreeMetadata(sessionUri).catch(() => undefined); worktreeIsolation.ts
592 > if (!meta?.worktreePath || !meta.repositoryRoot) {
593 return;
594 }
595 > const { branchName, worktreePath, repositoryRoot } = meta; worktreeIsolation.ts
596 >
597 > // Skip if the worktree directory is already gone — nothing to clean.
598 > try {
599 > await fs.access(worktreePath.fsPath);
600 > } catch {
601 this._createdWorktrees.delete(sessionId);
602 return;
603 }
605 > // Skip if the branch is missing — without it we can't safely recreate
606 > // the worktree on unarchive, so leave the working tree intact.
607 > const branchPresent = await this._gitService.branchExists(repositoryRoot, branchName).catch(() => false);
608 > if (!branchPresent) {
609 this._logService.info(`[${this._logLabel}:${sessionId}] Skipping worktree cleanup: branch '${branchName}' is missing`);
610 return;
611 }
613 > // Commit any uncommitted changes before archiving the session
614 > const hasUncommittedChanges = await this._gitService.hasUncommittedChanges(worktreePath).catch(() => true);
615 > if (hasUncommittedChanges) {
616 try {
617 await this._gitService.commitAll(worktreePath, localize('worktreeIsolation.commitMessage', 'Saving uncommitted changes before archiving session'));
621 }
622 }
624 > try {
625 > await this._gitService.removeWorktree(repositoryRoot, worktreePath);
626 > this._logService.info(`[${this._logLabel}:${sessionId}] Removed worktree '${worktreePath.fsPath}' on archive`);
627 > } catch (error) {
628 this._logService.warn(`[${this._logLabel}:${sessionId}] Failed to remove worktree '${worktreePath.fsPath}' on archive: ${errorMessage(error)}`);
629 > } finally { worktreeIsolation.ts
630 > this._createdWorktrees.delete(sessionId);
631 > }
632 > }
633
634 /**
638 */
639 async recreateWorktreeOnUnarchive(sessionUri: URI, sessionId: string): Promise<void> {
640 > return this._sequencer.queue(sessionId, () => this._recreateWorktreeOnUnarchive(sessionUri, sessionId)); worktreeIsolation.ts
641 > }
642
643 private async _recreateWorktreeOnUnarchive(sessionUri: URI, sessionId: string): Promise<void> {
644 > const meta = await this._readWorktreeMetadata(sessionUri).catch(() => undefined); worktreeIsolation.ts
645 > if (!meta?.worktreePath || !meta.repositoryRoot) {
646 return;
647 }
648 > // Skip if the worktree directory already exists — nothing to do. worktreeIsolation.ts
649 > try {
650 > await fs.access(meta.worktreePath.fsPath);
651 return;
652 > } catch { worktreeIsolation.ts
653 > // expected when the worktree was cleaned up on archive
654 > }
655 >
656 > const { branchName, worktreePath, repositoryRoot } = meta;
657 > await this._recreateWorktree(sessionId, { branchName, worktreePath, repositoryRoot });
658 > }
659
660 private async _recreateWorktree(sessionId: string, meta: { readonly branchName: string; readonly worktreePath: URI; readonly repositoryRoot: URI }): Promise<{ readonly ok: true } | { readonly ok: false; readonly reason: string }> {