{"record":{"id":"515c3f7d1ffffe9a","repo":"stablyai/orca","slug":"worktree-is-no-longer-registered-with-git-and-its","errorCode":null,"errorMessage":"Worktree is no longer registered with Git and its directory is already gone.","messagePattern":"Worktree is no longer registered with Git and its directory is already gone\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/main/ipc/worktrees.ts","lineNumber":2597,"sourceCode":"                  localWorktreeGitOptions\n                )\n                runtime.clearOptimisticReconcileToken(args.worktreeId)\n                removeWorktreeMetadataAndTransientState(store, args.worktreeId, removalHostId)\n                preservedBranchCleanupByScope.delete(\n                  preservedBranchCleanupScopeKey({\n                    worktreeId: args.worktreeId,\n                    hostId: removalHostId\n                  })\n                )\n                invalidateAuthorizedRootsCache()\n                notifyWorktreesChanged(mainWindow, repoId)\n                return {}\n              }\n            }\n            if (await isAlreadyRemovedWorktreePath(repo, worktreePath, localWorktreeGitOptions)) {\n              if (!args.force && !removedMeta) {\n                // Why: without persisted metadata, require the renderer recovery path before deleting Orca-only state for an unregistered path.\n                throw new Error(UNREGISTERED_MISSING_WORKTREE_MESSAGE)\n              }\n              // Why: a manually deleted worktree is already gone; persisted metadata proves it was an Orca-known row, so no force is needed.\n              if (repo.connectionId) {\n                await cleanupUnusedWorktreePushTargetRemoteSsh(\n                  provider!,\n                  repo.path,\n                  args.worktreeId,\n                  removedPushTarget,\n                  store\n                )\n              } else {\n                await cleanupUnusedWorktreePushTargetRemote(\n                  repo.path,\n                  args.worktreeId,\n                  removedPushTarget,\n                  store,\n                  localWorktreeGitOptions\n                )","sourceCodeStart":2579,"sourceCodeEnd":2615,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktrees.ts#L2579-L2615","documentation":"Thrown (UNREGISTERED_MISSING_WORKTREE_MESSAGE) when isAlreadyRemovedWorktreePath is true (directory already gone) but args.force is false AND removedMeta is undefined. Without persisted metadata proving Orca owned the row, the main process won't clear Orca-only state for an unregistered, already-deleted path; it requires the renderer recovery path.","triggerScenarios":"A non-force worktrees:remove for a worktree whose directory is already gone and for which the store holds no WorktreeMeta (never persisted, or metadata was wiped).","commonSituations":"User deleted the worktree directory out-of-band and the Orca metadata row was never written or was cleared; the path is gone but Orca can't prove prior ownership.","solutions":["Retry with args.force true so Orca clears the dangling state even without metadata.","If the worktree was never Orca-tracked, no removal is needed — drop the stale renderer row locally.","Ensure worktree metadata is persisted at creation so future removals have removedMeta to rely on."],"exampleFix":"// before\ninvoke('worktrees:remove', { worktreeId, force: false })\n// after\ninvoke('worktrees:remove', { worktreeId, force: true })","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isUnregisteredMissingMessage(e: unknown): boolean {\n  return e instanceof Error && e.message.startsWith('Worktree is no longer registered with Git and its directory is already gone')\n}","tryCatchPattern":"try {\n  await invoke('worktrees:remove', { worktreeId, force: false })\n} catch (e) {\n  if (isUnregisteredMissingMessage(e)) {\n    // No metadata + already gone: clear dangling Orca state with force.\n    await invoke('worktrees:remove', { worktreeId, force: true })\n  } else throw e\n}","preventionTips":["Persist worktree metadata at creation so removals have removedMeta.","Drop stale renderer rows for never-tracked worktrees instead of removing.","Use force to clear dangling state when metadata is absent."],"tags":["worktree-remove","orphan-cleanup","metadata","force-delete"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}