MCPcopy Create free account
hub / github.com/pingdotgg/t3code / getOrphanedWorktreePathForThread

Function getOrphanedWorktreePathForThread

apps/web/src/worktreeCleanup.ts:11–33  ·  view source on GitHub ↗
(
  threads: ReadonlyArray<Pick<ThreadShell, "id" | "worktreePath">>,
  threadId: ThreadShell["id"],
)

Source from the content-addressed store, hash-verified

9}
10
11export function getOrphanedWorktreePathForThread(
12 threads: ReadonlyArray<Pick<ThreadShell, "id" | "worktreePath">>,
13 threadId: ThreadShell["id"],
14): string | null {
15 const targetThread = threads.find((thread) => thread.id === threadId);
16 if (!targetThread) {
17 return null;
18 }
19
20 const targetWorktreePath = normalizeWorktreePath(targetThread.worktreePath);
21 if (!targetWorktreePath) {
22 return null;
23 }
24
25 const isShared = threads.some((thread) => {
26 if (thread.id === threadId) {
27 return false;
28 }
29 return normalizeWorktreePath(thread.worktreePath) === targetWorktreePath;
30 });
31
32 return isShared ? null : targetWorktreePath;
33}
34
35export function formatWorktreePathForDisplay(worktreePath: string): string {
36 const trimmed = worktreePath.trim();

Callers 2

useThreadActionsFunction · 0.90

Calls 1

normalizeWorktreePathFunction · 0.85

Tested by

no test coverage detected