Repository navigation
fix(worktrees): make hidden agent worktrees recoverable from the visibility dialog - #13652
Conversation
…bility dialog A discovered agent scratch worktree (.claude/worktrees, .gsd-workspaces) was a one-way door: the non-Orca visibility toggle never reveals scratch by design (#9388), the inbox never announces it, and the dialog listed nothing — so once hidden it was unreachable from the UI while sitting on disk. The per-path import exception has outranked the hidden rule all along; no surface offered it. The dialog now refetches an authoritative list on open (a stale snapshot must not read as 'nothing hidden'), lists hidden importable worktrees, and offers a per-row Show wired to the existing inbox import action, which already merges the import + baseline and rolls back on a failed refresh. When the list cannot be read the dialog says so and offers a retry instead of claiming the repo has nothing. No new settings, schema, or persistence: recovery rides entirely on importedExternalWorktreePaths, which every host already stores and validates. The repo-wide toggle is untouched and still never reveals scratch. Fix #10324 Co-authored-by: Gldywn <[email protected]>
…isibility dialog - row Show stays disabled until the open-time authoritative scan settles; a click mid-scan could join the pre-write refetch and read success off a list computed before the import landed, a silent no-op on slow hosts - checking/failed indicators follow the scan state alone, so a warm older snapshot cannot present stale rows as current with no failure indication - ownership-neutral section copy: non-scratch rows are listed too when the repo-wide switch is off
…tate - Try again is locked while a row import is in flight; a retry scan started before the import's write lands can absorb the import's own refetch and report success off a pre-import list - a successful row import (which requires a successful authoritative refetch) clears an earlier failed open-time scan instead of leaving a contradictory alert over the refreshed list - zh: 智能体 for agent (代理 reads as network proxy); polite live region on the checking hint
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe worktree visibility dialog now performs authoritative scans when opened, shows loading and failure states, supports retries, and allows individual hidden worktree imports. Importability filtering retains eligible hidden external and agent-scratch worktrees while excluding selected and managed worktrees. A help popover and localized messages describe visibility states and actions in five locales. Tests cover recovery, race prevention, error handling, and visibility counts. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 93389d62-db6b-4eff-b1b9-9ffab56b0312
📒 Files selected for processing (9)
src/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsxsrc/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsxsrc/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/external-worktree-inbox.test.tssrc/shared/external-worktree-inbox.ts
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: bf50fa37-caf1-4ec5-81ff-14c8fe1fa42b
📒 Files selected for processing (9)
src/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsxsrc/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsxsrc/renderer/src/components/sidebar/WorktreeVisibilityHelpPopover.test.tsxsrc/renderer/src/components/sidebar/WorktreeVisibilityHelpPopover.tsxsrc/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.json
🚧 Files skipped from review as they are similar to previous changes (5)
- src/renderer/src/i18n/locales/es.json
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsx
- src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx
- src/renderer/src/i18n/locales/ja.json
| <div | ||
| className="inline-flex" | ||
| onPointerEnter={() => setOpen(true)} | ||
| onPointerLeave={() => setOpen(false)} | ||
| > |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Confirm the local Popover primitive portals content to document.body, matching upstream Radix behavior.
fd -i popover.tsx --exec cat -n {}Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- target component ---'
target=$(fd -i -t f 'WorktreeVisibilityHelpPopover.tsx' | head -n 1)
cat -n "$target"
printf '%s\n' '--- related tests ---'
fd -i -t f . | rg 'WorktreeVisibilityHelpPopover|popover' | head -n 80
printf '%s\n' '--- Popover primitive and relevant package metadata ---'
popover=$(fd -i -t f 'popover.tsx' | rg 'components/ui/popover\.tsx$' | head -n 1)
cat -n "$popover"
rg -n '"radix-ui"|"`@radix-ui/react-popover`"|radix-ui' package.json pnpm-lock.yaml yarn.lock package-lock.json 2>/dev/null | head -n 40Repository: stablyai/orca
Length of output: 12088
🏁 Script executed:
#!/bin/bash
set -e
target=$(fd -i -t f 'WorktreeVisibilityHelpPopover.tsx' | head -n 1)
printf '%s\n' '--- target ---'
cat -n "$target"
printf '%s\n' '--- matching tests/files ---'
fd -i -t f . | rg 'WorktreeVisibilityHelpPopover|popover' | head -n 80
printf '%s\n' '--- local primitive ---'
popover=$(fd -i -t f 'popover.tsx' | rg 'components/ui/popover\.tsx$' | head -n 1)
cat -n "$popover"
printf '%s\n' '--- dependency declarations ---'
for f in package.json pnpm-lock.yaml yarn.lock package-lock.json; do
[ -f "$f" ] && rg -n '"radix-ui"|"`@radix-ui/react-popover`"|radix-ui' "$f" | head -n 40
doneRepository: stablyai/orca
Length of output: 11526
🏁 Script executed:
#!/bin/bash
set -e
target=$(fd -i -t f 'WorktreeVisibilityHelpPopover.tsx' | head -n 1)
cat -n "$target"
popover=$(fd -i -t f 'popover.tsx' | rg 'components/ui/popover\.tsx$' | head -n 1)
cat -n "$popover"
fd -i -t f . | rg 'WorktreeVisibilityHelpPopover|popover' | head -n 80Repository: stablyai/orca
Length of output: 9701
🏁 Script executed:
#!/bin/bash
set -e
test_file=$(fd -i -t f 'WorktreeVisibilityHelpPopover.test.tsx' | head -n 1)
cat -n "$test_file"
printf '%s\n' '--- pointer-related tests and handlers ---'
rg -n -C 5 'pointer|mouse|open|setOpen|relatedTarget|PopoverContent' "$test_file" src/renderer/src/components/sidebar/WorktreeVisibilityHelpPopover.tsx
printf '%s\n' '--- Radix Popover source references in lockfile and repository ---'
rg -n -C 3 'PopoverPrimitive|DismissableLayer|onPointerDownOutside|Portal' src/renderer/src/components/ui src/renderer/src/components/sidebar pnpm-lock.yaml | head -n 160Repository: stablyai/orca
Length of output: 26612
🏁 Script executed:
#!/bin/bash
set -e
test_file=$(fd -i -t f 'WorktreeVisibilityHelpPopover.test.tsx' | head -n 1)
cat -n "$test_file"
rg -n -C 5 'pointer|mouse|open|setOpen|relatedTarget|PopoverContent' "$test_file" src/renderer/src/components/sidebar/WorktreeVisibilityHelpPopover.tsxRepository: stablyai/orca
Length of output: 15864
Keep the help popover open while moving into its content.
PopoverContent is portaled outside the wrapper, so onPointerLeave closes the popover before the pointer reaches the content. Adding onPointerEnter to PopoverContent alone is unreliable because closing can unmount the content first. Defer and cancel the close, or keep the content mounted during the transition. Add a trigger-to-content pointer test.
Latest UI — final stateAll screenshots below are from the same final build at Always show offYes, the icon-only help popover is still present. It explains what is hidden by default, names Always show onThe existing Claude worktrees are visible, and a Result in the sidebarThe newly created |
Independent Electron QA (Grok) — PASSExact head: Actions exercised
VerdictPASS — recovery + Always show policy work end-to-end for both agent roots at Screenshots |
…bility dialog (stablyai#13652) * fix(worktrees): make hidden agent worktrees recoverable from the visibility dialog A discovered agent scratch worktree (.claude/worktrees, .gsd-workspaces) was a one-way door: the non-Orca visibility toggle never reveals scratch by design (stablyai#9388), the inbox never announces it, and the dialog listed nothing — so once hidden it was unreachable from the UI while sitting on disk. The per-path import exception has outranked the hidden rule all along; no surface offered it. The dialog now refetches an authoritative list on open (a stale snapshot must not read as 'nothing hidden'), lists hidden importable worktrees, and offers a per-row Show wired to the existing inbox import action, which already merges the import + baseline and rolls back on a failed refresh. When the list cannot be read the dialog says so and offers a retry instead of claiming the repo has nothing. No new settings, schema, or persistence: recovery rides entirely on importedExternalWorktreePaths, which every host already stores and validates. The repo-wide toggle is untouched and still never reveals scratch. Fix stablyai#10324 Co-authored-by: Gldywn <[email protected]> * fix(worktrees): honest scan states and race-safe row actions in the visibility dialog - row Show stays disabled until the open-time authoritative scan settles; a click mid-scan could join the pre-write refetch and read success off a list computed before the import landed, a silent no-op on slow hosts - checking/failed indicators follow the scan state alone, so a warm older snapshot cannot present stale rows as current with no failure indication - ownership-neutral section copy: non-scratch rows are listed too when the repo-wide switch is off * fix(worktrees): close the retry race window and clear stale failure state - Try again is locked while a row import is in flight; a retry scan started before the import's write lands can absorb the import's own refetch and report success off a pre-import list - a successful row import (which requires a successful authoritative refetch) clears an earlier failed open-time scan instead of leaving a contradictory alert over the refreshed list - zh: 智能体 for agent (代理 reads as network proxy); polite live region on the checking hint * fix(worktrees): serialize visibility dialog actions * fix(worktrees): clarify persistent visibility policy * fix(worktrees): clarify hidden worktree list * Explain hidden worktree defaults * Show agent worktrees with Always show * fix(worktrees): bound visibility dialog state and rendering * fix(worktrees): preserve visibility mutation fences across dismissal * fix(worktrees): scope visibility mutations by host --------- Co-authored-by: Gldywn <[email protected]>











Summary
Agent scratch worktrees under
.claude/worktrees/*and.gsd-workspaces/*became a one-way door after they were hidden by default: the old non-Orca policy could not reveal them, the discovery inbox intentionally omitted them, and the visibility dialog offered no recovery path. The reporter in #10324 asked for a toggle that restores Claude worktrees like pre-1.4.150; #10560 and #11799 established the repo-level opt-in precedent.This PR makes the
Non-Orca worktreesdialog the focused recovery and policy surface:Checking…/Could not list+Try againstates instead of treating a stale or fallback snapshot as empty.Hidden worktrees (count)lists every hidden importable worktree, including agent scratch, with its exact repo-relative path and a per-rowShow. That action reuses the existing per-path import mechanism, authoritative confirmation, and rollback behavior.Import/Hideaction is now an accessibleAlways showswitch. Enabling it sets both the regular non-Orca policy and the dedicated optionalagentWorktreeVisibilitypolicy, so current and future worktrees under both recognized agent roots appear automatically. Disabling it restores hidden-by-default behavior while preserving explicit per-path choices.Always showcovers current and future worktrees.The default remains safe: an absent
agentWorktreeVisibilitymeans hide for new and legacy repos. The new field is optional on the existing repo-update payload, follows #10560/#11799, and degrades safely with independently updated clients and hosts. No new IPC channel, dependency, discovery-inbox behavior, or background polling is added. Future per-source checkboxes and user-added agent-worktree locations are deliberately left as a separate UI/model extension; this policy is already independent so that split will not require reinterpreting the regular non-Orca setting.Fix #10324
Latest UI walkthrough
All current screenshots are consolidated in the latest UI walkthrough. They were captured from the final build at
424d041e47and show the off, on, and resulting sidebar states.Follow-up: per-source visibility controls
A future UI should replace the combined agent-worktree policy with a list of worktree sources that users can manage independently:
.claude/worktrees/*and.gsd-workspaces/*, with its own checkbox or switch.This PR deliberately does not add that management UI, but stores the agent policy independently so the follow-up can be implemented without a migration or behavior change for the regular non-Orca setting.
Testing
pnpm lintpnpm typecheckpnpm test— affected scope (224 files / 2050 tests acrosssrc/sharedand the sidebar components) run green three times through independent review lanes; the full suite has known environment-dependent failures on this machine unrelated to this diffpnpm build—build:electron-viteTests cover authoritative enumeration, per-row recovery, scan/write race locks, help-popover interaction, mixed regular/agent policy state, both
.claude/worktrees/*and.gsd-workspaces/*, hidden-by-default legacy behavior, local IPC, disk persistence, and remote RPC transport. The final same-model review ran 634 focused tests plus full typecheck, oxlint/type-aware lint, React Doctor, max-lines, formatting, localization, and diff checks.AI Review Report
Final follow-up review used the same model and high reasoning against the complete uncommitted diff. It fixed stale policy comments and added missing mixed-state, both-root, IPC, persistence, and RPC coverage, then returned explicitly CLEAN. The policy is O(1) state plus the existing linear worktree scan; no polling, watcher, or sidebar hot-path work was added.
Adversarial two-lane review (independent architecture lane and reproduction lane), three rounds to a clean final round. Six findings were fixed along the way, all in the new code: a mid-scan
Showclick could join the pre-write refetch and report success off a pre-import list; bulk actions could likewise race open-time scans or row imports; and row/retry actions could race a bulk update (all dialog actions now mutually lock across scans and writes); a warm older snapshot could mask a failed refetch (failure indicators now follow the scan state alone, and a confirmed import success clears a stale failure); section copy was accurate only for scratch rows (reworded); zh used 代理 (proxy) for agent (now 智能体). Cross-platform checked explicitly: path comparison and storage go through the shared normalizers on every host (Windows drive letters, WSL UNC, NFC), the repo-relative display falls back to the absolute path outside the checkout, and no shortcuts or shell behavior are touched. Remote/SSH:requireAuthoritativefails closed with a manual retry; no polling or auto-retry added; each row action is one update plus one authoritative refetch with rollback.The final same-model Codex review also tightened the help copy so it describes the policy only for newly added repositories and does not overclaim that Orca-created worktrees bypass unrelated sidebar filters. The icon-only popover has an accessible name and focused hover, keyboard, Escape, and outside-dismissal coverage.
Security Audit
No new IPC channel or method.
agentWorktreeVisibilityis a two-value optional field on the existing repo-update payload, validated at local IPC and remote RPC boundaries and covered through disk persistence. Absent values remainhide, so old data and mixed-version peers fail closed. Paths are classified, compared, and displayed through existing cross-platform helpers; they are never resolved, executed, or passed to a shell. No dependency, auth, or secret changes.Notes
.claude/worktrees/<uuid>a running agent creates and deletes, and each dismissal would append dead paths to a persisted baseline nothing prunes. The dialog lists them on demand instead.