diff --git a/src/main/worktree-removal-repo-owner.ts b/src/main/worktree-removal-repo-owner.ts index 86b1c828e94..8421c55d990 100644 --- a/src/main/worktree-removal-repo-owner.ts +++ b/src/main/worktree-removal-repo-owner.ts @@ -39,6 +39,24 @@ export function resolveWorktreeRemovalRepoOwner( : { kind: 'missing' } } +/** + * Whether this REPO is registered on a host other than the removal's. + * + * Deliberately a proxy, and it over-fires. The precise question is "does this + * WORKTREE id exist on another host", but `worktreeMeta` holds one entry per bare + * `repoId::path`, so main cannot enumerate per-host rows for an id — repo-level + * registration is the closest signal available. + * + * The cost, accepted knowingly: deleting a workspace that exists on ONE host, + * inside a repo that happens to be registered on two, preserves state it could + * have torn down (terminal history, advertised-URL watcher, PR-refresh aliases, + * the local session partition). Worktree ids are path-derived and reusable, so a + * workspace recreated at that path can inherit it. Narrowing this needs + * host-qualified worktree metadata, which is a storage change, not a fix here. + * + * Fail-safe direction: over-preserving leaves stale records, under-preserving + * destroys another host's live state. Prefer this way round. + */ export function hasWorktreeRemovalRepoOwnerOnOtherHost( store: Pick, repoId: string,