mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
567cf8050e
The code-review autosave skipped saving when the annotation list was empty (`if (annotations.length === 0 && viewedFiles.size === 0) return`). So deleting the last annotation never overwrote the stale draft on the server; on refresh the draft-recovery dialog offered the deleted annotations back. Mirror the plan-side useAnnotationDraft pattern: when the list is cleared, DELETE the draft with a generation tombstone (so it can't resurface and a late save can't revive it) instead of skipping. Guarded so an empty state only triggers a delete once the user has actually authored annotations this session — keyed on user-authored (non-source) annotations only, because viewedFiles are seeded from GitHub on mount and external/SSE annotations have their own lifecycle; counting either would let a fresh load or external churn wrongly delete an unrestored draft. Also clear the pending autosave timer in restoreDraft/dismissDraft so a stale save can't fire after restore/dismiss. Adds real-stack regression tests (hook + disk layer via an /api/draft shim): delete-to-empty removes the draft, a fresh/unengaged session preserves an unrestored draft, and external-annotation churn issues no delete. Reported by @alexanderkreidich. Closes #948
9.6 KiB
9.6 KiB