Skip to content

Keep file changes visible while the file watcher is paused after repeated crashes - #52678

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/watcher-fuse-cooldown-resync
Nov 30, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/watcher-fuse-cooldown-resync

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Orca's file watcher crashes too many times, Orca stops watching files for a while (5 to 60 minutes) before trying again. During that pause, files that changed on disk did not show up in the file explorer or open editors. Now Orca checks again every 10 seconds during the pause, so changes still appear, just a little later.

Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​120
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​138 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​106

What Changed

  • Before: when the crash breaker dropped a root, its listeners got one refresh at the drop and one after the cooldown. Nothing in between.
  • After: while the cooldown wait is pending, a slow timer (10 s) sends each dropped root's listeners the same catch-up refresh the app already sends after a watch gap (resync), marked watchStillDown so the renderer does not ask to watch again (that would cancel the cooldown). The renderer handles it as it does after any gap: the explorer re-reads the folders it shows, git status refreshes the active worktree, clean editor tabs reload or get marked stale, dirty tabs are compared with disk, and deleted files are detected.
  • One timer is shared by every dropped root and refreshes at most 8 roots per tick, taking turns by root so every root gets one. It stops when the cooldown ends (rewatch), when the last listener unwatches or goes away, and on quit, through the existing retry cancel. While the window is hidden or minimized it parks and refreshes when the window shows again.
  • No timer runs when no root is dropped.

Why

The breaker's own comment already says callers need their own polling while it is open; only the git common-dir watch had one. Reusing the overflow refresh keeps the cost to what the user is looking at, instead of walking whole trees to diff them. 10 s is a fallback cadence for a degraded state that lasts minutes.

Linked Issue

Internal (item 769).

Visual Proof

N/A: main-process change to a failure-only path (the watcher crash breaker); the visible effect is the existing overflow refresh, covered by the tests below.

Testing

  • filesystem-watcher-crash-fuse-rewatch.test.ts (real watcher handlers, only the watcher child mocked):

    • refreshes reach the renderer every 10 s during the cooldown, stop after the rewatch, and no timers remain;
    • unwatching during the cooldown stops the timer and the retry;
    • watching a healthy root arms no timer.
  • The first two fail with the fix reverted.

  • Scale check: 2,000 roots dropped at once and re-registered every cooldown for 12 cycles: at most 8 refreshes per tick, every root served, 0.33 ms per tick on main, no timers left after stop.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

Performance

Only runs while the crash breaker has dropped at least one root and a window is visible: one main wakeup per 10 s (0 when hidden or healthy) and at most 8 small IPC messages per tick, whatever the number of dropped roots (0.33 ms per tick at 2,000 roots). Renderer work per tick is at most 8 roots' gap reconciliation, the same work a single watch gap already costs per root: the explorer's loaded folders when that root is shown, git status for the active worktree, an existence probe of those roots' clean tabs and a disk read of their dirty tabs. Watched roots are the explorer's root and roots with open tabs, not every workspace.

Risk

Level: Low

Only the crash-breaker cooldown path changes. If it misbehaved, users in that degraded state would see the explorer refresh every 10 s. Plain revert.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Cross-platform: timers and Electron window state only; WSL roots have no crash breaker and are unchanged. Remote/SSH roots watch through runtime streams and are unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@brennanb2025
brennanb2025 marked this pull request as ready for review November 29, 2026 23:08
@brennanb2025

Copy link
Copy Markdown
Contributor Author

QA on 374e2d1 (Linux, dev build, profile seeded with 1,901 workspaces, 1,800 chat tabs and 200 terminals). The file watcher's child process was killed 3 times, which opened the crash breaker for 300 s. The only commit since, 3a40651, drops an unrelated lockfile change; the code is identical.

Flow Result
New file created during the cooldown Shown in the explorer within 4.5–7 s (on the next 10 s refresh)
Active clean tab overwritten on disk New text shown in 1.5 s
Dirty tab's file overwritten on disk "Changed on disk" banner, unsaved text kept
Open file deleted on disk Tab marked deleted
Cadence Refresh every 10.0 s; the watch was never retried early; the breaker stayed open its full 300 s
Cooldown ends Rewatch 77 ms after it ends; new file shown in 530 ms; no refreshes in the next 60 s
All tabs closed during a cooldown No refreshes for that root in the next 60 s
Base f9f7ebb6ef5, same steps New file and edit still missing after 115 s (the bug)

CPU during the cooldown: main +1.3 points, renderer +0.4 points vs healthy (60 s samples, fleet profile loaded).

QA evidence: new file during the cooldown / dirty-tab conflict / base build after 60 s (file still missing)

B1-new1.png
B3-b-conflict.png
C5-after-60s.png

Not covered in the app: more than 8 dropped roots at once, and parking while the window is hidden. A local harness covered both: at most 8 refreshes per tick, every one of 2,000 roots served, no timers while hidden, and one refresh on show.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds scheduled catch-up resyncs while a local watcher is down during its cooldown. The scheduler processes up to eight roots per batch and checks window visibility before running. Catch-up notifications include a watchStillDown flag, which the renderer uses to exclude them from deferred watch-root refreshes. Tests cover cooldown notifications, retry behavior, unwatching, and timer cleanup.

Merge Risk: Low · up to 62489

While the file watcher is paused after repeated crashes, file changes now stay visible through periodic catch-up refreshes. That costs a small, bounded amount of extra CPU during the cooldown. In a slow-disk case a clean tab may stay stale until the watcher is retried. Neither issue is likely to block merging, but owners should be aware of both.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: while the file watcher is paused after repeated crashes, file changes stay visible. The changeset adds a 10-second resync timer during the crash-breaker cooldown that …
Description check Passed The description follows the repository template: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill boundary, Notes, and Checklist. It …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: while the file watcher is paused after repeated crashes, file changes stay visible. The changeset adds a 10-second resync timer during the crash-breaker cooldown that refreshes explorer, git status, and open tabs, which matches the title.

Full details: Description check

Explanation

The description follows the repository template: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill boundary, Notes, and Checklist. It explains the before and after behavior, the mechanism, the test coverage, and the risk with a rollback method. The Linked Issue section cites an internal item rather than a GitHub issue. The Risk section does not set the Level field to a value and the AI Disclosure section is left empty.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2685df5-6e2b-41bc-bb82-85e9727cbc3c
Commits

Reviewing files that changed from the base of the PR and between 4e81886 and 6248926.

Files selected for processing: 1

  • src/main/ipc/filesystem/watchers/filesystem-watcher-crash-fuse-resync.performance.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Keeps file changes visible while the watcher waits through a crash cooldown.

  • Local files keep showing changes while a crashed watcher waits to restart.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Watcher crash cooldown] --> B[Register root for polling]
  B --> C{Window visible or windowless launch?}
  C -->|Yes| D[Send catch-up refresh for up to eight roots]
  D --> E[Wait ten seconds]
  E --> C
  C -->|No| F[Wait for show or restore]
  F --> D
  D --> G[Renderer refreshes files without restarting watch]
  B --> H[Cooldown ends or last listener leaves]
  H --> I[Remove root and stop polling when empty]
Loading

Reviews (3) · Last reviewed commit: "test(file-watch): pin every launch-polic..." · Reviewed by Greptile

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66a334d9-f451-4553-b1f0-a84772655bf7
Commits

Reviewing files that changed from the base of the PR and between 93af120 and 3a40651.

Files selected for processing: 6

  • src/main/ipc/filesystem/watchers/filesystem-watcher-crash-fuse-resync.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-crash-fuse-rewatch.test.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-local-capacity.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-pause-state.test.ts
  • src/renderer/src/hooks/useEditorExternalWatch.ts
  • src/shared/file-watch/filesystem-change-event.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 18efdcd6-9c5c-4d9d-9a45-e5368b9b6c2c
Commits

Reviewing files that changed from the base of the PR and between 3a40651 and 4e81886.

Files selected for processing: 1

  • src/main/ipc/filesystem/watchers/filesystem-watcher-crash-fuse-resync.performance.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@brennanb2025
brennanb2025 merged commit d2deed6 into main Nov 30, 2026
61 checks passed
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.

1 participant