Problem
Live Mode currently watches one file per window, but the watcher emits a pathless file-changed event. The frontend then reloads whichever tab is active at delivery time rather than the file that was watched.
This can overwrite unsaved edits in the active tab:
- Open
A.md, then B.md.
- Enable Live Mode while
B.md is active, so B.md is watched.
- Switch to
A.md and make an unsaved edit.
- Modify
B.md outside Markpad.
- The
B.md watcher event reloads A.md; its in-memory buffer is replaced and its dirty state is cleared.
Root cause
src-tauri/src/window_runtime.rs emits file-changed with () and src/lib/MarkdownViewer.svelte reloads currentFile, which is derived from the active tab. The event has no way to identify the watched path.
Expected behavior
A file-change event must carry the watched path. The UI must reload only when that path is the active Live Mode document; an event for another tab must never replace the active tab's buffer.
Scope
Keep the single-watcher model. Route the watched path through the event and add a regression test for the cross-tab case.
Problem
Live Mode currently watches one file per window, but the watcher emits a pathless
file-changedevent. The frontend then reloads whichever tab is active at delivery time rather than the file that was watched.This can overwrite unsaved edits in the active tab:
A.md, thenB.md.B.mdis active, soB.mdis watched.A.mdand make an unsaved edit.B.mdoutside Markpad.B.mdwatcher event reloadsA.md; its in-memory buffer is replaced and its dirty state is cleared.Root cause
src-tauri/src/window_runtime.rsemitsfile-changedwith()andsrc/lib/MarkdownViewer.sveltereloadscurrentFile, which is derived from the active tab. The event has no way to identify the watched path.Expected behavior
A file-change event must carry the watched path. The UI must reload only when that path is the active Live Mode document; an event for another tab must never replace the active tab's buffer.
Scope
Keep the single-watcher model. Route the watched path through the event and add a regression test for the cross-tab case.