Commit 171691c
authored
fix(annotate): include original file annotations when submitting from linked doc view (#536)
* fix(annotate): include original file annotations when submitting from 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.
* fix(annotate): include docCache in count when re-entering linked doc 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.
* fix(annotate): exclude destination doc from docAnnotationCount to prevent 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.
* fix(annotate): treat backlinks to source file as back() navigation
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.1 parent 0287b96 commit 171691c
2 files changed
Lines changed: 45 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| |||
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
221 | | - | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| |||
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
557 | 561 | | |
558 | 562 | | |
559 | 563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
56 | | - | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
112 | 128 | | |
113 | 129 | | |
114 | 130 | | |
| |||
120 | 136 | | |
121 | 137 | | |
122 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
123 | 145 | | |
124 | 146 | | |
125 | 147 | | |
126 | 148 | | |
127 | 149 | | |
128 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
129 | 160 | | |
130 | 161 | | |
131 | 162 | | |
| |||
219 | 250 | | |
220 | 251 | | |
221 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
222 | 260 | | |
223 | 261 | | |
224 | 262 | | |
225 | 263 | | |
226 | 264 | | |
227 | 265 | | |
228 | 266 | | |
229 | | - | |
| 267 | + | |
230 | 268 | | |
231 | 269 | | |
232 | 270 | | |
| |||
0 commit comments