Persist SeeCode diagrams in shared documents #410
- MA
## What changed
- Save a bounded SeeCode JSON spec in a `seecode` code fence. The existing collaborative code node remains the editable source; each reader gets a derived diagram viewer with private inspection state. - Validate newly introduced or revised Planner diagrams before committing a document edit. Incomplete human source stays editable and shows a bounded error without affecting surrounding prose. - Give the Planner valid architecture, sequence, and state examples, including a prose-only choice. - Keep diagram node clicks, Reset, and keyboard activation in the reader's private viewer; the Show source control remains the deliberate path back to the shared spec.
## Real document preview
The browser test seeded this diagram in a saved PostgreSQL document. Two readers loaded it; the test edited its source, reloaded a reader, and checked that inspection stayed private. This screenshot is persistence evidence, not a model-authored example.

### Native-width browser check
A saved document seeded with the exact seven-node Astro spec from a directed Planner turn now keeps its 1204px SVG at native scale inside the diagram’s horizontal scroller. Node labels remain 12px at split and narrow widths. Keyboard scrolling reaches the far edge; the document and page do not overflow. The stored spec, geometry, and labels are unchanged. These screenshots are browser regression evidence, not new Planner runs.


Connection labels remain 8px at native scale. This change prevents further shrinking but does not establish a general label readability standard.
## Verification
- The prepared linear branch includes the native-width fix and its saved-document browser regression, plus interaction assertions carried from the newer remote branch. `bun test packages/diagrams` passed 18 tests; `bun run fix`, `bun run ci`, `bun run types`, and `bun run build` passed locally. Its browser regression will run in GitHub CI after publication. - 106 focused unit and domain tests passed on the persistence head. Eight focused PostgreSQL-backed Playwright tests passed on the previous branch head: three SeeCode document checks and five Mermaid diagram checks. - `bun run types`, `bun run build`, and `bun run ci` passed on the previous branch head `ca742d8d`. [Its CI run](https://github.com/githubnext/chopin/actions/runs/37819661208) passed validation, browser integration, and container build. Required checks will rerun on the final rebased head. - Earlier pre-merge local full `bun test`: 4,118 passed, 29 failed, 6 errors, 3 skipped. A focused unsandboxed base comparison found the same five-second timeout in `registered Planner sessions load operator resources and offer only read-only Atomic tools beside host tools` on both unchanged `origin/main` and this branch (17 passed, 1 failed each). The remaining full-suite failures are not classified; this PR's focused tests passed.
## Live Planner assessment
`gpt-6-luna` through the Copilot SDK used real `read_plan` and `edit_plan` tools against three frozen public development checkpoints. Each edit was accepted and survived close/reopen. The service did not expose an underlying model version or usable cost/token totals.
| Checkpoint | Cutoff (UTC) | Saved result | Latency | | --- | --- | --- | ---: | | `astro-production-deps/c2` | 2023-08-15 21:36:04 | grounded prose, no diagram | 14.9 s | | `vite-bundled-dev-hmr/c2` | 2026-07-30 10:06:03 | grounded prose, no diagram | 12.6 s | | `biome-fix-all/c1` | 2024-07-02 20:38:00 | grounded prose, no diagram | 8.3 s |
Astro and Vite were candidate diagram cases; neither produced one (**0/2**). Biome was the deliberate no-diagram control, where prose was a reasonable choice (**1/1**). The open-ended prompts did not require a diagram, and no invalid spec was attempted, but **the live Planner authoring smoke did not demonstrate diagram insertion**. This PR establishes the saved edit and viewing mechanism; separate selection work owns when the Planner chooses a diagram. The bounded assessment runner is reproducible with a frozen development registry and an existing `gh auth` session:
```bash bun apps/server/src/testing/seecode-assessment.ts /path/to/development/registry.json /tmp/seecode-assessment.json ```
MaggieAppletonauto-rebase-enabledlast month on GitHub
MaggieAppletonhead-ref-force-pushed eb9172dd45f8last month on GitHub
MaggieAppletonreferenced this in Route Planner visual authoring through Jev #415last month on GitHub
MaggieAppletonhead-ref-force-pushed 0cbfd1eb473clast month on GitHub
MaggieAppletonmerged 7d7d20142ef2last month on GitHub
MaggieAppletonhead-ref-deletedlast month on GitHub