Skip to content

feat(notes): watch external changes and preserve conflicts - #158

Open
F4M1N3C wants to merge 1 commit into
noctalia-dev:mainfrom
F4M1N3C:feat/notes-watch-conflict-preservation
Open

F4M1N3C wants to merge 1 commit into
noctalia-dev:mainfrom
F4M1N3C:feat/notes-watch-conflict-preservation

Conversation

@F4M1N3C

@F4M1N3C F4M1N3C commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

Watch the notes folder while the panel is open and fold outside edits into the
editor instead of losing them. Compatible appends are merged with the local
buffer; an incompatible change keeps the local text and saves a copy under
.conflicts/ instead of overwriting what someone else wrote.

  • notes/merge.luau (new): pure 3-way resolver returning same / local /
    remote / merged / conflict.
  • notes/panel.luau: per-tick directory signature (name + mtime + size), the
    save path merges before writing, and conflicts are reported once per remote
    revision with a copy of the unsaved text.
  • notes/plugin.toml: new watch setting (bool, default true); version
    1.3.0 → 1.4.0.
  • notes/README.md, notes/translations/en.json: document the setting and the
    conflict behavior.

Motivation

Notes are plain files, so another editor, a sync tool or a script can change
them while the panel is open. Today the panel only reacts to the launcher's own
notes_bump signal, and there are two silent data losses:

  • an external edit is overwritten by the next autosave of the open note;
  • an unsaved local edit is replaced by the launcher's merge rule when the
    external change is not a simple append.

This PR makes both cases safe and keeps the behavior opt-outable with watch.

Type of Change

  • Bug fix
  • New feature

Related Issue

None.

Testing

  • luau-compile on every changed entry (panel.luau, merge.luau, plus
    dirs.luau, notes.luau, launcher.luau) - all passed.
  • noctalia plugins lint notes → 0 errors, 0 warnings.
  • .github/actions/validate-plugins/validate-plugins.py --profile official
    → Validated 14 plugin manifest(s).
  • Host-mock harness (in-memory Noctalia API + UI stubs) running the real
    panel.luau: a compatible external append is merged and written back; an
    incompatible external edit is not overwritten, is reported once, and the
    local text lands in .conflicts/.
  • The .conflicts folder is created on demand and is not listed as a note.
  • Live check on Hyprland with the panel entry from this branch: an external
    append appeared in the open editor without reloading; an incompatible
    external rewrite kept the disk text, showed the conflict notification and
    wrote the unsaved local text to .conflicts/, which the note list ignores.

Manual Coverage

  • Tested on Niri
  • Tested on Hyprland
  • Tested on Sway
  • Tested on another compositor:
  • Tested with different bar positions and density settings
  • Tested at different interface scaling values
  • Tested with multiple monitors

Screenshots / Videos

No visual changes.

Checklist

  • This PR is ready for review, or it is marked as Draft.
  • I self-reviewed the changes.
  • I added or updated translations/en.json, or this PR adds no new user-facing strings.
  • I did not edit non-English translation files unless this PR is explicitly for translation tooling, an import/export sync, or a maintainer-requested locale change.

Additional Notes

  • Manual UI testing was done on Hyprland only; Niri, Sway and the bar/scaling
    matrix were not exercised. The polling is one listDir + one fileInfo per
    note per second while the panel is open, and it stops when watch is off.
  • With watch off, the panel keeps the previous behavior: launcher captures
    still refresh the open note via notes_bump.
  • Conflict copies use the note name plus a timestamp, so repeated conflicts on
    the same note do not collide.

Poll the notes folder about once per second while the panel is open and fold
outside edits into the editor instead of losing them on the next autosave:
compatible appends are merged with the local buffer, and an incompatible
change keeps the local text and saves a copy under .conflicts/ instead of
overwriting what someone else wrote.

- merge.luau: pure 3-way resolver (same/local/remote/merged/conflict)
- panel.luau: directory signature per tick, merge on load/save, conflict copy
- plugin.toml: watch setting (bool, default on), version 1.4.0
- README + en.json: document the setting and the conflict behavior
@F4M1N3C

F4M1N3C commented Nov 18, 2026

Copy link
Copy Markdown
Author

Tested on Hyprland (panel entry from this branch, Noctalia API 26):

  • Opened the panel on a test note and appended a line to the file from a shell: the open editor folded it in live (~1 s), no reload.
  • While the editor had unsaved text, rewrote the same file from the shell with incompatible content: the file kept the external text, both notifications showed ("changed outside the editor" + "copy saved in .conflicts"), and .conflicts/zz-live-test (2026-11-18 08.58.40).md held the unsaved local text. The note list ignores the folder.
  • The panel's own autosave did not overwrite the external write in that state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant