openpencil/apps/web/src/stores
Fini 2aabe494f5 fix(core): design.md lives on PenDocument — kill cross-document leak
design.md was stored in a global Zustand store + per-file-key localStorage
in apps/web, and in a module-level cache in pen-mcp. Both leaked across
files: a newly-created document could pick up the previous file's dark
palette (async clearForNewDocument raced with AI chat reads; hydrate()
could rehydrate the last file's designMd on refresh; shared .pen files
lost the spec entirely because it wasn't inside the document).

Fix:
- Add `designMd?: DesignMdSpec` to PenDocument (pen-types). It now
  serializes with .pen/.op and travels across sessions/users.
- Add `setDesignMd` action to document-store.
- Rewrite design-md-store as a thin mirror over document-store so the
  legacy hook API still works. On document load it migrates any legacy
  localStorage entry into the opened document and deletes the localStorage
  key; hydrate() wipes the orphan `openpencil-design-md-current-key`.
- MCP handleGetDesignMd / handleSetDesignMd / handleExportDesignMd read
  `doc.designMd` directly and persist via saveDocument. Removed the
  process-level `_mcpDesignMd` cache.

Verified via MCP live round-trip: set on file A → persists to A's .op on
disk → new file B returns hasDesignMd:false (no leak).
2026-04-20 00:37:31 +08:00
..
__tests__ V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
agent-settings-store.ts V0.7.2-bugfix (#109) 2026-04-14 21:42:56 +08:00
ai-store.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
canvas-store.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
design-md-store.ts fix(core): design.md lives on PenDocument — kill cross-document leak 2026-04-20 00:37:31 +08:00
document-position-utils.test.ts V0.7.2-bugfix (#109) 2026-04-14 21:42:56 +08:00
document-position-utils.ts V0.7.2-bugfix (#109) 2026-04-14 21:42:56 +08:00
document-store-component-actions.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
document-store-node-actions.ts V0.7.2-bugfix (#109) 2026-04-14 21:42:56 +08:00
document-store-pages.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
document-store-variable-actions.ts V0.7.3 (#111) 2026-04-15 22:19:12 +08:00
document-store.ts fix(core): design.md lives on PenDocument — kill cross-document leak 2026-04-20 00:37:31 +08:00
document-tree-utils.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
git-store-helpers.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
git-store-types.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
git-store.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
history-store.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
theme-preset-store.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
uikit-store.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00