Skip to content

Detect external edits to note files and prompt user to reload #212

@matt-pharr

Description

@matt-pharr

Summary

When a note file is open in the PDV editor, the app should detect if the underlying file on disk has been modified externally (e.g., by a text editor or git operation) and warn the user rather than silently overwriting the external changes on the next auto-save.

Proposed Approach

Use a checksum-based conflict detection strategy (leveraging the existing xxhash dependency):

  1. On each save attempt (500ms debounced), compute the checksum of the in-editor note content
  2. If it matches the last-saved checksum, skip the save (no changes)
  3. If it differs, check the checksum of the file on disk against the last-saved checksum
  4. If the disk file also differs from last-saved (i.e., external edit detected), show a warning dialog prompting the user to:
    • Reload — discard in-editor changes and load the disk version
    • Overwrite — save the in-editor version, discarding the external changes
    • Cancel — keep both versions as-is until the user decides
  5. Consider also adding a manual Reload from disk action (e.g., in the note context menu or toolbar)

Context

From PR #195 discussion. Currently PDV assumes all edits to project files happen through the app. Users who edit note files externally (common for markdown notes or config-style files) risk losing those changes silently.

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