Repository navigation
Refresh project worktrees created outside Orca - #6241
Conversation
|
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:
📝 WalkthroughWalkthroughThis PR adds an external worktree inbox flow and a worktree base directory watcher flow. It introduces shared external-worktree path and eligibility helpers, repo state and update fields, renderer inbox rows and actions, and locale strings. It also adds event filtering, watcher subscription and sync logic, main-process wiring for watcher lifecycle events, and tests covering the new behavior. 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 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: 3
🧹 Nitpick comments (4)
src/main/ipc/worktree-base-directory-watcher.test.ts (1)
32-168: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse Node path utilities for fixture paths to keep tests cross-platform.
These tests currently hardcode
/path separators in many fixtures. Please build paths withpath.join(or a small helper) so the suite remains portable across platforms.♻️ Suggested pattern
+import { join, sep } from 'node:path' + +const p = (...parts: string[]) => join(sep, ...parts) +const WORKTREE_ROOT = p('workspace', 'worktrees') +const PROJECT_ROOT = p('workspace', 'projects', 'project') +const PROJECT_GIT_COMMON = join(PROJECT_ROOT, '.git') const settings = { - workspaceDir: '/workspace/worktrees', + workspaceDir: WORKTREE_ROOT, nestWorkspaces: true } as GlobalSettings function makeRepo(overrides: Partial<Repo> = {}): Repo { return { id: 'repo-1', - path: '/workspace/projects/project', + path: PROJECT_ROOT, displayName: 'Project', @@ - emit('/workspace/worktrees', [ - { type: 'create', path: '/workspace/worktrees/project/external-5104' }, - { type: 'create', path: '/workspace/worktrees/project/external-5104/.git' } + emit(WORKTREE_ROOT, [ + { type: 'create', path: join(WORKTREE_ROOT, 'project', 'external-5104') }, + { type: 'create', path: join(WORKTREE_ROOT, 'project', 'external-5104', '.git') } ] as WatcherEvent[])As per coding guidelines, “Use
path.joinor Electron/Node path utilities for file paths — never assume/or\for cross-platform compatibility.”Source: Coding guidelines
src/main/window/attach-main-window-services.ts (1)
64-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short
Why:for the attach-time watcher sync.This hook is easy to remove as “redundant” because repo and settings changes also resync watchers. A one-line rationale here would preserve the lifecycle contract.
As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”
Source: Coding guidelines
src/main/ipc/worktree-base-directory-event-filter.ts (1)
33-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short why comment for the shallow matching rules.
These predicates encode the key design constraint: only completion/root-delete/common-dir metadata signals should refresh worktrees, while deeper churn is ignored.
Suggested comment placement
+// Why: root creation can fire before checkout is usable; `.git` marks completion. function isRootCompletionEvent(parts: string[], config: WorktreeBaseRepoWatchConfig): boolean {+// Why: Git registers linked worktrees under the common dir's `worktrees` metadata. function matchingGitCommonRepoIds(target: WorktreeBaseWatchTarget, eventPath: string): string[] {As per coding guidelines,
**/*.{ts,tsx,js,jsx}code driven by a design doc or non-obvious constraint should include a short comment explaining why.Also applies to: 78-83
Source: Coding guidelines
src/main/ipc/worktree-base-directory-watcher.ts (1)
166-174: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why WSL UNC roots are skipped.
The warning says what happens, but not why this intentionally avoids watching/polling those roots.
Suggested comment
+ // Why: local desktop file watching is unreliable for WSL UNC roots; avoid polling. if (isWslUncPath(workspaceRoot) || isWslUncPath(repo.path)) {As per coding guidelines,
**/*.{ts,tsx,js,jsx}code driven by a design doc or non-obvious constraint should include a short comment explaining why.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5a8baade-1b15-4eed-b15d-acf68f6b794a
📒 Files selected for processing (7)
src/main/index.tssrc/main/ipc/repos.tssrc/main/ipc/settings.tssrc/main/ipc/worktree-base-directory-event-filter.tssrc/main/ipc/worktree-base-directory-watcher.test.tssrc/main/ipc/worktree-base-directory-watcher.tssrc/main/window/attach-main-window-services.ts
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/main/ipc/worktree-base-directory-watcher.ts (1)
208-214: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short why-comment for the stale-generation unsubscribe path.
This cleanup is guarding a subtle async race, so it deserves an in-code reason before someone “simplifies” it away in a later refactor. As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”
Source: Coding guidelines
src/main/ipc/worktree-common-git-directory.ts (1)
21-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the
worktrees/../..fallback.This branch depends on Git’s linked-worktree metadata layout and is not self-explanatory from the expression alone. A one-line why-comment would make the contract much safer to maintain. As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”
Source: Coding guidelines
src/main/ipc/repos.ts (1)
2490-2490: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short why-comment for the watcher resync side effect.
notifyReposChanged()now does more than IPC fanout, and that extra watcher sync is design-driven rather than obvious from the callsite. A brief reason here would help preserve the contract. As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”Source: Coding guidelines
src/main/ipc/settings.ts (1)
113-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a why-comment for the post-settings watcher resync.
The relationship between
workspaceDir/nestWorkspaces,prepareLocalWorktreeRootsForRepos(store), and this watcher reschedule is policy-heavy and not obvious from control flow alone. As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 885aca72-9964-4885-a802-f6f4c4473c2c
📒 Files selected for processing (8)
src/main/index.tssrc/main/ipc/repos.tssrc/main/ipc/settings.tssrc/main/ipc/worktree-base-directory-event-filter.tssrc/main/ipc/worktree-base-directory-watcher.test.tssrc/main/ipc/worktree-base-directory-watcher.tssrc/main/ipc/worktree-common-git-directory.tssrc/main/window/attach-main-window-services.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/window/attach-main-window-services.ts
- src/main/ipc/worktree-base-directory-event-filter.ts
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/sidebar/WorktreeList.tsx (1)
6517-6524: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
filtersHideAllRowsdoesn't account for inbox candidates.
buildRowsincludesnewExternalWorktreesInboxByRepo, so a repo with only an inbox row (no visible worktrees, placeholders, or imported-card candidates) produces a non-emptyrows. ButfiltersHideAllRowsignores the inbox map, so when filters are active this evaluatestrueand the early return renders the "No workspaces found" empty state, hiding the inbox row entirely. Since inbox candidates already honorfilterRepoIds, include them in the guard.🐛 Proposed fix
const filtersHideAllRows = hasFilters && worktrees.length === 0 && placeholderRepoIds.size === 0 && - importedWorktreesByRepo.size === 0 + importedWorktreesByRepo.size === 0 && + newExternalWorktreesInboxByRepo.size === 0
🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/worktree-list-groups.ts (1)
1105-1138: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDeduplicate the per-group
repoIdscomputation.
repoIdsInGroup(Lines 1106-1113) repeats the exactrepoIdsfallback computed a few lines above (Lines 1077-1084 in the imported-card/pending block). Computing it once and reusing it avoids the two copies drifting apart later.Also note the per-repo split changes ordering for multi-repo project groups: previously
orderMainWorktreeFirst(group.items)ordered the whole group together; now worktrees are segregated byrepoIdingroup.repoIdsinsertion order, which may not match the manual/repoOrderranking. Please confirm this ordering is intended.♻️ Hoist the shared repoIds list
if (!isCollapsed) { + const repoIds = + groupBy === 'repo' + ? group.repoIds.size > 0 + ? [...group.repoIds] + : repo + ? [repo.id] + : key.startsWith('repo:') + ? [key.slice('repo:'.length)] + : [] + : [] if (groupBy === 'repo') { - const repoIds = - group.repoIds.size > 0 - ? [...group.repoIds] - : repo - ? [repo.id] - : key.startsWith('repo:') - ? [key.slice('repo:'.length)] - : [] for (const repoId of repoIds) {Then reuse
repoIdsforrepoIdsInGroupat Line 1106.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e3b3ec73-b293-47da-a817-b2af9044781e
📒 Files selected for processing (32)
src/main/ipc/repos.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/repo.tssrc/preload/api-types.tssrc/renderer/src/components/sidebar/NewExternalWorktreesInboxLine.tsxsrc/renderer/src/components/sidebar/SuppressExternalWorktreeInboxDialog.tsxsrc/renderer/src/components/sidebar/WorktreeList.tsxsrc/renderer/src/components/sidebar/WorktreeVisibilityDialog.tsxsrc/renderer/src/components/sidebar/host-section-rows.tssrc/renderer/src/components/sidebar/imported-worktrees-card-actions.test.tssrc/renderer/src/components/sidebar/imported-worktrees-card-actions.tssrc/renderer/src/components/sidebar/imported-worktrees-card-candidates.tssrc/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.test.tssrc/renderer/src/components/sidebar/new-external-worktrees-inbox-actions.tssrc/renderer/src/components/sidebar/new-external-worktrees-inbox-candidates.test.tssrc/renderer/src/components/sidebar/new-external-worktrees-inbox-candidates.tssrc/renderer/src/components/sidebar/worktree-drag-units.tssrc/renderer/src/components/sidebar/worktree-list-groups.test.tssrc/renderer/src/components/sidebar/worktree-list-groups.tssrc/renderer/src/components/sidebar/worktree-list-virtual-rows.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/repos.tssrc/shared/external-worktree-inbox.test.tssrc/shared/external-worktree-inbox.tssrc/shared/types.tssrc/shared/worktree-ownership.test.tssrc/shared/worktree-ownership.ts
✅ Files skipped from review due to trivial changes (2)
- src/renderer/src/i18n/locales/zh.json
- src/renderer/src/i18n/locales/ja.json
Adds a second-stage inbox in the worktree sidebar for repos that already dismissed the initial imported-worktrees prompt. Users can import new externals, keep them hidden, import all, or permanently opt out with recovery via Non-Orca worktrees settings.
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
f294374 to
24c3506
Compare
Co-authored-by: Orca <help@stably.ai>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/repo-update-schema.ts (1)
54-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the redundant
.finite()calls from thesez.number()schemas.z.number()already rejects non-finite values in Zod 4, so the chain is just noise. Same applies to the other.finite()on this object.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c187ff4c-9cfb-4c31-9165-1e5b48f439a6
📒 Files selected for processing (14)
src/main/index.tssrc/main/ipc/repos.tssrc/main/ipc/settings.tssrc/main/ipc/worktree-base-directory-event-filter.tssrc/main/ipc/worktree-base-directory-watch-targets.tssrc/main/ipc/worktree-base-directory-watcher.test.tssrc/main/ipc/worktree-base-directory-watcher.tssrc/main/ipc/worktree-common-git-directory.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/repo-update-schema.tssrc/main/runtime/rpc/methods/repo.tssrc/main/window/attach-main-window-services.tssrc/preload/api-types.ts
🚧 Files skipped from review as they are similar to previous changes (9)
- src/main/ipc/settings.ts
- src/main/runtime/orca-runtime.ts
- src/main/window/attach-main-window-services.ts
- src/main/ipc/worktree-common-git-directory.ts
- src/preload/api-types.ts
- src/main/index.ts
- src/main/ipc/worktree-base-directory-event-filter.ts
- src/main/ipc/repos.ts
- src/main/ipc/worktree-base-directory-watcher.test.ts
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Orca <help@stably.ai>
Fixes #5104
Summary
worktrees:changedrefresh path.UI State Behavior
Hiding N discovered worktreesis the initial hidden external-worktree review state for a repo. If another external worktree is created outside Orca while the repo is still in this state, it is folded into that same hidden-discovered count/list rather than shown as a separate inbox.New externally-created worktreesappears only after the initial hidden-worktree baseline has been handled/dismissed. It represents hidden external worktrees detected after that baseline, so the two bars should not appear together for the same repo.Design and Review
codex execfails with missingCODEX_LB_API_KEY; local review, perf audit, tests, and Electron validation were completed instead.Perf Audit
.git/gitdir:filesystem metadata.worktrees:changedevents.Validation
git worktree addunder configuredworktrees/project/<name>did not appear until manualfetchWorktrees(repoId).issue-5104-worktree-list-refresh; disposable repo under/private/tmp/orca-5104-final.Zx8ZjB; baseline visible count1; rawgit worktree add .../worktrees/project/external-final-5104 -b external-final-5104; after watcher debounce, visible count2and branchrefs/heads/external-final-5104appeared without manual refresh..playwright-cli/issue-5104-final-visible-worktrees.png.Checks
pnpm run typecheckpnpm run lintgit diff --checkpnpm exec vitest run --config config/vitest.config.ts src/main/ipc/worktree-base-directory-watcher.test.tsRisks
.gitcompletion signals.