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):
- On each save attempt (500ms debounced), compute the checksum of the in-editor note content
- If it matches the last-saved checksum, skip the save (no changes)
- If it differs, check the checksum of the file on disk against the last-saved checksum
- 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
- 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.
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
xxhashdependency):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.