fix(annotate): include original file annotations when submitting from linked doc view#536
Merged
backnotprop merged 4 commits intomainfrom Apr 11, 2026
Merged
fix(annotate): include original file annotations when submitting from linked doc view#536backnotprop merged 4 commits intomainfrom
backnotprop merged 4 commits intomainfrom
Conversation
… linked doc view When using `plannotator annotate` on a file with markdown links, annotations on the original file were silently dropped if the user clicked "Send Annotations" while viewing a linked document. The root cause was that `getDocAnnotations()` only read from `docCache` (previously-visited linked docs) and the current linked doc — it never read from `savedPlanState`, where the original file's annotations are stashed during navigation. This adds a `sourceFilePath` option to `useLinkedDoc` so the hook can key the stashed annotations in the returned Map. Also updates `docAnnotationCount` in `open()` so button visibility and exit warnings reflect reality immediately, not only after calling `back()`. Closes #535 For provenance purposes, this commit was AI assisted.
…navigation The first branch of open() set docAnnotationCount from only the original file's annotations, ignoring any linked docs already cached from prior navigation. After original → linkedA → back → linkedB, the count dropped to 0 if the original had no annotations, hiding the Send Annotations button despite linkedA's annotations sitting in docCache. Also adds defensive spread copies for savedPlanState arrays in getDocAnnotations() to match the hook's existing pattern. For provenance purposes, this commit was AI assisted.
…vent double-counting When navigating to a previously-cached linked doc, the destination's cached annotations were included in docAnnotationCount AND loaded into allAnnotations, causing the exit warning to report an inflated count. Skip the destination filepath when summing the non-active total. For provenance purposes, this commit was AI assisted.
When a linked document contains a link back to the source file (e.g., original.md → design.md → backlink to original.md), opening it as a linked doc created two competing Map entries for the same filepath in getDocAnnotations(). The empty linked-doc entry overwrote the stashed annotations, silently dropping them. Now detects when the resolved destination matches sourceFilePath and routes through back() instead, which caches the current linked doc and restores the source file with its annotations intact. For provenance purposes, this commit was AI assisted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getDocAnnotations()now includes stashed original-file annotations via a newsourceFilePathoption onuseLinkedDocdocAnnotationCountupdates immediately on navigation (not only onback()), so button visibility and exit warnings reflect the true annotation countRoot cause
useLinkedDoc.open()stashes original-file annotations intosavedPlanState(a ref), then swaps React state to the linked doc's annotations. ButgetDocAnnotations()only read fromdocCache+ the current linked doc — never fromsavedPlanState. The original file's annotations became invisible to the entire submission pipeline (annotationsOutputmemo →handleAnnotateFeedback→/api/feedback).Confirmed via runtime instrumentation: at submit time,
savedPlanStateheld 1 annotation butgetDocAnnotations()returned a Map without it.Scope
back()firstannotate-last: Unaffected — no file path to key againstTest plan
plannotator annotate original.mdwhereoriginal.mdlinks tolinked.mdplannotator annotate <dir>) is unaffectedCloses #535