Skip to content

Files created while the app is closed or in a background workspace never appear (no catch-up rescan) #18

Description

@anbturki

Summary

The file tree only updates from live watcher events on the active workspace. There is no catch-up rescan on app launch, on workspace switch, or on window focus, so anything written while the app was closed, or while a different workspace was active, never appears until an unrelated create/remove/rename event forces a rescan or the user clicks the manual refresh button.

Reproduction (release build of f485396, macOS)

  1. Open a workspace and let it scan (2 files: done/shipped-feature.md, research/getting-started.md).
  2. Quit the app.
  3. Create research/created-while-closed.md on disk.
  4. Relaunch the app: the sidebar still shows 2 files. The new file never appears (first screenshot).
  5. With the app running, create research/created-while-running.md: the watcher rescan makes both files appear at once (second screenshot, "4 files").

Step 5 is the control: the watcher pipeline works, only the catch-up is missing. The same gap applies to switching workspaces, since the single watcher is keyed to the active root and a background workspace has no watcher at all.

Root cause

  • Startup hydrates the cached scan only and never rescans: src/hooks/useLibrary.ts:237-250. The cache stores cachedAt but nothing ever checks it (src/lib/storage.ts:180-194).
  • selectRoot never rescans when switching workspaces: src/hooks/useLibrary.ts:305-312.
  • The window-focus handler only reconciles the registry for newly added workspaces (src/hooks/useLibrary.ts:216-234, 473); it never rescans existing roots.
  • Related gap while active: the watcher drops the "other"/"any" event kinds that notify emits when FSEvents overflows and requests a rescan (src/lib/events.ts:10-26, src/hooks/useLibrary.ts:407-409), so bulk write bursts can also be missed.

Proposed fix

Stale-while-revalidate: keep showing the cached tree but kick a rescan on launch for the selected root, on selectRoot, and on window focus for the active root. Treat "other"/"any" watch events as a rescan trigger. Rescans are already debounced and rate limited, so the added cost is bounded.

Screenshots

After relaunch, file missing (step 4), then both files appear after the live create (step 5):

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions