Skip to content

Live Mode can reload the wrong tab after an external file change #295

Description

@PathGao

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:

  1. Open A.md, then B.md.
  2. Enable Live Mode while B.md is active, so B.md is watched.
  3. Switch to A.md and make an unsaved edit.
  4. Modify B.md outside Markpad.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions