Ctrl+Z after a peer's edit no longer reverts (and re-broadcasts) the peer's work, and the adopt undo-bomb is gone: - doApply/doApplyItems (both editors) Push with SKIP_UNDO; the emit path is unaffected (suppression keys off s_applyingRemote, not undo). - With SKIP_UNDO no picker owns removed items — the bindings free them after Push (explicit removals + upsert's remove-before-re-add; fields excluded: CHT_REMOVE hides them, parent keeps ownership). Freeing stays out of the fork commit classes so DRC's SKIP_UNDO callers can't double-free. - Test hooks kicadCollabTestUndo/UndoDepth, registered per-editor AND in the kicad_editor dispatcher (merged image compiles out per-app registrations). - kicad pointer: eeschema UUID undo guard + SKIP_UNDO connectivity split + quiet stale-entry drop (ca8877324c). - tests/kicad/collab-undo.spec.ts: 5 scenarios (no undo entry from remote applies; selective undo; stranded replaced/deleted entries) — 5/5, plus collab/ysync regression 30 pass. - docs: ysync-review 20 fix record; 09 marked FIXED; overview indexed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ejJEvS7ogef2o9gVTXjmp
4 KiB
4 KiB
Fix 20 — Miss 09 implemented: local-ops-only undo (option 1)
Status: DONE, e2e-verified 2026-07-07 (5/5 firefox + collab/ysync regression suites) Design: 09-miss-undo-not-collab-aware.md option 1, feasibility per 19-undo-option1-feasibility.md
Remote applies no longer land on the receiving editor's undo stack: Ctrl+Z after a peer's edit reverts your own last op, never the peer's, and the adopt "undo bomb" is gone (adopt creates no undo entry at all — 09's option 3 history-barrier is moot).
What changed
KiCad fork
eeschema/schematic_undo_redo.cpp— UUID stale-pointer guard inPutDataInPreviousState, mirroring pcbnew's: every picker (exceptDELETED,PAGESETTINGS,REPEAT_ITEM, and the root sheet, whichResolveItemcannot see) is existence-checked viaSCHEMATIC::ResolveItem(uuid). Missing → picker dropped (not_found→wxLogWarning, no modal). Present-but-different-pointer (a remote apply replaced the object, same uuid) → the picker is re-anchored (SetPickedItem) and the restore targets the current live item. Without this, undoing an entry whose item a remote apply freed dereferenced a dangling pointer.eeschema/sch_commit.cpp—RecalculateConnectionsmoved out of the!( aCommitFlags & SKIP_UNDO )gate inpushSchEdit: a commit that skips undo still changes the model, and remote applies rely on the recalc (it was the whole point of applying through real commits).SaveCopyInUndoListstays gated.pcbnew/undo_redo.cpp— the "Incomplete undo/redo operation"wxMessageBoxdowngraded towxLogWarning: dropped entries are routine in a collab session, and a blocking modal would hang the wasm modal pump.
wasm bindings
eeschema_embind.cpp/pcbnew_embind.cpp— all four remote-apply Push sites (doApply+doApplyItemsper editor) now push withSKIP_UNDO. Change detection is unaffected: emit suppression is keyed offs_applyingRemote, not undo entries.- Removed-item ownership: under
SKIP_UNDOno undo picker takes ownership of removed items (and the commit deletes the clone image), so the bindings free the detached items after Push — both the explicitremoved[]uuids and the upsert's remove-old-before-re-add. Fields are excluded (CHT_REMOVE hides them; they stay owned by their parent). Freeing stays in the binding layer, NOT the fork commit classes, because existingSKIP_UNDOcallers (DRC marker flows) manage their removed items' lifetimes themselves — freeing in the commit would double-free. - Test hooks
kicadCollabTestUndo(runsACTIONS::undoon the main-loop/fiber stack) andkicadCollabTestUndoDepth, registered per-editor and inkicad_editor_embind.cpp's dispatcher — the merged image compiles out the per-appEMSCRIPTEN_BINDINGSregistrations, so a shared-name hook that is not in the dispatcher silently vanishes from kicad_editor (build even forces the relink; it's the registration that's conditional).
Coverage — tests/kicad/collab-undo.spec.ts (5/5)
| Scenario | Editors |
|---|---|
| Remote apply adds no undo entry; undo reverts own op, peer's delete survives | eeschema + pcbnew |
| Stranded CHANGED entry (remote replaced the item) — undo re-anchors by uuid, no crash | eeschema |
| Stranded entry (remote deleted the item) — picker dropped quietly (log, not modal), no resurrect | eeschema + pcbnew |
Pre-fix, the stranded cases dereferenced freed memory (eeschema had no guard at all; pcbnew guarded existence but popped a blocking modal).
Accepted semantics (per doc 19)
- Undo restores the full item image → a peer's concurrent edit to another field of the same item is clobbered (LWW, converges; same trade-off as opt 14 granularity).
- Duplicate-KIID edge (local delete parked on undo + peer re-adds same uuid + undo) remains untested; the differ keys by uuid so it should reconcile — follow-up test.
- Pre-existing local entries that a big adopt strands are dropped on first undo.