Skip to content

feat(worktrees): manage non-Orca worktree visibility from one screen - #11799

Closed
Gldywn wants to merge 4 commits into
stablyai:mainfrom
Gldywn:feat-recover-hidden-scratch-worktrees
Closed

Gldywn wants to merge 4 commits into
stablyai:mainfrom
Gldywn:feat-recover-hidden-scratch-worktrees

Conversation

@Gldywn

@Gldywn Gldywn commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Keeping a discovered worktree hidden was a one-way door for agent worktrees. The inbox baseline suppressed the notification, the repo-wide non-Orca toggle can never reveal agent scratch by design (#9388), and the visibility dialog reported nothing was there, so the worktree became unreachable from the UI while it sat on disk. Found by manual testing: create two .claude/worktrees/* worktrees, click Keep hidden on the inbox, and the first one is gone for good.

The Non-Orca worktrees dialog becomes the permanent home for both kinds, with the same anatomy on each side:

  • a repo switch (Show all / Hide all) that also covers worktrees created later,
  • a collapsible Manage individually list to show or hide one worktree at a time,
  • a state line that reports the real mix (Partly shown, 1 of 3 shown) instead of claiming all or nothing.

Agent worktrees get their own opt-in repo setting, so the non-Orca toggle still never reveals them; a shared test pins that guarantee. Hiding a whole kind drops that kind's explicit exceptions, otherwise an exception would outrank the switch that was just set. Both switches roll back if the refresh that follows them fails, so a stale list never reads as a successful flip.

Both switches also need an authoritative listing before they act, because hiding derives the exception purge and the notification ledger from that very list. On a host Orca cannot reach, the dialog says so and offers a retry, and the switches stay disabled, rather than purging the wrong paths against an empty list.

A one-shot primer explains the two kinds in plain words and stays reachable from a What is this? button after dismissal. The two sidebar notices now speak the same vocabulary as the dialog (Show / Show all, no filled button), show repo-relative paths, cap their preview at three rows, and link straight into the dialog instead of naming a menu the app never labels that way.

docs/non-orca-worktree-visibility.md writes down the model: two kinds by path, one setting each, per-path exceptions that outrank both, and the notification ledger that must never gate recovery.

This PR carries the commit from #11730 so everything reviews in one place, and consolidates two overlapping open PRs (see Notes).

Fix #10324

Screenshots

SCR-20260801-bnua

Sidebar notice. Newly discovered worktrees, with repo-relative paths, a three-row preview cap, and a recovery pointer whose only link is here. Clicking it reveals the project actions menu rather than naming a button that stays hidden until hover.

SCR-20260801-btul

Where it lives. The entry the sidebar notice points at. Clicking here in the notice opens this menu on the project row, which also reveals the ⋯ button that stays hidden until hover, so the path is learned rather than described.

SCR-20260801-bsgj

First open. The primer names the two kinds in plain words, then each kind gets the same anatomy: a repo switch that also covers worktrees created later, and a collapsible per-worktree list.

SCR-20260801-boqu

After Got it. The primer is replaced by a What is this? button in the header, and both lists are expanded. Paths render repo-relative, or absolute when the worktree lives outside the checkout.

SCR-20260801-bprr

Mixed state. One agent worktree was shown individually, so the section reports Partly shown in sidebar, 1 of 2 shown, and offers Hide all because something is on screen. Each row carries the action that matches its own state, while the other kind is fully shown by its switch.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Details, because two of those boxes need context:

  • pnpm test: the full suite was run: 18 files fail on this machine, none of them in this diff's area, and every cause was confirmed rather than assumed. 13 of the 18 pass when re-run in isolation and only fail under full-suite parallel load (node-pty, ssh, plugin and gitea integration). The remaining 5 are environmental: a global tag.gpgsign true turns three fixtures' lightweight tags into annotated ones that demand a message (fatal: no tag message?), an inherited GIT_CONFIG_COUNT=2 in the shell makes a relay handler emit 4 where the test expects 2, and a macOS helper fixture misses a temp pid file. Zero failures in src/renderer or src/shared. Targeted verification: 609 files / 5521 tests green across src/renderer/src/components/sidebar, src/renderer/src/i18n and src/shared.
  • pnpm build: build:electron-vite (the desktop bundle) passes. build:native was not run locally.
  • Tests added: shared visibility rule (the [Feature] More obvious guide for hiding non-orca-worktrees #9388 guarantee for both toggle values, the opt-in path, an exception surviving the setting), selector unit tests including the baselined-scratch recovery that reproduces the bug, switch-action tests (per-kind exception purge, rollback on failed refresh, refusal to hide against a non-authoritative snapshot, no worktree fetch when the update is refused), 17 dialog behavior tests, inbox-line tests for the shared vocabulary and the recovery link, and one e2e spec (tests/e2e/non-orca-worktree-visibility.spec.ts, adapted from feat(worktrees): import a single hidden worktree from the visibility dialog #11275) that walks the whole path in the real app: the setting cannot reveal an agent worktree, the dialog recovers one, the sidebar shows it while the other kind stays hidden, and hiding the kind drops the exception. Green with pnpm exec playwright test tests/e2e/non-orca-worktree-visibility.spec.ts --config tests/playwright.config.ts --project=electron-headless --workers=1.

AI Review Report

Reviewed with Claude Opus across the dimensions CONTRIBUTING asks for.

  • Cross-platform (macOS, Linux, Windows): no keyboard shortcut is added, so no metaKey hazard and no modifier labels to drift. No path string is built or split by hand: comparisons go through normalizeRuntimePathForComparison and the repo-relative display uses relativePathInsideRoot, both of which already handle Windows drive letters, UNC and WSL aliases. No shell invocation. Layout uses tokens and shadcn primitives only, so light and dark both come from main.css.
  • SSH, remote, local: every visibility write refetches with requireAuthoritative: true and rolls back on failure, so a slow or failing remote cannot leave the UI claiming a flip that did not land. The dialog refetches on open rather than trusting a cached snapshot, and renders Checking… instead of None in this repo. while a fallback snapshot is in play. When that refetch fails it says so and offers a retry, and the bulk switches stay disabled for as long as the list is untrustworthy, because hiding a kind reads the purge and the ledger off that list. Row actions reuse the existing inbox action, so they inherit its rollback.
  • Agents and providers: the two agent scratch containers (.claude/worktrees, .gsd-workspaces) come from the existing shared matcher; no provider-specific naming was introduced and no git provider logic is touched.
  • Performance: selectors are pure array passes over the already-fetched detected list, memoized per snapshot. One extra authoritative worktree list per dialog open. No work added to sidebar render or any hot path.
  • UI quality: the review flagged three things that were fixed rather than shipped. Grid children lacked min-w-0, so a long unbreakable path blew the dialog wider than its own panel; a help affordance was duplicated per section for a rule that belongs to the screen; and two locale entries had drifted from their inline defaults, which silently wins at runtime because the catalog takes precedence. A drift sweep over every touched file now reports zero.
  • Security: see below.

Three further adversarial rounds were then run, each with two independent reviewers reading the branch cold. Round one raised nine issues, all fixed: the exception purge re-derived ownership from repo.path while main anchors its matcher at every live checkout, so scratch created inside another worktree was misfiled and purged; a failed rollback dropped a discovery opt-out; the bulk switches never wrote their decision ledger, so the inbox re-announced what the user had just put away; a plural noun was composed before interpolation; the two sections derived their state differently; the guided-reveal observer could outlive its menu. Round two found that the bulk switches still acted on a non-authoritative snapshot, which reopened the purge bug on a failing remote, and that two catalog keys had been missed in the four non-English locales. Round three, run against a majors-only bar, came back empty from both reviewers.

Security Audit

  • Input handling: the new repo field is a two-value enum validated at both boundaries, the Electron IPC handler and the runtime RPC zod schema, mirroring the existing externalWorktreeVisibility guard. The new persisted UI flag is a boolean in the ui-state schema, which a type-level parity check enforces against PersistedUIState.
  • Path handling: worktree paths are only compared and normalized, never resolved, written, or passed to a shell. Nothing new is executed. The repo-relative display is presentational and falls back to the absolute path when the worktree sits outside the checkout.
  • IPC surface: no new channel or method. One additional field on an existing repo-update payload.
  • Auth, secrets, dependencies: none touched, no dependency added.
  • Follow-up: importedExternalWorktreePaths is never pruned when a worktree disappears from disk, so recreating the same path stays visible without asking again. Documented as a deliberate non-goal; worth revisiting if it surprises users.

Notes

  • Consolidates two overlapping PRs. fix(worktrees): let repos reveal coding-agent scratch worktrees #10560 (@jeongph) added the agent visibility setting; its field name agentWorktreeVisibility and its rollback shape are kept here. feat(worktrees): import a single hidden worktree from the visibility dialog #11275 (@5hseok) added per-path recovery from this dialog; its sharper exception detection is kept, namely asking whether the rule without imports would hide the row rather than trusting the recorded path list. Neither of them handles the interaction between the two mechanisms, which is the bug where hiding a kind left previously imported worktrees visible. If maintainers prefer to land either of those first, this branch rebases onto it with a textual conflict rather than a conceptual one.
  • Supersedes fix(worktrees): make agent-scratch worktrees importable (#10324) #11730, whose commit is included here so the model change and the UI that exposes it review together.
  • Legacy repos keep their own rule. A repo added before the visibility rollout still shows its unknown-legacy worktrees whatever the setting says, which no switch on this screen can change. Those rows are therefore left out of a kind's counts, on the principle that a section must never report a state its own button cannot produce, nor offer a Hide all that hides nothing.
  • [Feature] More obvious guide for hiding non-orca-worktrees #9388 is not reversed. externalWorktreeVisibility still cannot reveal an agent worktree for either of its values, and a shared test asserts it. Agent worktrees answer only to their own opt-in setting, an explicit exception, or being the selected checkout. Both defaults stay hidden.
  • The e2e spec earned its keep immediately. It caught a UX flaw that unit tests and manual review both missed: the bulk button label read only the stored setting, so with every row shown through individual exceptions the section still offered Show all and nothing offered to hide what was on screen. The label now answers to the visible state.
  • Local environment caveats for anyone reproducing the suite locally: node-pty may need npm_config_build_from_source=true pnpm rebuild node-pty in a fresh worktree, a global tag.gpgsign true breaks three tag fixtures (two release scripts and the plugin installer), and an inherited GIT_CONFIG_COUNT breaks a relay env assertion. All pre-existing and unrelated to this diff; a separate PR hardens those fixtures.

@Gldywn
Gldywn force-pushed the feat-recover-hidden-scratch-worktrees branch from 5a50ba0 to c3cde97 Compare August 1, 2026 11:56
@Gldywn
Gldywn marked this pull request as ready for review August 1, 2026 12:00
@Gldywn
Gldywn requested a review from brennanb2025 as a code owner August 1, 2026 12:00
@greptile-apps

greptile-apps Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR turns the Non-Orca worktrees dialog into the unified home for managing both kinds of non-Orca worktrees — agent scratch (.claude/worktrees, .gsd-workspaces) and hand-made git worktrees — fixing a one-way-door bug where clicking "Keep hidden" in the inbox made an agent scratch worktree permanently unreachable. Each kind now gets its own repo-wide switch, a collapsible per-row list, accurate mixed-state reporting, an authoritative-list guard that disables bulk actions on unreachable hosts, and full rollback on failed refresh.

  • New visibility model: agentWorktreeVisibility is a separate opt-in repo setting (validated at both IPC and RPC boundaries) so the existing externalWorktreeVisibility toggle cannot inadvertently reveal agent scratch, preserving the [Feature] More obvious guide for hiding non-orca-worktrees #9388 guarantee pinned by a new shared test.
  • Dialog redesign: WorktreeVisibilityDialog refetches authoritatively on every open, shows a one-shot primer with a persistent "What is this?" re-entry, and disables bulk switches while the list is untrustworthy; hiding a kind also purges that kind's explicit imports and baselines all its paths so the inbox cannot re-announce them.
  • Sidebar notices: Both inbox lines now show repo-relative paths, cap previews at three rows, speak the shared Show/Show all vocabulary, and link to the project actions menu (with a dialog fallback) instead of naming a hidden button.

Confidence Score: 5/5

Safe to merge; the core visibility model, rollback paths, and authoritative-list guard are well-exercised by unit and e2e tests, with only minor behavioural edge cases in the undo-import path worth revisiting.

The change is tightly scoped to the visibility dialog and its supporting logic, with no new IPC channels, no new dependencies, and path handling that goes exclusively through existing cross-platform helpers. The two new repo settings are validated at both the IPC and RPC boundaries mirroring the existing pattern. The bulk switch guards against acting on a non-authoritative snapshot and rolls back all touched fields on a failed refresh. The e2e spec exercises the full round-trip and caught at least one bug (the bulk label) during development. The two minor findings are edge cases in the undo-import flow and an unnecessarily broad rollback, neither of which affects the primary recovery or visibility guarantees.

Files Needing Attention: new-external-worktrees-inbox-actions.ts (undoExternalWorktreeImportPaths baseline gap) and non-orca-worktree-switch-actions.ts (show-path rollback over-writes unchanged list fields)

Important Files Changed

Filename Overview
src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx Substantially rewritten dialog: adds per-kind sections (agent scratch + other), authoritative-list gating with retry, primer guide, and per-row toggle/bulk switch actions; actionState error not cleared on dialog reopen (noted in prior threads)
src/renderer/src/components/sidebar/non-orca-worktree-switch-actions.ts New bulk-switch action with authoritative-list guard, per-kind import purge, baseline merge, and rollback on failed refresh; rollback for the show path over-writes unchanged list fields unnecessarily
src/renderer/src/components/sidebar/non-orca-worktree-visibility-candidates.ts New selectors for agent/other worktree rows and summaries; correctly uses detected ownership rather than path heuristics, and separates legacy/selected-checkout rows from both switches
src/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.ts Adds undoExternalWorktreeImportPaths; correctly preserves baseline for paths previously judged via inbox, but paths imported only through the dialog have no baseline entry and will re-appear in the inbox after undo
src/renderer/src/components/sidebar/reveal-project-actions-menu.ts New utility that synthesizes a pointerdown event to open Radix dropdown and then rAF-polls for the visibility menu item; correctly handles the keyboard fallback path and the guided-row hover-lock cleanup via MutationObserver
src/shared/external-worktree-inbox.ts Adds getHiddenImportableExternalWorktrees and refactors getNewExternalWorktreeInboxWorktrees to surface agent scratch independently of the non-Orca visibility prompt gate
src/shared/worktree-ownership.ts agent-scratch now answers to effectiveAgentWorktreeVisibility rather than always returning false; exports the new helper for use in the dialog
tests/e2e/non-orca-worktree-visibility.spec.ts New e2e spec covering the full round-trip: setting cannot reveal agent worktrees, dialog recovers them, sidebar shows one kind while other stays hidden, hiding kind drops the import exception

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Dialog opens] --> B[fetchWorktrees requireAuthoritative]
    B --> C{refresh ok?}
    C -- yes --> D[listState = ready\nbulk buttons enabled]
    C -- no --> E[listState = failed\nbulk buttons disabled\nRetry shown]

    D --> F{User action}
    F --> G[Row toggle\nshow/hide]
    F --> H[Bulk switch\nShow all / Hide all]

    G --> I{intent}
    I -- show --> J[importNewExternalWorktreeInboxPaths\nadd to importedPaths]
    I -- hide --> K[undoExternalWorktreeImportPaths\nremove from importedPaths\nbaseline unchanged]

    H --> L{detected\nauthoritative?}
    L -- no, hide --> M[Refuse with error\nno writes]
    L -- yes or show --> N[setNonOrcaWorktreeKindVisibility\nupdate setting\npurge kind imports if hide\nbaseline kind paths if hide]
    N --> O[fetchWorktrees requireAuthoritative]
    O --> P{refresh ok?}
    P -- yes --> Q[setSwitchState null\ndone]
    P -- no --> R[Rollback all fields\nshow error]

    K --> S[fetchWorktrees requireAuthoritative]
    J --> S
    S --> T{refresh ok?}
    T -- yes --> U[setInboxState null]
    T -- no --> V[rollback importedPaths\nshow error]
Loading

Reviews (2): Last reviewed commit: "i18n(worktrees): say the switch hides in..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added independent visibility policies for agent-scratch and other non-Orca worktrees. Added shared classification, inbox filtering, persistence, IPC validation, and renderer state handling. Replaced the visibility dialog with categorized bulk and per-worktree controls. Updated inbox actions, project-menu recovery, localized strings, and end-to-end coverage.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.55% 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 restoring recovery and visibility management for Claude and other non-Orca worktrees.
Out of Scope Changes check ✅ Passed The documentation, UI, persistence, localization, validation, and tests directly support the non-Orca worktree visibility objectives.
Title check ✅ Passed The title clearly and concisely describes the main change: managing non-Orca worktree visibility from one screen.
Description check ✅ Passed The description covers the required summary, screenshots, testing, AI review, security audit, and notes with detailed implementation and verification results.

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: 3

🧹 Nitpick comments (3)
src/renderer/src/components/sidebar/NonOrcaWorktreeSection.tsx (1)

50-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Mark the state icons as decorative.

Eye and EyeOff duplicate the adjacent stateLabel text. Add aria-hidden="true" so assistive technology does not announce them. The codebase already does this for other decorative icons, for example in NewExternalWorktreesInboxLine.tsx.

♻️ Proposed change
-            {anyShown ? <Eye className="size-4" /> : <EyeOff className="size-4" />}
+            {anyShown ? (
+              <Eye className="size-4" aria-hidden="true" />
+            ) : (
+              <EyeOff className="size-4" aria-hidden="true" />
+            )}
src/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsx (1)

273-297: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use the EXTERNAL_PATH constant instead of the duplicated literal.

Lines 277 and 294 repeat '/elsewhere/manual', which is already defined as EXTERNAL_PATH. Use the constant so a change to the fixture path stays consistent.

♻️ Proposed change
-        importedExternalWorktreePaths: [SCRATCH_PATH, '/elsewhere/manual']
+        importedExternalWorktreePaths: [SCRATCH_PATH, EXTERNAL_PATH]
       agentWorktreeVisibility: 'hide',
-      importedExternalWorktreePaths: ['/elsewhere/manual'],
+      importedExternalWorktreePaths: [EXTERNAL_PATH],
       externalWorktreeInboxBaselinePaths: [SCRATCH_PATH]
src/renderer/src/components/sidebar/reveal-project-actions-menu.ts (1)

41-50: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

The observer can stay attached after the row is detached.

clearGuidedRowWhenMenuCloses observes doc.body with subtree: true and disconnects only when the visibility item disappears. If the project header unmounts while the menu is still open, the observer keeps running on every body mutation. Consider disconnecting when row.isConnected is false as well.

♻️ Proposed change
   const observer = new MutationObserver(() => {
-    if (doc.querySelector(`[${PROJECT_ACTIONS_VISIBILITY_ITEM_ATTRIBUTE}]`)) {
+    if (row.isConnected && doc.querySelector(`[${PROJECT_ACTIONS_VISIBILITY_ITEM_ATTRIBUTE}]`)) {
       return
     }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d19dd5f0-aa67-4eb6-a686-01f417a7e89d

📥 Commits

Reviewing files that changed from the base of the PR and between 16c5526 and c3cde97a87b7febf4e30fd661d3e871a811c3cc8.

📒 Files selected for processing (41)
  • docs/non-orca-worktree-visibility.md
  • src/main/ipc/repos.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/main/runtime/rpc/methods/repo-update-schema.ts
  • src/preload/api-types.ts
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/sidebar/ImportedWorktreesVisibilityLine.tsx
  • src/renderer/src/components/sidebar/NewExternalWorktreesInboxLine.test.tsx
  • src/renderer/src/components/sidebar/NewExternalWorktreesInboxLine.tsx
  • src/renderer/src/components/sidebar/NonOrcaWorktreeRowList.tsx
  • src/renderer/src/components/sidebar/NonOrcaWorktreeSection.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsx
  • src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.test.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-candidates.test.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-candidates.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-switch-actions.test.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-switch-actions.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-visibility-candidates.test.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-visibility-candidates.ts
  • src/renderer/src/components/sidebar/repo-header-action-button-class.ts
  • src/renderer/src/components/sidebar/reveal-project-actions-menu.test.ts
  • src/renderer/src/components/sidebar/reveal-project-actions-menu.ts
  • 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/renderer/src/store/slices/repos.ts
  • src/renderer/src/store/slices/ui.ts
  • src/shared/external-worktree-inbox.test.ts
  • src/shared/external-worktree-inbox.ts
  • src/shared/external-worktree-visibility.ts
  • src/shared/types.ts
  • src/shared/worktree-ownership.test.ts
  • src/shared/worktree-ownership.ts
  • tests/e2e/non-orca-worktree-visibility.spec.ts

Comment thread src/renderer/src/i18n/locales/ko.json Resolved
Comment thread src/renderer/src/i18n/locales/zh.json Resolved
@Gldywn

Gldywn commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks both. Every point was checked against the code rather than taken on trust; here is what happened to each.

Taken (2e5bc71d6)

  • @coderabbitai on zh.json: right, and the block's own sibling settled the form. 已显示 {{value1}} 个中的 {{value0}} 个 was already verb-first, so the four count keys were inconsistent with the label next to them. They now read 已一起显示 {{value0}} 个 / 已一起隐藏 {{value0}} 个.
  • @coderabbitai on ko.json: right, and worse than reported. The Korean was a faithful translation of an ambiguous English source (Hiding a kind clears the worktrees you had shown individually), and es and zh inherited the same reading: borra los worktrees, 会清除...工作树. Three catalogs told the user their worktrees were about to be deleted. Fixing Korean alone would have made it more precise than its own source, so the English now says Hiding a kind also hides the worktrees you had shown individually and all five catalogs are realigned.

Refuted, with evidence

  • @greptile-apps, stale actionState on reopen: the premise that the component stays mounted does not hold. src/renderer/src/components/sidebar/index.tsx:205 renders {activeModal === 'worktree-visibility' ? <WorktreeVisibilityDialog /> : null}, so closeModal() unmounts it and every useState including actionState is destroyed. Reopening mounts a fresh instance. The in-component if (!isOpen) return null is a secondary guard, not the lifecycle.
  • @greptile-apps, HERE_TOKEN split fallback (both files): three reasons. All five catalogs contain {{value0}} for both keys, and a locale that dropped it would fail verify:localization-catalog, which errors on interpolation mismatches. If it somehow happened, nothing is silently dropped: split on a token-less string returns [wholeString], so the whole sentence renders and the link appends at the end, which is the best available degradation. And the = '' defaults are inert, since both values go straight into JSX and React renders undefined and '' identically.
  • @coderabbitai, aria-hidden on Eye/EyeOff: lucide-react 0.577.0 already adds it. node_modules/lucide-react/dist/cjs/lucide-react.js:69 spreads !children && !hasA11yProp(rest) && { "aria-hidden": "true" }, and <Eye className="size-4" /> qualifies, so assistive technology ignores both icons today.
  • @coderabbitai, guarding importedPathKind: answered in the thread. Short version: the live path is already gated at non-orca-worktree-switch-actions.ts:74-77, and the proposed guard would force the repo.path heuristic that misfiles scratch created inside another checkout, which is the defect that function exists to fix.

Left alone on purpose

  • The MutationObserver in reveal-project-actions-menu.ts keeps observing if the project header unmounts while the menu is open. Real, but bounded: the portal unmounting is itself a body mutation, so the callback runs a no-op removeAttribute on a detached node and disconnects. No unbounded leak, nothing user-visible.
  • '/elsewhere/manual' repeated where EXTERNAL_PATH exists in the dialog test. Test-only readability; not worth a CI round on its own.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@Gldywn Thanks for the detailed verification.

The localization changes address both reported issues. The revised English wording removes the deletion implication, and the aligned catalogs preserve that meaning.

I withdraw the aria-hidden finding. lucide-react 0.577.0 supplies aria-hidden="true" for these icon-only components.

I also withdraw the importedPathKind finding. The existing live-path gate preserves authoritative classification. The proposed fallback would reintroduce incorrect scratch-worktree classification.

🐇 ✅


✏️ Learnings added
Learnt from: Gldywn
URL: https://github.com/stablyai/orca/pull/11799

Timestamp: 2026-08-01T12:30:37.209Z
Learning: In this repository, `lucide-react` 0.577.0 automatically adds `aria-hidden="true"` to icon-only components when no accessible child or explicit accessibility prop is present. Do not request redundant `aria-hidden` props for usages such as `<Eye className="size-4" />`.

Learnt from: Gldywn
URL: https://github.com/stablyai/orca/pull/11799

Timestamp: 2026-08-01T12:30:37.209Z
Learning: In `src/renderer/src/components/sidebar/non-orca-worktree-switch-actions.ts`, preserve the existing live-path gate for `importedPathKind`. Do not replace it with a `repo.path` heuristic, because agent scratch worktrees can exist inside another checkout and would be classified incorrectly.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown

All four rebuttals hold up:

  • actionState lifecycle: the {condition ? <Component /> : null} pattern is the canonical React unmount — confirmed.
  • HERE_TOKEN split: verify:localization-catalog catching interpolation drift plus the graceful split degradation is a legitimate defense-in-depth argument.
  • aria-hidden on icons: the lucide-react spread at hasA11yProp check is real; no manual annotation needed.
  • importedPathKind guard: the existing gate at lines 74–77 already covers the live path, and the proposed guard would have reintroduced the cross-worktree misfiling bug — good catch.

The translation fixes are the right call too: correcting Korean alone while es and zh still said "deletes your worktrees" would have been worse than the original ambiguity.

Nothing outstanding from my side. This looks ready.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@lu9999

lu9999 commented Aug 5, 2026

Copy link
Copy Markdown

When this change rolls out, I still have to use the old version, as the newer Orca does not show Claude worktrees

@brennanb2025

Copy link
Copy Markdown
Contributor

Taking a look!

Gldywn added 4 commits August 6, 2026 00:06
…rktrees are recoverable (stablyai#10324)

Worktrees under <repo>/.claude/worktrees are classified agent-scratch and
shouldShowWorktree hides them before the visibility branch, so the "Show
non-Orca worktrees" toggle cannot reveal them by design (stablyai#9388). The only
reveal path is an explicit import into importedExternalWorktreePaths, but
nothing ever offered scratch for import, leaving them unreachable.

Add isImportableExternalWorktree (excludes only orca-managed and the
selected checkout) and getHiddenImportableExternalWorktrees, and use them
in getNewExternalWorktreeInboxWorktrees so scratch reaches the inbox. Let
scratch bypass both the visibility-mode gate and the first-run prompt gate:
neither governs scratch, and the prompt flag is only written by the import
card, which never renders for a scratch-only repo. Discovery suppression
and the inbox baseline still apply.

getHiddenExternalWorktrees, the import card and the visibility dialog are
left untouched: the card's only action flips externalWorktreeVisibility,
which by design can never reveal scratch.
Keeping a discovered worktree hidden was a one-way door for agent scratch.
The inbox baseline suppressed the notification, the repo-wide toggle can
never reveal scratch by design (stablyai#9388), and the dialog reported nothing was
there, so the worktree became unreachable from the UI.

The visibility dialog now owns both kinds of non-Orca worktrees, each with
the same anatomy: a repo switch that also covers worktrees created later,
and a collapsible per-worktree list to show or hide one at a time. Agent
worktrees answer to their own opt-in setting, so the non-Orca toggle still
never reveals them; a shared test pins that guarantee. Hiding a whole kind
drops that kind's explicit exceptions, otherwise an exception would outrank
the switch that was just set, and both switches roll back if the refresh
that follows them fails.

Both switches also need an authoritative listing, because hiding derives the
purge and the decision ledger from it. On a host Orca cannot reach, the
dialog says so and offers a retry instead of purging against an empty list.
Worktrees a legacy repo shows whatever the setting are left out of a kind's
counts, since no switch on this screen can move them.

A row counts as an exception when the visibility rule without imports would
hide it, not when its path sits in the recorded list, because that list can
lag behind reality. Row-level actions reuse the inbox import path so
behavior and rollback stay identical, and the recovery list ignores the
inbox baseline on purpose: the baseline suppresses a notification, it must
not block recovery.

The sidebar notices now speak the same vocabulary as the dialog and link
straight into it instead of naming a menu. docs/non-orca-worktree-visibility.md
writes down the model, the stablyai#9388 guarantee, and the exception rules.

Supersedes stablyai#11730 and consolidates the overlapping work in stablyai#10560 (the
agent visibility setting, whose field name and rollback shape are kept) and
… worktrees

Three of the five catalogs read as if hiding a kind removed the worktrees
themselves: es "borra los worktrees", zh "会清除...工作树", ko "워크트리도
해제됩니다". They were faithful to an English source that said "clears the
worktrees you had shown individually", so the fix belongs in the source.

Also puts the Chinese count labels in verb-first order, matching the sibling
"已显示 N 个中的 M 个" already in that block.
…hema file

client-ui-schemas.ts sat exactly at the 300-line ceiling, so the visibility
field this branch adds pushed it over. The two workspace-cleanup schemas were
file-local, so moving them changes no public surface.
@damianjarosz-erli

Copy link
Copy Markdown

Maybe better solution will be to set a mask of agent worktrees that shoud be hidden for project?
In most cases I saw names was /agent-. One setting that solve problem for long time. And gives you more ways to show or hide worktrees.

@Gldywn

Gldywn commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Maybe better solution will be to set a mask of agent worktrees that shoud be hidden for project? In most cases I saw names was /agent-. One setting that solve problem for long time. And gives you more ways to show or hide worktrees.

I tried integrating it into the existing product logic, but I think it's a good idea, we can add configurable paths that allow to ignore or include all worktrees in a dir and sub-dirs. We can put it inside the general settings screen or in the "Manage non-Orca working directories" screen. Let's wait for @brennanb2025's opinion to know if this PR will be merged or not first

@Gldywn
Gldywn force-pushed the feat-recover-hidden-scratch-worktrees branch from 2e5bc71 to 7b5de7c Compare August 6, 2026 08:16
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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.

@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: 180471b1-e596-4f96-93f4-15757ea78eb7

📥 Commits

Reviewing files that changed from the base of the PR and between c3db2b8 and 7b5de7c.

📒 Files selected for processing (42)
  • docs/non-orca-worktree-visibility.md
  • src/main/ipc/repos.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/main/runtime/rpc/methods/client-workspace-cleanup-schemas.ts
  • src/main/runtime/rpc/methods/repo-update-schema.ts
  • src/preload/api-types.ts
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/sidebar/ImportedWorktreesVisibilityLine.tsx
  • src/renderer/src/components/sidebar/NewExternalWorktreesInboxLine.test.tsx
  • src/renderer/src/components/sidebar/NewExternalWorktreesInboxLine.tsx
  • src/renderer/src/components/sidebar/NonOrcaWorktreeRowList.tsx
  • src/renderer/src/components/sidebar/NonOrcaWorktreeSection.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/WorktreeVisibilityDialog.test.tsx
  • src/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsx
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.test.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-candidates.test.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-candidates.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-switch-actions.test.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-switch-actions.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-visibility-candidates.test.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-visibility-candidates.ts
  • src/renderer/src/components/sidebar/repo-header-action-button-class.ts
  • src/renderer/src/components/sidebar/reveal-project-actions-menu.test.ts
  • src/renderer/src/components/sidebar/reveal-project-actions-menu.ts
  • 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/renderer/src/store/slices/repos.ts
  • src/renderer/src/store/slices/ui.ts
  • src/shared/external-worktree-inbox.test.ts
  • src/shared/external-worktree-inbox.ts
  • src/shared/external-worktree-visibility.ts
  • src/shared/types.ts
  • src/shared/worktree-ownership.test.ts
  • src/shared/worktree-ownership.ts
  • tests/e2e/non-orca-worktree-visibility.spec.ts
🚧 Files skipped from review as they are similar to previous changes (34)
  • src/preload/api-types.ts
  • src/renderer/src/store/slices/repos.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-candidates.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/repo-update-schema.ts
  • src/main/ipc/repos.ts
  • src/renderer/src/components/sidebar/repo-header-action-button-class.ts
  • src/renderer/src/components/sidebar/NewExternalWorktreesInboxLine.test.tsx
  • src/renderer/src/components/sidebar/NonOrcaWorktreeRowList.tsx
  • src/renderer/src/components/sidebar/reveal-project-actions-menu.test.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-candidates.ts
  • src/shared/worktree-ownership.test.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-visibility-candidates.test.ts
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/shared/external-worktree-inbox.test.ts
  • src/renderer/src/assets/main.css
  • src/shared/worktree-ownership.ts
  • src/main/persistence.ts
  • src/renderer/src/i18n/locales/es.json
  • src/shared/types.ts
  • src/shared/external-worktree-visibility.ts
  • src/renderer/src/components/sidebar/NewExternalWorktreesInboxLine.tsx
  • src/renderer/src/components/sidebar/ImportedWorktreesVisibilityLine.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/NonOrcaWorktreeSection.tsx
  • src/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-switch-actions.ts
  • src/shared/external-worktree-inbox.ts
  • src/renderer/src/components/sidebar/non-orca-worktree-visibility-candidates.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/components/sidebar/non-orca-worktree-switch-actions.test.ts


How Orca decides whether a worktree it did not create appears in the sidebar, and which surface
can change that decision. Builds on the analysis in #10560 (agent scratch needs an opt-in) and
#11275 (a hidden worktree needs a per-path way back).

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep #11275 in the paragraph.

Line 5 starts an unintended Markdown heading. Move the issue reference to line 4, or prefix line 5 with normal prose.

Proposed fix
-How Orca decides whether a worktree it did not create appears in the sidebar, and which surface
-can change that decision. Builds on the analysis in `#10560` (agent scratch needs an opt-in) and
-#11275 (a hidden worktree needs a per-path way back).
+How Orca decides whether a worktree it did not create appears in the sidebar, and which surface
+can change that decision. Builds on the analysis in `#10560` (agent scratch needs an opt-in) and `#11275`
+(a hidden worktree needs a per-path way back).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#11275 (a hidden worktree needs a per-path way back).
How Orca decides whether a worktree it did not create appears in the sidebar, and which surface
can change that decision. Builds on the analysis in `#10560` (agent scratch needs an opt-in) and `#11275`
(a hidden worktree needs a per-path way back).
🧰 Tools
🪛 markdownlint-cli2 (0.23.2)

[warning] 5-5: No space after hash on atx style heading

(MD018, no-missing-space-atx)

Source: Linters/SAST tools

@damianjarosz-erli

Copy link
Copy Markdown

When this change rolls out, I still have to use the old version, as the newer Orca does not show Claude worktrees

Me too. It's easier use old orca version than change agent flow for everybody.

@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for this work — #13652 landed the focused recovery and visibility behavior. The remaining per-source and custom-location UI is documented there as a follow-up, so this PR is now superseded.

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

5 participants