Repository navigation
fix(projects): refuse a Git-to-folder type change while the project has other worktrees - #29265
Conversation
…ked worktrees with saved tabs (STA-10638) A folder project lists only its main folder and its folder workspaces, so switching a Git project to folder drops every linked worktree from the next refresh, and Orca purges their saved tabs as if they had been deleted. The same repo write that already refuses the folder-to-Git case now also refuses this one, counting only ids with saved tabs or details on the project's own host, and comparing ids exactly as the purge does. Folder workspaces left over from an earlier switch never block, so a converted project can still go back to folder mode.
|
Converting a Git project to a folder project hides linked worktrees from its next listing, allowing deleted-workspace cleanup to discard their saved tabs. This PR refuses that change before writing while the project's own host has worktree records that folder mode cannot show. Leftover folder-workspace rows do not block conversion and become visible again in folder mode. Status: review clean; validation blocked on the fresh main comparison. Reviewed head The metadata-only replacement removes the earlier session-scanning failures and uses the existing host ownership filter. No review-loop code changes were committed or pushed. The larger uncommitted repair was saved locally then discarded under the author's ruling. Verified:
Unverified: the requested fresh main comparison at Intended: owned worktree records block conversion even after tabs close. Accepted author limit: startup cleanup can remove a record for a checkout absent over 30 days while headless saved sessions survive; recreating that path and converting before discovery can leave the residue uncounted. Deferred outside B: pre-existing setup host targeting and sibling-host folder-display limitations, plus manual folder-to-Git root proof. The pending option to show folder workspaces in Git projects was not built. Project-kind-dependent catalog membership remains a temporary architectural difference tracked in STA-10638; no broader catalog feature is authorized here. For Brennan's review
The two judgment points are the owned-record boundary and exact-ID exemptions, and the refusal/message before mutation. |
…orktree records only Every worktree a Git listing shows gets a saved record, and the missing-worktree prune keeps any record that still has saved tabs, so the records already cover every workspace with something to lose. Drop the saved-session scan and its per-partition owner rules; count this host's owned worktree records instead, with the existing same-id sibling rule. Known limit: a record the 30-day startup cleanup removed for a checkout that was missing, then recreated at the same path before any listing, is not counted; a desktop launch clears that workspace's tabs anyway.
|
Closing per Brennan: the Git-to-folder data loss this guards against could not be reproduced on main (a local project's automatic Git upgrade switches it straight back to Git, so the tabs survive). The branch is kept if it is ever needed. |




ELI5
Switching a Git project to a plain folder project hides every extra Git worktree it has, and Orca then wipes those worktrees' saved tabs as if they had been deleted. Now Orca refuses that switch while the project has other worktrees, and says why.
Stacked on #29257 (the same fix for the folder-to-Git direction, which is the bug a user reported). Review only the top two commits.
What Changed
The problem. Which workspaces a project has is worked out from its type each time Orca lists them. A folder project lists exactly its main folder and its folder workspaces. A Git project's linked worktrees (other checkouts of the same repo) are not in that list, so after a switch to folder mode they drop out of the next refresh, and Orca's cleanup for deleted workspaces clears their tabs, layouts and sleeping agents. The user who reported #29257's bug tried exactly this switch as a workaround; it would have wiped the new Git worktrees they had just made.
The change. The single repo write that #29257 guards now also refuses a Git-to-folder change while the project has other worktrees on that host. Nothing is written, and the message says: "This Git project has N other worktrees that a folder project can't show, so its type was not changed. Delete those worktrees first, or keep it as a Git project."
How "other worktrees" is decided:
Known limit: Orca's 30-day startup cleanup removes the record of a worktree whose checkout has been missing that long, without looking at saved tabs. If that checkout is recreated at the same path and the type is changed before any listing runs, its leftover tabs are not counted. In practice a desktop launch already clears tabs for a missing checkout, so this only matters for a server running with no desktop attached.
What you see. Before: switching a Git project with linked worktrees to folder mode succeeds, and those worktrees' tabs are gone after the next refresh. After: the switch is refused with the message above. A Git project with no other worktrees converts as before.
Why
Same root cause as #29257: changing a project's type silently changes which workspaces it lists, and the cleanup treats "no longer listed" as "deleted". Keeping the decision in the one write every type change goes through covers both directions with one rule.
Alternatives considered:
C:\repoversusC:/repo) still counts as shown. Rejected because the tab cleanup compares exact ids, so that case really would lose its tabs.Linked Issue
Linear STA-10638
Visual Proof
Both requested branch scenarios passed real Electron QA on M4Air at
5c2bfd3270215a458df6e675b5451b16317a348b. With a linked worktree and two real terminal tabs, the CLI refused conversion with the expected message; after refresh, the worktree, both tabs, visible order and selection remained. With only a leftover folder-workspace row, the real CLI converted successfully; after reload, folder mode showed the root and leftover workspace.The fresh main comparison at
93095c2f67447474c1894e477f6695cdf5e98c16is incomplete: repeated M4Air overload required stopping the test copy, and both Windows machines were below the free-memory threshold. An older main attempt accepted the command but restored Git kind and retained tabs after reload; no main tab-loss reproduction is claimed. The PR remains draft until the required comparison completes.Testing
persistence-update-repo.test.tsandrepo-update-host-guard.test.ts). CI remains the full lint and typecheck gate.Review
Fresh correctness and readiness reviews on
5c2bfd3270215a458df6e675b5451b16317a348bfound no new proven PR-caused defect in the top two commits. The earlier session-scanning findings no longer apply to the metadata-only replacement; the host ownership issue uses the existing ownership filter. Pre-existing setup host targeting and sibling-host folder-display limitations remain outside this PR. No review-loop code changes were committed or pushed. The exact-head full PR workflow completed successfully. Its aggregate job intentionally skips its runner after all selected required jobs succeed. Validation remains blocked on the fresh main comparison. The single review status comment carries the current evidence.Agent skill upstream boundary
Notes
No new saved field and no wire change. A record for a worktree deleted outside Orca can block the switch until the usual cleanup removes it; refusing is the safe side of that trade.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author: @BrennanKB5