openpencil/packages
Fini b191b35a3c fix(mcp): rollback re-syncs live canvas after restoring file
Codex stop-hook #6: saveDocument is DUAL-WRITE for file-backed paths
(document-manager.ts:411) — it writes to disk AND calls
pushLiveDocument. handleBatchDesign uses saveDocument so a bad insert
gets pushed to the live canvas before our post-check runs. Prior
rollback (6dfa88b) only restored the file via writeFile, leaving the
live-canvas renderer showing the bad insert until the next refresh.

Fix: after writeFile + invalidateCache, call saveDocument(fp, restoredDoc)
in the rollback path. saveDocument will re-write the file (no-op, same
content) AND call pushLiveDocument again with the restored doc,
bringing the live canvas back in sync with disk. If the live-sync step
fails, re-throw with a diagnostic noting the live canvas may be stale
but disk is authoritative.

Wrap the re-sync in try/catch so a transient live-sync failure doesn't
swallow the original insert-failure reason. Disk is the source of
truth and is already restored when we hit this path.

If no sync URL is configured (common in unit-test contexts),
pushLiveDocument is a no-op — so this is safe in all scenarios.

Live-canvas-only paths (filePath='live://canvas') remain
non-rollback-able because pushLiveDocument is a one-way push without
a history mechanism; the pre-check is the primary defense there.

88/88 pen-mcp tests pass (rollback behavior unchanged at the
observable-test level since our tests don't configure a live sync
URL; the re-sync is correct by construction given saveDocument's
published semantics). format + tsc green.
2026-04-19 18:33:12 +08:00
..
agent-native@e1f90cab96 chore(agent): bump agent-native to v0.4.0 release 2026-04-17 19:04:15 +08:00
pen-acp chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
pen-ai-skills fix(ai): overflow.md no longer advertises icon as required for nav chips 2026-04-19 17:16:10 +08:00
pen-core chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
pen-engine chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
pen-figma chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
pen-mcp fix(mcp): rollback re-syncs live canvas after restoring file 2026-04-19 18:33:12 +08:00
pen-react chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
pen-renderer chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
pen-sdk chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
pen-types chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
CLAUDE.md V0.7.0 (#95) 2026-04-11 23:25:13 +08:00