Undoing a saved pin delete restores a numbered marker with no note#1591

openedSep 25, 2026byBbirdbrain-agent

Defect: undoing the delete of a saved annotation pin brings back a numbered marker with no note.

What: After an operator deletes a saved pin and presses undo, the marker reappears on the screenshot but its note is gone, so an exported image can show a numbered pin that no longer has a note. It was kept out of the change that found it because the fix is either making saved-pin deletes impossible to undo, which is a product call, or restoring the pin with its number through the main process.

Where it is and how to reproduce it

Where: src/renderer/components/captures/annotation/AnnotationEditor.tsx:72 removes the saved pin from storage, but the shape stays in the undo history; the cancelled-draft path was fixed in PR #1579 with a new discardShape, the saved-pin path was not. Reproduce: open a capture's annotation editor, add a pin with a note and save, delete that pin from its popover or with the Delete key, then press undo.

1pnpm test tests/components/AnnotationEditor.test.tsx
Synced from GitHub

A related gap found in the same review: a Cancel that lands while an automatic save is still being written is not persisted until the next edit.

Detail

From the round-3 pre-pass of PR #1579: the in-flight autosave's success marks the canvas saved and drops the re-save the Cancel queued, so the stored layout keeps the marker although its note row is deleted. The timing bug predates #1579 and affects every annotation edit, not only pins. Reproduced with a scratch test (save ran once, not twice).

Note

Claude responding on behalf of Matt.

This was generated by AI during triage.

Agent Brief

Category: bug, evidence-affecting Summary: Deleting a saved annotation pin cannot be undone, so undo never brings back a numbered marker whose note is gone.

Triage confirmed the defect from the code on 2026-10-05. Deleting a saved pin removes its note from storage at once, but the marker stays in the editor's undo history, so undo restores a numbered marker with no note, and an exported image can show it.

Decision taken during triage: a saved pin's delete leaves the undo history, the same way a cancelled draft pin already does. Restoring the note through undo is not attempted, because the delete has already been stored.

Current and desired behavior, interfaces, acceptance criteria, verification and scope

Current behavior (read at origin/main 43906e63, not run)

  • removePin in the annotation editor calls editor.removeShape(shape.id) and mutations.deletePin.mutate(shape.pinId). removeShape pushes the previous shapes onto the undo stack.
  • The draft-cancel path already uses editor.discardShape, whose comment says a shape whose backing record no longer exists must leave the history as well as the canvas.
  • removePin is reached from the pin popover's delete and from the Delete key shortcut.

Desired behavior

  • Deleting a saved pin, by either route, removes it from the canvas, the undo stack and the redo stack, and deletes the pin record.
  • Undo and redo after that never show the deleted pin.
  • Deleting a shape that is not a pin is unchanged and stays undoable.

Acceptance criteria

  • Add a pin, save a note, delete it from the popover, press undo: the pin does not reappear.
  • The same with the Delete key.
  • Undo after deleting a rectangle or arrow still restores it.
  • The cancelled-draft test added in PR #1579 still passes.

Verification

pnpm test tests/components/AnnotationEditor.test.tsx, then pnpm preflight on Node 20.

Starting files

  • src/renderer/components/captures/annotation/AnnotationEditor.tsx (removePin)
  • src/renderer/components/captures/annotation/useAnnotationEditor.ts (discardShape, removeShape)
  • tests/components/AnnotationEditor.test.tsx

Evidence-affecting: yes. The annotation editor is on the blocking tier because its shapes are burned into exported images. The label is now on the issue.

Out of scope

  • The autosave race in the comment above, where a Cancel during an in-flight save is not persisted until the next edit. It affects every annotation edit and needs its own fix.
  • Making a saved-pin delete restorable.