( threads: ReadonlyArray<Pick<ThreadShell, "id" | "worktreePath">>, threadId: ThreadShell["id"], )
| 9 | } |
| 10 | |
| 11 | export 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 | |
| 35 | export function formatWorktreePathForDisplay(worktreePath: string): string { |
| 36 | const trimmed = worktreePath.trim(); |
no test coverage detected