Unposted review annotations become unreachable when the diff changes (draft is keyed by whole-patch hash)
Problem
Review annotations are persisted under contentHash(options.rawPatch) in packages/server/review.ts. Any change to the diff changes the key, and the previous draft is simply not looked up any more.
For a PR review that means: annotate a PR, close the session, a teammate pushes a commit, reopen the PR → every unsubmitted comment is gone from the UI. The draft file is still on disk under the old hash; it has only become unreachable.
GitHub keeps pending review comments across pushes and marks them "Outdated". This is a place where Plannotator loses work that the web UI would keep.
This looks like the same mechanism as #1136, which covers viewed-file state. The acceptance criteria there are written around viewed marks, so it may be worth confirming that the fix also carries the annotation draft, which rides the same key.
Reproduction (0.27.17, macOS)
- In any git repo with an uncommitted change, run
plannotator review. - Add an inline comment on the changed file. Close the tab without submitting.
- A new file appears in
~/.plannotator/drafts/<hash>.jsonand contains the comment. - Make one more edit to the same file so the diff changes.
- Run
plannotator reviewagain.
Expected: the comment from step 2 is shown, possibly marked outdated.
Actual: GET /api/draft returns {"found": false}, the UI shows no annotations, and the file from step 3 is still on disk, untouched.
Restarting with an unchanged diff restores the draft correctly, so this is specifically about the key changing, not about persistence in general. Same outcome for a PR review when the branch receives a new commit between sessions.
Proposed behavior
Key the review draft by the review target rather than by patch content, the way #1112 did for Guided Reviews:
- PR review: platform + host +
owner/repo#number - Branch / working-tree review: repository identity + compare target
On load, anchor each annotation by file path plus line or hunk content. Annotations whose anchor no longer matches are shown as outdated rather than dropped.
Acceptance criteria
- Reopening a PR review after new commits shows the previously saved, unsubmitted annotations.
- Annotations on unchanged lines keep their position; annotations on changed lines are marked outdated, not lost.
- Existing drafts stored under the content-hash key are migrated or remain discoverable.
Source: backnotprop/plannotator