fix(watch): the owner's folder choice must never be overwritten

Two bugs found while filing the Obsidian Sorter note itself:

1. proposed_toc went stale when proposed_folder was edited by hand.
   The watcher now re-resolves the index line from the folder on every pass.

2. Re-proposing after a body edit clobbered a hand-edited proposed_folder.
   The watcher's own suggestion is now kept separately in
   proposed_folder_auto, so a difference marks a human choice, which wins.

Adds two guard tests. 17/17 passing.
This commit is contained in:
sam
2026-09-26 06:57:41 +10:00
parent 2c7c8257d1
commit 92ea55f77d
2 changed files with 60 additions and 13 deletions

View File

@@ -326,6 +326,29 @@ def main() -> int:
except OSError:
pass
# ---- watcher: the owner's hand-picked folder must survive ----------
from sorter.watch import user_selected_folder
from sorter.models import Note as _Note
def _n(chosen, auto):
return _Note(path="x", rel_path="010 inbox/x.md", filename="x.md",
stem="x", title="x", note_type="note", status=None,
fm={"proposed_folder": chosen, "proposed_folder_auto": auto})
if user_selected_folder(_n("300 areas/A", "200 projects/B")) == "300 areas/A":
print("PASS guard: a hand-edited folder is treated as the owner's choice")
passed += 1
else:
details.append("FAIL guard: hand-edited folder not detected")
failed += 1
if user_selected_folder(_n("200 projects/B", "200 projects/B")) is None:
print("PASS guard: an untouched proposal is not treated as customised")
passed += 1
else:
details.append("FAIL guard: untouched proposal wrongly seen as customised")
failed += 1
# ---- inbox cleared --------------------------------------------------
left = [p for p in (vault / args.inbox).glob("*.md")
if not p.name.startswith("_")]