Repository navigation
Conversation
…dialog shouldShowWorktree reveals any path listed in importedExternalWorktreePaths, including agent-scratch ones, but no surface could add a path there: the discovery inbox is the only writer and its candidate selector drops agent-scratch. Worktrees under .claude/worktrees were therefore unreachable, and non-Orca worktrees only had the repo-wide show/hide toggle. Add a per-worktree import list to the Non-Orca worktrees dialog covering every hidden ownership, plus a hide action for worktrees an individual import revealed. Worktrees the repo-wide toggle reveals are excluded from that action, since dropping their path would not hide them.
Drive the real round trip a unit test cannot reach: git worktrees on disk, one external and one under .claude/worktrees, classified by the main process and imported through the dialog. Capturing that flow also surfaced rows printing the worktree name and its branch as two identical lines. A worktree with no Orca metadata takes its display name from the branch, so collapse the branch line when the two match.
Greptile SummaryThis PR adds per-worktree import functionality to the "Non-Orca worktrees" visibility dialog, allowing users to reveal individual agent-scratch worktrees (which the repo-wide
Confidence Score: 5/5Safe to merge. All changed code paths have unit and E2E test coverage, and the two issues raised in prior review rounds are demonstrably addressed by the new logic. The hide-is-a-no-op compound case is now handled correctly: getIndividuallyImportedWorktrees calls shouldShowWorktree with the import list withheld so that a worktree the repo-wide toggle would reveal regardless is excluded from the hide candidates — and the replacement test fails against the old predicate. The rollback failure path now returns a distinct ambiguous-state message rather than the same retry prompt, and both branches are covered by tests. The scheduler coalescing is correct: the refreshAll/pendingRepoIds state machine resets per batch and a targeted request cannot narrow an already-queued full refresh. The runtimeWorktreeRepoHostKey refactoring adds a backwards-compatible comparisonPlatformByRepoId map for legacy IDs and is validated by the new colliding-repo-id test in orca-runtime.test.ts. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/shared/hidden-worktree-import.ts | New module implementing importable/imported worktree selectors and path list helpers; getIndividuallyImportedWorktrees correctly withholds the import list when calling shouldShowWorktree to catch the compound toggle+import case. |
| src/renderer/src/components/sidebar/hidden-worktree-import-actions.ts | Optimistic import/hide action with rollback; correctly distinguishes ambiguous-state from plain retry when the rollback write itself fails (hiddenWorktreeRollbackError path). |
| src/renderer/src/components/sidebar/HiddenWorktreeImportSection.tsx | New UI component listing importable and individually-imported worktrees; correctly defers the pending spinner by 200 ms to avoid flicker on fast local imports. |
| src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx | Extended with HiddenWorktreeImportSection; action state is keyed by repoHostIdentity and guarded by a generation counter so cross-project interleaving is safe. |
| src/renderer/src/hooks/runtime-project-refresh-scheduler.ts | Adds per-repoId targeted refresh coalescing; refreshAll/pendingRepoIds state machine correctly resets on each new pending batch and prevents a targeted request from narrowing an already-queued full refresh. |
| src/main/runtime/orca-runtime.ts | Refactors platformByRepoId to platformByRepoHostKey to disambiguate runtime repos sharing an ID on different hosts; adds buildRuntimeWorktreeVisibilityContexts to batch visibility context construction and removes per-worktree store lookups at ps-poll time. |
| src/renderer/src/store/slices/worktrees.ts | Added suppressLineageRefresh option to fetchWorktrees; correctly skips the remote lineage round-trip for scheduler-driven targeted per-repo refreshes while preserving it for full and action-driven refreshes. |
| tests/e2e/hidden-worktree-import.spec.ts | New E2E spec covering the full import/hide round trip with real git worktrees; correctly defers fixture cleanup to post-Electron-shutdown to avoid EPERM on Windows. |
| src/shared/external-worktree-inbox.ts | Adds createExplicitExternalWorktreePathMatcher for O(1) per-worktree lookups instead of scanning the imported paths array each time; normalizes on construction. |
| src/shared/worktree-ownership.ts | shouldShowWorktree and toDetectedWorktree now accept an optional pre-built path matcher to avoid rebuilding the Set on every call; falls back to the existing per-path helper when matcher is absent. |
Reviews (4): Last reviewed commit: "fix(runtime): keep mobile worktree metad..." | Re-trigger Greptile
📝 WalkthroughWalkthroughAdds hidden worktree selection, persistence actions, host-aware visibility, targeted runtime refreshes, localized sidebar controls, and visibility-dialog integration. Adds shared, component, action, runtime, and end-to-end tests for these flows. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/hidden-worktree-import-actions.ts (1)
42-66: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueGuard against rejection paths in
applyImportedPaths.
updateRepoandfetchWorktreescurrently handle API failures and returnfalse, so this path is defensive: add atry/catcharound the await chain and clear pending with an error/retry state if a caller passes a rejecting dependency.Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 287b6180-1a6a-4862-8965-5c1b66c4da0a
📒 Files selected for processing (13)
src/renderer/src/components/sidebar/HiddenWorktreeImportSection.test.tsxsrc/renderer/src/components/sidebar/HiddenWorktreeImportSection.tsxsrc/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsxsrc/renderer/src/components/sidebar/hidden-worktree-import-actions.test.tssrc/renderer/src/components/sidebar/hidden-worktree-import-actions.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/hidden-worktree-import.test.tssrc/shared/hidden-worktree-import.tstests/e2e/hidden-worktree-import.spec.ts
…ason a worktree shows Review caught the hide action doing nothing when a worktree is revealed twice over: individually imported and also covered by the repo-wide show toggle. Dropping its path leaves it on screen. Ask shouldShowWorktree with the import list withheld instead of re-deriving the condition, so the judgement stays on the rule that owns it. The previous test passed only because its import list was empty; the replacement fails against the old predicate. Also from review: - surface a distinct error when a failed refresh cannot be rolled back, rather than reporting a plain retry against a record that moved - key the dialog's action state by project, so a pending or failed action does not bleed into the next project opened - register the E2E fixture for post-Electron cleanup, take worktree rows through the escaping locator helper, and assert that show leaves scratch hidden - use the zh catalog's own terms for worktree and agent
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/hidden-worktree-import.spec.ts (1)
94-145: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover individual import of the external candidate.
This test verifies that the external worktree is affected by the repo-wide toggle, but only exercises the individual Import/Hide flow for the scratch worktree. Add an assertion that importing the external candidate makes it visible and that its individual Hide action works.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5c0e03f7-236a-4f61-bf2e-f4186b6e85c2
📒 Files selected for processing (11)
src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsxsrc/renderer/src/components/sidebar/hidden-worktree-import-actions.test.tssrc/renderer/src/components/sidebar/hidden-worktree-import-actions.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/hidden-worktree-import.test.tssrc/shared/hidden-worktree-import.tstests/e2e/hidden-worktree-import.spec.ts
🚧 Files skipped from review as they are similar to previous changes (9)
- src/renderer/src/components/sidebar/hidden-worktree-import-actions.test.ts
- src/renderer/src/components/sidebar/hidden-worktree-import-actions.ts
- src/renderer/src/i18n/locales/es.json
- src/shared/hidden-worktree-import.test.ts
- src/shared/hidden-worktree-import.ts
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/ko.json
Conflicts were limited to the localization catalogs, which are generated: take upstream's five files, regenerate the keys this branch adds with sync:localization-catalog, and reapply the ko/ja/es/zh translations. The non-English catalogs no longer need full parity with en.json upstream, so the regenerated keys are added directly rather than mirrored by the fixer.
…rktrees # Conflicts: # src/renderer/src/store/slices/runtime-status.test.ts # src/renderer/src/store/slices/runtime-status.ts
The locale catalogs conflicted again, so take main's en.json and regenerate the keys this branch adds; the ko/ja/es/zh translations survived the auto-merge. One conflict git could not see. main added a resolveKnownWorkspaceFileTarget call to isRuntimeWorktreeVisible using the old single-argument signature, while this branch had changed that method to take the repo explicitly so a repo id shared across hosts resolves correctly. The text merged; the types did not. Resolved the way the branch's other two call sites already do — build the visibility contexts and look the worktree up by repo/host key — rather than falling back to getRepo(worktree.repoId), which would reintroduce the ambiguity.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f3a2bf3-60b0-4fda-8514-d484b77257bf
📒 Files selected for processing (30)
.oxlintrc.jsonconfig/scripts/relay-watcher-fault-harness.mjssrc/main/ipc/worktrees.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/renderer/src/components/github/GitHubMarkdownComposerEditorPane.tsxsrc/renderer/src/components/sidebar/HiddenWorktreeImportSection.test.tsxsrc/renderer/src/components/sidebar/HiddenWorktreeImportSection.tsxsrc/renderer/src/components/sidebar/WorktreeList.tsxsrc/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsxsrc/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsxsrc/renderer/src/components/sidebar/hidden-worktree-import-actions.test.tssrc/renderer/src/components/sidebar/hidden-worktree-import-actions.tssrc/renderer/src/hooks/runtime-project-refresh-scheduler.test.tssrc/renderer/src/hooks/runtime-project-refresh-scheduler.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/worktree-helpers.tssrc/renderer/src/store/slices/worktrees.tssrc/shared/external-worktree-inbox.tssrc/shared/hidden-worktree-import.test.tssrc/shared/hidden-worktree-import.tssrc/shared/runtime-client-events.tssrc/shared/worktree-ownership.tstests/e2e/hidden-worktree-import.spec.tstests/e2e/setup-script-prompt-unreadable-orca-yaml.spec.ts
🚧 Files skipped from review as they are similar to previous changes (10)
- src/renderer/src/components/sidebar/hidden-worktree-import-actions.test.ts
- src/renderer/src/i18n/locales/es.json
- src/renderer/src/components/sidebar/HiddenWorktreeImportSection.test.tsx
- src/shared/hidden-worktree-import.test.ts
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/components/sidebar/hidden-worktree-import-actions.ts
- src/renderer/src/i18n/locales/zh.json
- src/shared/hidden-worktree-import.ts
| const repo = findRepoForHost(repos, projectId, { settings }) | ||
| if (repo) { | ||
| handleOpenWorktreeVisibility(repo) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preserve the originating host for visibility recovery.
Line 6748 resolves projectId with the currently focused host. If the recovery started from the same repository ID on another host, this opens the visibility dialog for the wrong repository. Store the originating hostId with suppressExternalWorktreeInboxRepoId and pass it to findRepoForHost or directly to handleOpenWorktreeVisibility.
|
Thanks for this work — per-worktree recovery from the visibility dialog landed in #13652, so this PR is now superseded. |
Summary
Closes #11274.
Adds a per-worktree import list to the "Non-Orca worktrees" dialog, so you can pull in one hidden worktree without flipping the whole repo — and so agent scratch worktrees become reachable at all.
shouldShowWorktreealready treats a path inimportedExternalWorktreePathsas an override that beats theagent-scratchrule; the comment above it says "only an explicit import or selected checkout reveals it". Nothing could write a scratch path there, though. The only writer is the discovery inbox, whose candidates pass throughisUserFacingExternalWorktree, which filtersagent-scratchout. So a worktree under.claude/worktreescouldn't be opened in Orca short of editingorca-data.json.That also kept AI Vault's Resume disabled for every session that ran in one of those worktrees, since Resume needs the session cwd to resolve to a known worktree.
The new section sits under the existing toggle and lists every hidden worktree —
external,unknown-legacy,agent-scratch— with Import per row and "Import all N" for bulk. Scratch rows carry a badge so an unfamiliar worktree doesn't read as a sidebar bug.Two things worth flagging for review:
Hide is only offered when the explicit import is the sole reason a worktree shows. A worktree revealed twice over — imported individually and covered by the repo-wide
showtoggle — would stay on screen after its path is dropped, so the button would silently do nothing. Rather than re-derive that condition, the selector asksshouldShowWorktreewith the import list withheld and keeps the row only if the answer is no.The write is optimistic with a rollback: set the path list, force an authoritative refresh, and if the refresh fails put the old list back and surface the error in the dialog rather than leaving the repo record ahead of the sidebar. Same shape as
new-external-worktrees-inbox-actions.ts.No defaults move. Scratch stays hidden until imported, which is what #9535 asked for. The section is also ownership-agnostic, so entries added to
AGENT_SCRATCH_PATH_PREFIXESlater need no UI work.Screenshots
Repo parked on the default
hide, with one external worktree and two scratch ones. The scratch worktree at the bottom was imported from this dialog.Testing
pnpm lintpnpm typecheckpnpm test(see note)pnpm build39,676 passing. One suite fails on my machine for a reason that predates this branch:
automation-schedules.test.tsexpects'Sundays at ...'andIntlon ako-KRhost returns'일요일s at ...'. It passes underLANG=en_US.UTF-8. A few others (transcript-watch-liveness,project-view-wrapper-source-context-boundary,windows-port-scan) failed intermittently under full-suite parallelism across runs and pass in isolation. None are in the import graph of anything this PR touches.27 new unit cases plus one E2E spec:
showtoggle also reveals being dropped from the hide list while an imported scratch one is kept, and path add/remove being idempotent and separator-tolerant.tests/e2e/hidden-worktree-import.spec.ts): real git worktrees, one external and one under.claude/worktrees. Neither is in the sidebar with the repo onhide; importing the scratch one puts it there and leaves the external one hidden; Hide takes it back out.Also exercised by hand against a repo with 7 real scratch worktrees, 4 of which were unreachable before this.
AI Review Report
Reviewed with an AI coding agent.
normalizeRuntimePathForComparisonthrough the existing inbox helpers, which already cover Windows drive-letter casing, separator folding and WSL UNC aliases. The scratch matcher is untouched, and its anchoring to a registered checkout means nothing here assumes a POSIX-shaped path. No new shortcuts or shortcut labels.importedExternalWorktreePathsis already accepted by the runtime repo-update schema, so the action works unchanged on SSH and runtime hosts. Selectors requireauthoritative === true, so a disconnected SSH repo falling back tometadata-fallbackshows no list rather than a stale one. The dialog is gated onisGitRepoKind, so folder workspaces are unaffected.shouldShowWorktree's ordering are all unchanged — this only feeds a branch that already existed. The inbox andImportedWorktreesVisibilityLinebehave identically; their selectors are untouched and their tests pass.aria-labelandaria-busyon the section, truncation with the full path in a tooltip, disabled buttons while pending,role="alert"on the error. All nine new strings go throughtranslate(), withko/ja/es/zhtranslated rather than left as English.What came out of the review:
useAppStore.getState()calls inside the action callback were swapped for the already-subscribed selectors, and the E2E capture caught rows printing the worktree name and its branch as two identical lines, since a worktree with no Orca metadata takes its display name from the branch — the branch line now collapses when they match.The bot reviews on this PR then caught a real one, and it was mine: the hide list checked only whether a path sat in
importedExternalWorktreePaths, never whether the repo-wide toggle was also revealing the worktree, so hide could still be a no-op for the compound case. The test I had written for it passed only because its import list was empty. The selector now defers toshouldShowWorktree, and the replacement test fails against the old predicate. Four smaller ones came from the same pass: a rollback whose own write failed reported a plain retry, the dialog's action state wasn't keyed by project, the E2E spec deleted its fixture before Electron shut down and builtdata-worktree-idselectors without escaping, and the zh strings didn't use the catalog's own terms for worktree and agent.Security Audit
No filesystem access, no path construction, no shell interpolation, no command execution — the change compares paths and writes a string array.
Every path comes from
git worktree listoutput that Orca scanned and classified itself, not from user input. It goes through the existingupdateRepo, which already validatesimportedExternalWorktreePathsas an array of strings before persisting, and through the runtime schema for SSH hosts. Importing a path only affects sidebar visibility; it can't make Orca show a pathgit worktree listdidn't report, because the selectors work off the detected list, so a stale entry in the record simply never matches a row.No new IPC channels, dependencies, secrets, auth or network paths.
Notes
importedExternalWorktreePathsaccumulates entries for worktrees that no longer exist. Harmless — nothing matches them — but the list only grows. Pruning has to tell "deleted" apart from "not in this scan", so it's a separate change.ELI5
Orca hides worktrees agents create inside your repo, and there was no button to un-hide one even though the code was written to allow it. The project's worktree dialog now lists them so you can bring in just the ones you want.