Skip to content

[Feature]: Reconcile sidebar worktree records with the filesystem — externally deleted worktrees linger as permanent ghost rows #10951

Open

Description

@chan1103

Problem or use case

Worktrees that are removed outside Orca leave permanent "ghost" rows in the Projects sidebar.

My setup: Windows 11 + WSL2 (Ubuntu), Orca 1.4.158, a WSL repo added via \\wsl.localhost\.... I run terminal AI agents that create git worktrees for each task and delete them after the branch is merged (git worktree remove + git branch -D, from the CLI side). This is a very common agent workflow.

What happens:

  • The deleted worktree keeps showing in the Projects sidebar as a gray-dot row, indefinitely.
  • The record survives app restarts — there appears to be no prune/refresh that reconciles records against the filesystem. In a few days of normal agent work I accumulated 4 ghost rows while git worktree list shows none of them.
  • Internally these correspond to lingering worktreeMeta entries in orca-data.json whose paths no longer exist on disk.

Why manual removal is not a great answer: each ghost must be removed one by one via the row menu, and users who don't know the internals are afraid to do it — it is not obvious that "Remove" only drops Orca's record and cannot touch real folders/code. Doing this repeatedly invites mis-clicks on a live worktree row.

Proposed solution

Either (or both) of:

  1. Auto-reconcile: when scanning a project (startup and/or periodic refresh), archive or prune worktree records whose backing path no longer exists. If silently dropping them feels too aggressive, mark them as "missing" with a distinct state.
  2. One-click cleanup: a "Clean up missing worktrees" action on the project context menu that removes all records whose folders are gone, so users never have to pick rows one by one.

Given Orca's positioning around parallel agent workflows, externally-deleted worktrees are the norm rather than the exception, so a filesystem-reconciling refresh would remove a recurring papercut.

Activity

  1. Smurries commented on Aug 7, 2026

    @Smurries

    Confirming this on 1.4.175 in a configuration the original report doesn't cover: a monitor-only client with no local projects, paired to three Remote Orca Servers. Same ghost rows, but the reconcile can't happen where #10951 currently proposes it.

    Configuration

    Client Windows 11 x64, Orca 1.4.175 (also present on 1.4.176), profile local-default
    Client role Dashboard only — no agents run here
    Servers 3 × Remote Orca Server on Linux, paired over Tailscale, same repo on each
    Client-owned records repos: [], projects: [], worktreeMeta: {} — none

    Symptom

    Worktrees deleted on a server keep appearing in the client's sidebar. They survive app restart (restarted 06:26 UTC on 07 Aug during the 1.4.175 update; rows persisted).

    Why this configuration matters for the fix

    The client holds zero owned project or worktree records. It cannot reconcile "records against the filesystem" as proposed in the opening post, because there is no local filesystem backing any of these rows — the servers are serving them. So the reconcile has to fan out per connected runtime environment and be driven by the owning host, not by a local project scan.

    Evidence from orca-data.json

    1. workspaceSessionsByHostId accumulates orphan per-worktree records, and does so inconsistently across hosts. Comparing the five-file backup ring (05 Aug 12:31 UTC → 07 Aug 07:19 UTC), counting distinct worktree ids referenced across tabsByWorktree, unifiedTabs, tabGroups, openFilesByWorktree, lastVisitedAtByWorktreeId and friends:

    Host 05 Aug 12:31 07 Aug 06:21 07 Aug 07:19 Removals seen
    server A 31 46 52 0
    server B 11 11 11 0
    server C 22 22 16 9

    79 records total, most for worktrees long gone. Server C prunes; A and B never do. Whatever path drops records on C isn't running for the other two.

    2. Cross-host identity contamination in the per-host session store. All three host sessions carry identical scalar pointers, and two of three name a repo id the host does not own:

    Host session activeWorktreeId activeWorkspaceKey
    A repo bc3d8e8e — owned by C repo 9e1d30e0 — own
    B repo bc3d8e8e — owned by C repo 9e1d30e0 — owned by A
    C repo bc3d8e8e — own repo 9e1d30e0 — owned by A

    This looks like the same class as #8881 and #10859 — peer identity leaking into per-host client state — except it's landing in the persisted session rather than the in-memory store, so a restart doesn't clear it.

    3. Blast radius. Per #12918, one invalid field in one persisted record discards the entire workspace session. 79 orphan records pointing at paths that no longer exist is a lot of surface for that.

    Why the shipped fixes don't reach this

    Request

    1. Extend the reconcile in this issue to fan out per connected runtime environment, so a paired Remote Orca Server's worktree set is reconciled the same way a local project scan is.
    2. Route Remote Orca Server hosts through the same git.pruneWorktrees relay path feat(space): add a prune action for stale worktree registrations #8910 uses for SSH targets, so the ⚠ N stale worktree registrations [Prune] notice appears for remote hosts too.
    3. Prune the matching workspaceSessionsByHostId records at the same time. Removing the sidebar row without removing the persisted session record leaves the resurrection surface in Closing a terminal tab with a missing persisted session record resurrects the tab — close aborts on tab_not_found before PTY kill and snapshot prune #12920 / [Bug]: Closed SSH terminal tabs resurrect: reattach re-creates persisted tabs, erases close tombstones, and auto-runs claude --resume on old sessions #12447 intact.

    Workaround currently in use

    Glad to test a build on this 3-server fleet if that helps move #8910 along.

  2. clemens commented on Oct 17, 2026

    @clemens

    Note: Written by agent, sanity-checked by me.

    Same ghost rows on an SSH host, here an on-demand VM runtime (Cloud VM recipe, provisioned-root checkout at /workspace). Orca 1.4.227, Linux.

    What happens

    A worktree created inside the box (git worktree add /workspace/<dir>/wt-main) and later removed there with git worktree remove / git worktree prune over SSH keeps its row.

    • While the box is connected, orca worktree list --repo id:<repo-id> shows only /workspace, so the relay's git worktree list --porcelain -z is authoritative and correct.
    • orca worktree show --worktree 'id:<repo-id>::/workspace/<dir>/wt-main' still resolves it from worktreeMeta, with empty head and branch.
    • Whenever the SSH listing is unavailable (runtime suspended, app start before the host reconnects, a failed list), worktrees:list returns the metadata-fallback result built from worktreeMeta, and the dead row is back in the sidebar.

    Why it is never swept (reading the 1.4.227 bundle)

    • The metadata prune that runs after a fresh git scan is gated to local repos: the store sweep only runs when the repo's execution host is local. SSH and runtime repos never get it.
    • For SSH/runtime hosts the only removal path is the renderer's worktrees:forgetRemovedForExecutionHost, which fires only for worktrees that were in the renderer's worktreesByRepo for that host and then missing from a later source: "git" refresh. A worktree removed while Orca was closed, while the host was disconnected, or before the sidebar had loaded that host's list never gets forgotten.
    • orca worktree rm doesn't help for such a row: it runs git worktree remove on the host, which fails for a path git no longer knows.

    Suggestion

    Run the same reconcile for SSH/runtime repos after an authoritative remote listing: drop (or mark missing) worktreeMeta rows on that host whose path isn't in the listing, using the same hostId scoping forgetRemovedForExecutionHost already applies. That would cover this case without depending on the renderer having seen the worktree before it disappeared.

  3. BGamboa13 commented on Oct 21, 2026

    @BGamboa13

    Operating system

    Windows 11 with WSL2 (project opened via \\wsl.localhost\<distro>\...)

    Orca version

    1.4.230

    Details

    What happens

    For a project that lives inside WSL, worktrees removed outside Orca (for example git worktree remove run by an agent in a WSL terminal) keep showing in the sidebar. orca worktree list for the same project no longer includes them, so the listing is correct; the sidebar simply never asks for it again.

    Steps to reproduce

    1. On Windows, add a Git project located in a WSL distro (\\wsl.localhost\...).
    2. Create a worktree for it (from Orca or from the CLI).
    3. In a WSL shell, run git worktree remove <path>.
    4. The worktree row stays in the sidebar. orca worktree list no longer shows it.

    Expected

    The row disappears after a refresh, or there is a way to trigger one.

    Why it happens (from reading the source)

    • src/main/ipc/worktree-base-directory-watch-targets.ts intentionally skips both the worktree-root watcher and the git-common watcher when the repo path is a WSL UNC path ("WSL UNC paths are unreliable for native watching"). No polling fallback is installed for these repos, so main never sends worktrees:changed for them.
    • On the renderer side, fetchAllWorktrees() only runs at startup and when the number of projects changes. There is no refresh on window focus, no periodic refresh, and no manual refresh action. The only manual retry (RepoScanUnavailableIndicator) appears only after a failed scan.

    Proposed minimal fix

    1. Add a "Refresh worktrees" item to the project actions menu that calls fetchWorktrees(repo.id, { executionHostId, requireAuthoritative: true }), the same call the scan-failure indicator already uses.
    2. Refresh unwatched (WSL) projects when the window regains focus or visibility, with a cooldown of about 30 seconds, through the existing worktree change refresh queue so bursts coalesce. Skip distros that are not running so focusing Orca never starts WSL.

    Both stay in the renderer and reuse existing listing and merge code; no IPC or wire change. I am happy to open a PR if a maintainer approves the approach.

  4. gethubguy commented on Nov 17, 2026

    @gethubguy

    Still present in 1.4.261 (Windows 11 + WSL2). Five worktrees removed with git worktree remove from a WSL shell stay in the sidebar; the trace log shows no worktree list catalog scan after the removal. Opening Delete on one of these rows also shows a misleading result, filed as #43678.

  5. gethubguy commented on Nov 17, 2026

    @gethubguy

    Follow-up on my comment above: deleting just one of the ghost rows from its Delete dialog cleared all the others in the same project. The trace log shows Orca re-reading git worktree list --porcelain for that project one second after the delete, and every row whose worktree was gone disappeared. So the sidebar does reconcile; it just never re-reads the list after an outside git worktree remove. Workaround until then: delete any one ghost row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions