Skip to content

Commit 0a63c6f

Browse files
committed
fix(pdf-server): rebase annotations baseline after save
After a successful save_pdf, update pdfBaselineAnnotations and pdfBaselineFormValues to reflect what was written to disk. Without this, removing all annotations after a save produced an empty diff (compared to the stale pre-save baseline), incorrectly disabling the save button even though the file on disk still had annotations.
1 parent c557635 commit 0a63c6f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

examples/pdf-server/src/mcp-app.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,6 +3729,14 @@ async function savePdf(): Promise<void> {
37293729
const sc = result.structuredContent as { mtimeMs?: number } | undefined;
37303730
lastSavedMtime = sc?.mtimeMs ?? null;
37313731

3732+
// Rebase: the file on disk now contains our annotations + form values.
3733+
// Update the baseline so future diffs are relative to what was saved.
3734+
pdfBaselineAnnotations = [...annotationMap.values()].map((t) => ({
3735+
...t.def,
3736+
}));
3737+
pdfBaselineFormValues.clear();
3738+
for (const [k, v] of formFieldValues) pdfBaselineFormValues.set(k, v);
3739+
37323740
setDirty(false); // → updateSaveBtn() disables button
37333741
const key = annotationStorageKey();
37343742
if (key) {

0 commit comments

Comments
 (0)