Skip to content

fix(worktrees): make hidden agent worktrees recoverable from the visibility dialog - #13652

Merged
brennanb2025 merged 11 commits into
mainfrom
fix/recover-hidden-agent-worktrees
Aug 13, 2026
Merged

brennanb2025 merged 11 commits into
mainfrom
fix/recover-hidden-agent-worktrees

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

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 worktrees dialog the focused recovery and policy surface:

  • The dialog refetches an authoritative worktree list on open and shows honest Checking… / Could not list + Try again states 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-row Show. That action reuses the existing per-path import mechanism, authoritative confirmation, and rollback behavior.
  • The misleading one-shot Import / Hide action is now an accessible Always show switch. Enabling it sets both the regular non-Orca policy and the dedicated optional agentWorktreeVisibility policy, 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.
  • Dialog actions are mutually locked while scans or writes are in flight, preventing bulk, row, and retry refreshes from coalescing onto stale pre-write work.
  • An icon-only help popover explains which worktrees default hidden, why, the exact built-in agent paths, and that Always show covers current and future worktrees.

The default remains safe: an absent agentWorktreeVisibility means 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 424d041e47 and 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:

  • Show each recognized source, such as .claude/worktrees/* and .gsd-workspaces/*, with its own checkbox or switch.
  • Add an Add location action so users can include custom worktree roots.
  • Keep source matching/classification separate from visibility preferences so sources can be added or changed without reinterpreting existing settings.
  • Preserve the current safe default: newly recognized or user-added sources remain hidden until explicitly enabled.

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 lint
  • pnpm typecheck
  • pnpm test — affected scope (224 files / 2050 tests across src/shared and 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 diff
  • pnpm build — build:electron-vite
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Tests 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 Show click 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: requireAuthoritative fails 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. agentWorktreeVisibility is 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 remain hide, 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

brennanb2025 and others added 3 commits August 10, 2026 13:12
…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
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #10324 by allowing hidden Claude and agent worktrees to be discovered and shown in the project sidebar.
Out of Scope Changes check ✅ Passed The implementation, tests, and localization changes support the visibility-dialog recovery objective without unrelated code changes.
Title check ✅ Passed The title clearly and concisely describes the main change: recovering hidden agent worktrees from the visibility dialog.
Description check ✅ Passed The description includes all required sections and provides detailed change, testing, AI review, security, platform, and follow-up information.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c0c893d and 08f24ba.

📒 Files selected for processing (9)
  • src/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsx
  • src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/external-worktree-inbox.test.ts
  • src/shared/external-worktree-inbox.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e75c8d6 and 54b07f1.

📒 Files selected for processing (9)
  • src/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsx
  • src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx
  • src/renderer/src/components/sidebar/WorktreeVisibilityHelpPopover.test.tsx
  • src/renderer/src/components/sidebar/WorktreeVisibilityHelpPopover.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/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

Comment on lines +15 to +19
<div
className="inline-flex"
onPointerEnter={() => setOpen(true)}
onPointerLeave={() => setOpen(false)}
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 40

Repository: 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
done

Repository: 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 80

Repository: 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 160

Repository: 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.tsx

Repository: 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Latest UI — final state

All screenshots below are from the same final build at 424d041e47; they show different states of the feature, not different versions.

Always show off

Yes, the icon-only help popover is still present. It explains what is hidden by default, names .claude/worktrees/* and .gsd-workspaces/*, and clarifies that Always show applies to current and future worktrees. Hidden worktrees remain available individually with Show.

Current default state with help popover

Always show on

The existing Claude worktrees are visible, and a .gsd-workspaces/future-agent worktree created afterward was picked up automatically. The user does not need to return to this dialog for future worktrees under either recognized path.

Current Always show state

Result in the sidebar

The newly created future-agent worktree appears alongside the existing Claude worktrees.

Current sidebar with future agent worktree

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Independent Electron QA (Grok) — PASS

Exact head: b8c243b32f1b4c7611df53a26555cffcdeec16d0
Worktree: pr-11799-review @ review/pr-13652
Identity: window.api.app.getIdentity() → isDev: true, devLabel: qa-pr13652-indep, devWorktreeName: pr-11799-review, devRepoRoot matches this checkout, name: Orca: review/pr-13652
Driver: electron skill + agent-browser CDP only (REMOTE_DEBUGGING_PORT=9591, isolated ORCA_DEV_USER_DATA_PATH) — no Computer Use / AppleScript / OS input
Fixture: disposable real git repo with worktrees under both .claude/worktrees/* and .gsd-workspaces/*

Actions exercised

  1. Opened Non-Orca worktrees dialog (authoritative list on open)
  2. Confirmed Always show off → Hidden from sidebar / 4 worktrees currently hidden
  3. Confirmed hidden rows with exact repo-relative paths:
    • .claude/worktrees/claude-qa-extra1
    • .claude/worktrees/claude-qa-extra2
    • .claude/worktrees/claude-qa-scratch
    • .gsd-workspaces/gsd-qa-scratch
  4. Per-row Show on claude-qa-extra1 → hidden count 4→3; import path written; sidebar shows recovered worktree
  5. Always show on → agentWorktreeVisibility: show + externalWorktreeVisibility: show; dialog Shown in sidebar / 4 worktrees currently shown; all agent worktrees in sidebar
  6. Always show off → hide restored; per-path import of claude-qa-extra1 preserved; other three re-listed under Hidden worktrees (3)
  7. Help popover (hover/open) describes Orca-created exemption, default hide for new repos, and Always show covering .claude/worktrees/* + .gsd-workspaces/*
  8. Escape: closes help popover while dialog stays; Escape again closes dialog
  9. Virtualized list rows use absolute translateY positioning with scroll container
  10. agent-browser console/page errors: empty; app log noise only (port bind fallback, port-scan timeout) — not dialog regressions

Verdict

PASS — recovery + Always show policy work end-to-end for both agent roots at b8c243b32f. No product defects found. No product-code edits/commits.

Screenshots

01 Hidden / Always show off

02 Help popover open

03 After per-row Show (3 remaining hidden)

04 Sidebar after per-row recovery

05 Always show on

06 Sidebar with all agent worktrees visible

07 Always show off (preserved per-path import)

08 Sidebar after Always show off

@brennanb2025
brennanb2025 merged commit 6ac39b7 into main Aug 13, 2026
44 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude worktrees no longer show on project on left panel

1 participant