Skip to content

Unposted review annotations become unreachable when the diff changes (draft is keyed by whole-patch hash) #1590

Closed

Description

@RobertoArtiles

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)

  1. In any git repo with an uncommitted change, run plannotator review.
  2. Add an inline comment on the changed file. Close the tab without submitting.
  3. A new file appears in ~/.plannotator/drafts/<hash>.json and contains the comment.
  4. Make one more edit to the same file so the diff changes.
  5. Run plannotator review again.

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.

Activity

  1. backnotprop commented on Sep 22, 2026

    @backnotprop
    Owner

    Thanks @RobertoArtiles, this is a clear and well-specified report, and the reproduction is exact. Confirmed it is long-standing rather than new in 0.27.17: the draft has been keyed by the whole-patch hash since drafts existed. Your read of #1136 is right too, viewed state rides the same key, so the fix should carry both. Keying by review target with per-file anchoring, the way #1112 did for guides, is the shape I'd expect; the owner will weigh in on scheduling.

  2. added
    bug
    on Oct 21, 2026
  3. backnotprop commented on Oct 21, 2026

    @backnotprop
    Owner

    Fixed in #1592.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions