Repository navigation
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds a shared Git metadata polling scheduler with visibility handling, poll coalescing, staggered schedules, and bounded filesystem I/O. Existing repository and worktree pollers now use the scheduler and I/O wrapper. Common-directory snapshots detect worktrees directory replacement. A crash-isolated narrow watcher now handles retries, stale generations, root replacement, and polling fallback. Reconciliation polling performs forced full scans. Tests cover concurrency, timing, visibility, and watcher lifecycle behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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: 3
🧹 Nitpick comments (4)
src/main/ipc/git-metadata-poll-scheduler.ts (2)
71-78: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSeparate the poll-concurrency limit from the filesystem-I/O limit.
this.concurrencybounds two unrelated things: concurrentruncallbacks indrainPollQueue(Line 240) and concurrent filesystem operations indrainFilesystemQueue(Line 282). The constant is namedGIT_METADATA_FILESYSTEM_CONCURRENCY, so the poll limit is invisible to callers and cannot be tuned independently. Introduce a second field with its own constant.♻️ Proposed split
export const GIT_METADATA_FILESYSTEM_CONCURRENCY = 8 +export const GIT_METADATA_POLL_CONCURRENCY = 8 @@ constructor( private readonly concurrency = GIT_METADATA_FILESYSTEM_CONCURRENCY, - private readonly now: () => number = () => performance.now() + private readonly now: () => number = () => performance.now(), + private readonly pollConcurrency = GIT_METADATA_POLL_CONCURRENCY ) {
180-214: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoffConsider a due-time heap if target counts grow.
armTimerandcollectDuePollseach iterate every registered poll. Staggered phases produce about one timer fire per poll per interval, so the scan cost per interval grows with the square of the target count. With a few hundred targets this is acceptable. If the host must hold thousands of targets, replace the linear scan with a min-heap keyed ondueAt.src/main/ipc/git-metadata-poll-scheduler.test.ts (1)
50-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for
setIntervalMsandreschedule.The suite exercises the timer, coalescing, and visibility paths only.
setIntervalMsrecomputesdueAtonly while the poll runs, andfolder-repo-git-upgrade.tsdepends on that exact branch to switch between the active and idle cadence.reschedulealso has a distinct hidden-window branch that parks the poll. Add two cases: an interval change applied from inside a runningrun, and areschedulecall while the window is hidden.src/main/ipc/worktree-git-common-polling.ts (1)
44-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExpose the directory identity from the signature producer instead of parsing the string.
gitCommonDirectoryIdentityrecovers the inode by slicing the signature thatgitCommonDirectorySignaturebuilds insrc/main/ipc/worktree-git-common-entry-snapshot.ts. The two modules share only an unwritten string format. If that format changes, this parse still returns a value, and root-replacement detection at Line 192 fails without any error. Return the identity from the producer, or add a shared parser next to the producer.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 58014987-6ecb-45f6-abbc-2bc0ce1968ec
📒 Files selected for processing (11)
src/main/ipc/folder-repo-git-upgrade.tssrc/main/ipc/git-metadata-poll-scheduler.test.tssrc/main/ipc/git-metadata-poll-scheduler.tssrc/main/ipc/worktree-base-directory-poller.tssrc/main/ipc/worktree-git-common-entry-snapshot.tssrc/main/ipc/worktree-git-common-narrow-watch.tssrc/main/ipc/worktree-git-common-polling.tssrc/main/ipc/worktree-git-common-primary-polling.tssrc/main/ipc/worktree-git-common-watch-reconciliation.tssrc/main/ipc/worktree-git-common-watch.test.tssrc/main/ipc/worktree-git-common-watch.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| usingPollingFallback = true | ||
| const pending = reconciliation | ||
| .unsubscribe() | ||
| .catch(() => {}) | ||
| .then(() => | ||
| startGitCommonPolling(target.path, onEvents, pollIntervalMs, visibility, onFullScan, false) | ||
| ) | ||
| .then(async (fallback) => { | ||
| if (disposed || subscription) { | ||
| await fallback.unsubscribe() | ||
| return | ||
| } | ||
| subscription = fallback | ||
| }) | ||
| const tracked = pending.finally(() => { | ||
| if (pollingFallbackPromise === tracked) { | ||
| pollingFallbackPromise = null | ||
| } | ||
| }) | ||
| pollingFallbackPromise = tracked | ||
| return pollingFallbackPromise |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Clear fallback state when fallback startup fails.
If startGitCommonPolling rejects during setup, usingPollingFallback remains true. The error path can re-arm a native subscription, but canStart and shouldKeep then prevent reconciliation from starting. The forced reconciliation path stays disabled after a transient filesystem error.
Reset usingPollingFallback when fallback setup fails. Add a regression test for a rejected fallback initialization followed by a successful native re-subscribe.
| if (installed && !disposed) { | ||
| stopExistencePoll() | ||
| await reconciliation.ensureStarted() | ||
| // The dir appearing means a first linked worktree was just | ||
| // registered; surface it so the repo's worktree list refreshes. | ||
| onEvents([{ type: 'create', path: worktreesDir }]) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Retry a failed reconciliation startup.
If reconciliation.ensureStarted() rejects, this call rejects after the native subscription is installed and the existence poll is stopped. Calls from the interval and visibility handler discard that rejection. Later upgrade attempts do not retry because subscription is already set.
Make reconciliation startup retry independently of native subscription installation. Add a test that makes the initial reconciliation snapshot fail once.
| const coarseRootReplacement = events.some( | ||
| (event) => | ||
| event.type === 'create' && | ||
| event.path !== worktreesDir && | ||
| dirname(event.path) === worktreesDir | ||
| ) | ||
| if (rootWasReplaced || coarseRootReplacement) { | ||
| onRootReplacement() | ||
| } | ||
| onEvents( | ||
| coarseRootReplacement | ||
| ? events.map((event) => | ||
| event.type === 'update' && event.path === worktreesDir | ||
| ? { ...event, type: 'create' } | ||
| : event | ||
| ) | ||
| : events | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not treat every child creation as a root replacement.
A normal git worktree add creates a path directly under worktreesDir. That makes coarseRootReplacement true. The caller then removes the active native subscription and may rewrite a root update event to create, although the root was not replaced.
Trigger this recovery only from confirmed root replacement evidence, such as root identity change or explicit root delete/create events. Add a test that a normal child creation keeps the native subscription active.
|
Closing: reconciliation and hidden-window parking already landed on main. Staggering on top doesn't buy enough to keep. |
Problem / Why
Visible Orca windows currently give every repository its own 2-second Git metadata timer. At fleet scale those timers align into filesystem bursts across repositories and linked worktrees. The macOS native watcher is fast when healthy, but a silently lost native stream also needs bounded reconciliation so external branch, index, upstream, and linked-worktree changes cannot stay stale indefinitely.
Solution
worktreesroot identity, re-arm native watching after same-name root replacement, and generation-fence stale callbacks, interruption hooks, and late subscription resolutions.ELI5
Instead of every repository ringing its alarm at the same moment, one host clock gives each repository a different turn and allows only eight filesystem checks at once. Hidden windows stop taking turns and catch up once when shown. macOS still uses its instant native watcher, while a quiet 30-second safety check repairs a watcher that silently stopped reporting.
Proof
pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/git-metadata-poll-scheduler.test.ts src/main/ipc/worktree-git-common-watch.test.ts src/main/ipc/worktree-base-directory-poller.test.ts src/main/ipc/folder-repo-git-upgrade.test.tspnpm run typecheck:nodeUser tradeoffs
Readiness verdict
CLEAN — P0: 0, P1: 0, P2: 0.
Review status
c51edbda012b1ac3c00b67471213a9fff008e932