Problem
Preview refresh watches the target file directly, accepts only change events, and assumes the watcher remains attached to the same file identity. Editors that save through a temporary file and rename it over the original can emit rename, invalidate the watcher, or expose the path before the new write is stable.
The preview can therefore stop refreshing after an ordinary atomic save.
Evidence
electron/main.cjs:1679-1710 creates a direct fs.watch watcher.
electron/main.cjs:1693-1703 ignores every event except change and only debounces for 300 ms.
src/hooks/useFileWatcher.ts:22-72 sets up the watcher once and treats each emitted signal as a finished update.
README.md:42 advertises automatic preview refresh.
dev-docs/BACKLOG.md:33 marks the feature complete.
Proposed work
- Keep the implementation in Node, the runtime that already owns the preview.
- Treat watcher events as signals and reconcile the target path with
stat.
- Handle rename, delete, and recreate saves, reattaching when the file identity changes.
- Wait for a stable file before notifying the renderer.
- Add an error handler and bounded recovery behavior.
Acceptance criteria
- Start with failing tests for an in-place write and a temporary-file rename over the target.
- Auto-refresh continues after several atomic replacements.
- Unrelated changes in the parent directory do not refresh the preview.
- Delete and recreate produces a bounded retry or a clear error.
- Cleanup closes timers and watchers without leaking listeners.
- Each completed save produces one refresh after debouncing.
Non-goals
- Do not add PowerShell, direct .NET, or another watcher runtime.
- Do not turn preview watching into a render-job queue.
- Do not add an unbounded polling loop.
Problem
Preview refresh watches the target file directly, accepts only
changeevents, and assumes the watcher remains attached to the same file identity. Editors that save through a temporary file and rename it over the original can emitrename, invalidate the watcher, or expose the path before the new write is stable.The preview can therefore stop refreshing after an ordinary atomic save.
Evidence
electron/main.cjs:1679-1710creates a directfs.watchwatcher.electron/main.cjs:1693-1703ignores every event exceptchangeand only debounces for 300 ms.src/hooks/useFileWatcher.ts:22-72sets up the watcher once and treats each emitted signal as a finished update.README.md:42advertises automatic preview refresh.dev-docs/BACKLOG.md:33marks the feature complete.Proposed work
stat.Acceptance criteria
Non-goals