Repository navigation
Description
Outcome
A module can draw its own content — a markdown fence or a file type — in the chat, the file viewer and every export path, through a build-time-bundled renderer seam that Mermaid also uses. On that seam, @schlessera/brain-module-diagrams turns a versioned ```diagram spec into editorial figures that look like brain-kit: drawn with --bk-* tokens, switching with the app's light/dark theme, printing on white, with diagram-design's connector rules guaranteed by computed geometry rather than checked afterwards. The module carries a written procedure for reviewing upstream diagram-design for new types and rule changes.
Why now
The maintainer asked for diagram-design's visual quality inside brain-kit with light, dark and print support, and ruled (2026-10-16) for the full module-renderer approach in one epic, with no file-based interim. The measurements in docs/decisions/module-renderers.md showed why the module-only route cannot deliver it:
- An
<img>-embedded SVG never sees@media print, so browser print keeps the screen palette. - WebKit (all iOS browsers) does not reliably theme an
<img>SVG (WebKit bug 199134 still NEW). - An image cannot use the app's fonts under the raw-file CSP.
Inline rendering by a trusted, bundled renderer removes all three problems. The seam also retires Mermaid's three special cases and gives #905 (maps) and #1609 (charts) a path.
Shared context
- Design and ordering: docs/plans/module-renderers.md. Why: docs/decisions/module-renderers.md. Read both before picking up any task.
- Upstream: https://github.com/cathrynlavery/diagram-design (MIT). Reviewed at commit
b46c970(plugin 2.6.107). It is an agent skill, not a renderer: about 9.5k lines of reference prose, 45 type grammars, six connector rules and about 6.2k lines of Python checkers. - Mermaid now uses the renderer seam: ui-react: Mermaid renders as a content-renderer pack and exports in the print theme #2084/CONTRACT: route Mermaid through content renderers and print tokens #2168 removes its fence/file special cases. Generic fence dispatch is (
MarkdownPre,packages/ui-react/src/components/chat/brain-markdown-code.tsx:17-25), file dispatch is (ViewerBody,packages/ui-react/src/components/files/file-viewer.tsx:89), and the retained public share helper delegates generic rendering (inlineMermaidDiagrams,packages/ui-react/src/lib/mermaid.ts:281). The built-in pack supplies its print contract. - Precedent for build-time packs: tool renderers (
export function registerToolRenderers,packages/ui-sdk/src/client/renderers.ts:171;Runtime plugin loading,packages/ui-react/src/components/chat/renderers/index.ts:3). - Module contributions are
.strict()and now declare package-owned renderer exports (export interface ModuleContribution,packages/core/src/lib/module-types.ts:147;ModuleRenderer, same file:133-138). docs/decisions/module-mcp-tools.md is the precedent for adding a contribution kind under the shared compatibility policy. - Tokens:
--bk-diagram-*(--bk-diagram-bg: light-dark,packages/ui-kit/src/tokens.css:810) and the generated print theme ([data-theme="print"] {,packages/ui-kit/src/tokens.css:898). - Example world: Odysseus only (docs/decisions/example-corpus.md). Upstream's example HTML is never vendored.
Constraints and non-goals
- Markdown stays the source of truth. The fence spec is the diagram; any SVG file is derived.
- Packs are registered by the build, never loaded at runtime from config. No renderer receives raw content markup to inject; renderers build elements from data.
- brain-kit's design system wins over upstream's skin (fonts, the 9px floor, no alpha ink, never colour alone). Upstream contributes the method.
- Theme contract: every pack implements
light,darkandprint. Every artifact leaving the screen usesprint(decision ruling 6). - Contract: the manifest key, the fence spec and new
--jsonshapes are contract additions withCONTRACT:commits. - Non-goals:
- automatic whole-diagram layout (dagre or elk)
- data-chart types that ui-kit's chart components cover
- upstream's import/export tooling, icons, sketchy and terminal variants, and animation
- a
show_blockkind
Breakdown
The sub-issue list carries the work. Its order is this stack plan, under docs/process/github.md § Stacked pull requests. A stack is a linear chain, so the dependency tree is cut into three stacks and some ordinary PRs. Each layer is one issue and one reviewable slice.
Stack plan
| Stack | Layers, bottom → top | Starts from |
|---|---|---|
| A: renderers | #2081 seam ← #2082 manifest ← #2083 registry ← #2084 Mermaid ← #2085 static path ← #2087 bundling | main |
| B: diagrams core | #2088 scaffold ← #2089 spec ← #2090 geometry ← #2093 skin | main, in parallel with A |
| C: diagrams render | #2094 renderer pack ← #2099 export | main, once A and B have landed |
- The design/skin prerequisites are delivered. ui-kit: design brief for a free-layout diagram in the brain-kit style (architecture) #2091's revised eight-node desktop/narrow/fallback compositions were explicitly adopted by the maintainer; ui-kit: design brief for an axis diagram in the brain-kit style (sequence) #2092 and modules: diagrams paint with generated brain-kit tokens in light, dark and print #2093 are complete. Preserve their approved direction. The separate common-callout treatment modules: accepted diagram callouts disappear from client and static figures #2242 is delivered by CONTRACT: render readable common diagram callouts #2346 under its adopted N1/N2/N3 and revision 2 R1=A/R2=B rulings, including the fixed-canvas inline compatibility exception.
- Ordinary PRs on
main:- ui-server: an .svg file previews as an image, and SVG images print light #2086 (
.svgimage fix): at any time. - modules: node-link diagram types (architecture, flowchart, state, tree, ER, dependency) #2095, modules: axis diagram types (sequence, swimlane, timeline, Gantt) #2096, modules: positional diagram types (quadrant, layers, pyramid, loop, Venn) #2097 (type families): in parallel once modules: the diagrams renderer pack draws inline, interactive, accessible figures #2094 lands. They do not depend on each other, so stacking them would invent dependencies.
- modules: the diagram skill teaches selection, taste and the fence #2098 (skill): after the three families.
- ui-server: an .svg file previews as an image, and SVG images print light #2086 (
- Other repositories: shell: bundle the configured modules' renderer packs into the PWA build brain-hosting-template#33 now waits on that repository's extraction feat: pi backend parity with the Claude backend #15; delivered registration ui-react: a deployment bundles module renderer packs and flags declared-but-unbundled fences #2087 and diagrams pack modules: the diagrams renderer pack draws inline, interactive, accessible figures #2094 do not create its missing host foundation. A stack cannot cross repositories.
- Delivered foundations and module: the approved record, renderer seam/manifest/registry, Mermaid migration, shared static print path and bundling (docs: record the module-renderer decision and the diagrams plan #2080/modules: rule on reproducing upstream's MIT notice, which names a person, against the no-real-names rule #2109, ui-sdk: define the content-renderer seam and its light/dark/print conformance suite #2081–modules: scaffold the diagrams module with upstream provenance and a sync procedure #2088) are delivered. The common spec/geometry/skin/client-static pack (modules: diagrams v1 fence spec and
brain diagram check#2089/modules: the diagram geometry builder enforces the connector rules by construction #2090/modules: diagrams paint with generated brain-kit tokens in light, dark and print #2093/modules: the diagrams renderer pack draws inline, interactive, accessible figures #2094), axis/positional/node-link families (modules: node-link diagram types (architecture, flowchart, state, tree, ER, dependency) #2095–modules: positional diagram types (quadrant, layers, pyramid, loop, Venn) #2097), and authoring skill (modules: the diagram skill teaches selection, taste and the fence #2098) are also delivered. Their native child receipts record immutable merge identities and source-qualified proof. The module now checks and renders shipped types. Common callouts are delivered by CONTRACT: render readable common diagram callouts #2346 /99c67ceca1537b0fc5c6e62eca854546c9e50195: full annotations, shared per-target keys, responsive notes bands, summary indices and the approved fixed-canvas compatibility behavior. modules:brain diagram exportandbuild, plus hygiene for external viewers #2099 is now delivered by CONTRACT: export diagrams and audit external-viewer pairs #2258 /61c73e2037ae17e9bfe0c1d8bb4722978b2a2fc3: SVG/optional PNG/PDF export, identified GFM light/dark pairs and ownership/freshness hygiene with embedded painted fonts. The full epic definition of done and the generated-host foundation remain open; modules: accepted diagram callouts disappear from client and static figures #2242 is complete. - Selection: Under process: decide how an issue that depends only on an open lower stack layer becomes selectable #2137 option A, a blocked upper layer is selectable only after every remaining open blocker is verified as an open, non-draft lower PR in this epic's declared stack with complete passing selected proof for its current parent/head candidate. Verify actual membership and the immediate parent before claiming and again before checkout creation; start from that verified head. Any genuine
needs:label, non-stack blocker or unavailable/failed/cancelled/unexpectedly skipped proof rejects selection. Preserve canonicalBlocked bylines andblockedfor open dependencies; a merged parent uses ordinary reconciliation and fetchedmain. Each layer owner refreshes their own layer bottom-up after parent changes, with explicit ownership handoff when absent. The stack merger verifies each included issue's delivered identities, acceptance/proof and release milestones and closes only completed issues. Native-stack candidate qualification remains separately subject to ci: native stacked PR events do not match contract and candidate identity guards #2141. Its October 22 ruling parked frozen-prefix verification/integrator work. Serial candidate confirmation is now used again, but ci: native stacked PR events do not match contract and candidate identity guards #2141 still awaits a concrete current native-stack use case; that workflow fact alone does not resume or qualify native integration. The earlier B/A policies remain binding if that separately scoped work resumes. The declared stack order is delivery history for the now-merged layers, not an instruction to revive the parked native verifier. Remaining work follows its own current brief; ordinary PRs retain their declared dependencies and reconstruct only their own diff after predecessors land. - Branches and proof: each layer issue names its branch and parent, and its verification runs
check:pr --base <parent-ref>.
Current remaining native work — 2026-11-03
Delivered on main: the renderer seam, Mermaid migration, static print path, bundling, the diagrams spec/geometry/skin/pack, the three type families, the skill and export (all listed above); the bounds and viewer-proof repairs #2228 (#2369) and #2241 (#2368); and #2402, grouped diagram capture within the WebKit case deadline (closed as completed 2026-10-30).
The #2469/#3367 parity-capture and #3397/#3410 frame/header deliveries are now ancestors of inspected main and their native issues are closed. Their former branch-only handoff is superseded. Remaining native work is #3405 (current browser-document pin audit) and schlessera/brain-hosting-template#33 (generated-host renderer bundling, with that repository's extraction prerequisite). Do not retain #3397 as an unresolved delivery prerequisite after verifying its output on main. Child closure does not establish all integrated chat/print and generated-host criteria below; keep this epic open without agent-ready.
Definition of done
- A
```diagramfence written by the agent in chat renders inline in light and dark, follows the theme toggle on Chromium and WebKit, and prints white from the browser and from share → PDF. Each is shown with a capture in the closing comment. - Mermaid renders identically through the seam, and its old special cases are deleted.
- Every first-party pack (Mermaid, diagrams) passes
contentRendererConformance, and a share → PDF holding both a Mermaid chart and a diagram shows one white ground. docs/modules.md,docs/extending/README.mdand the integration contract describe the seam, the manifest key and the spec.packages/module-diagrams/UPSTREAM.mdexists, and one dry-run review against upstream HEAD has been recorded in a PR.
2026-10-16: the breakdown became a stack plan (stacked PRs, #1997). #2109 was added for the licence ruling and #2137 for stack selection.
2026-10-16 triage at main 8822aedeeac8b824bafe120c20a9b58c4cd1f4e6: replaced unavailable main links with the inspected immutable #2102 proposal and updated the resolved-versus-undelivered stack-policy distinction. The content-renderer decision is proposed documentation awaiting merge, not shipped renderer capability; preserve the existing stack plan, native membership and full definition of done.
2026-10-16 triage at main 80e028d84b7686d6cf864d8166029b1142de8756: replaced proposal-only links with the delivered decision identity and folded verified foundation deliveries into the current breakdown. Existing Mermaid fallback special cases remain until #2084; generic dispatch does not complete their migration. Preserved design revisions/final sign-off, ordinary delivery fallback, stack dependencies and the complete definition of done. Recorded focused/native receipts are not a new independent full-main CI audit.
2026-10-16 delivery reconciliation: #2089 delivered the common v1 spec, check command and contract in #2167. The next Stack B layer #2090 uses fetched main; the remaining definition of done and declared dependencies are unchanged.
2026-10-16 triage at main 4ba792473152c89eb74c286fc914e54ca1dae8fc: reconciled the active specification with closed child outputs and merged source, replacing obsolete Mermaid special-case and pending-foundation statements. The approved design/skin/families/skill are delivered; dedicated exports, common callout treatment, generated-host foundation and complete integrated proof remain separate. Local/source-qualified receipts are not an independent full current hosted audit; preserve the original definition of done and epic-not-ready status.
2026-10-17 triage at main ecb87487d714956b0fcef520debe9dfa885b234f: folded the closed export/build child into the active delivery summary after reading its closure, immutable delivery and qualified artifact/font receipts. #2242 retains its newly documented crowded/semantic-only fallback design gap and approved N1/N2/N3 rulings; no annotation approval or complete epic outcome is inferred. Existing source-qualified proof is not a new independent hosted audit.
2026-10-22 native-output reconciliation: folded the two delivered bounds/viewer-proof repairs and current native open-child scope into the active brief. Original failure and qualification receipts retain their actual source identities; no new renderer runtime, generated-host result or epic-completion proof is claimed.
2026-10-24 continued triage at main dc5d3c73282c29a3f0098306d398743ee18ec791: Reconciled the active #2141 reference with its later parked-workflow ruling. All renderer/diagram deliveries and the remaining generated-host #33 and raster-attribution #2469 outcomes remain distinct. No native candidate support, stack action, new renderer proof or epic completion is claimed.
2026-11-02 source/prerequisite review at main a84d9bfbcb4e608b504aa0a9feb1144ad9a0b77e: Re-read the current #2141 workflow/use-case handoff and #2469’s later investigation-readiness correction. Reconciled those states in the active stack-selection and remaining-work paragraphs; the source-verified renderer/module owners, generated-host #33 after #15, exact-pixel requirements and full integrated definition of done remain. No native stack action, runtime/host proof, raster cause or epic readiness is claimed.
Triage 2026-11-03 (main 3d3516a02): replaced the 2026-10-22 remaining-work section: #2402 delivered; #2469 and #3397 merged into the epic integration branch awaiting a lane PR; #3405 attached and blocked on #3397; host #33 unchanged.
2026-11-04 triage at main 53b862123d7b8e4c9d039859fabdc9fc6ad4cd36: Refreshed the active named-source navigation after inspecting the current declarations; existing decisions, historical receipts, child prerequisites and readiness remain unchanged. No new runtime qualification or implementation is claimed.
2026-11-04 triage at main 53b862123d7b8e4c9d039859fabdc9fc6ad4cd36: Reconciled the closed renderer children against their merged PR identities and verified main ancestry; the remaining pin-audit and generated-host outcomes stay open. No new runtime qualification or implementation is claimed.
2026-11-05 triage at main 35217d283b849b5ef81700d5d4c2ec7486405d12: Refreshed the ModuleRenderer declaration pointer; native pin-audit and generated-host outcomes and the complete integrated definition of done remain open. Existing rulings, historical receipts and remaining qualification requirements are preserved; no runtime result or causal repair is claimed.
Triage 2026-11-08 at main 8752570331ffebdbb9233196412781f6cd71f3d9: Verified the moved active source anchors and refreshed navigation. Historical measurements and source-bound failure receipts keep their identities; existing scope, rulings, needs, priority, assignment and release attribution are preserved. This source review supplies no new runtime qualification or epic completion.
Activity
brain diagram check#208936 remaining items
schlessera commentedon Oct 22, 2026
2026-10-22 native-output reconciliation at a310317: #2228/#2369 and #2241/#2368 are merged, ancestral and present in current geometry/viewer proof. Updated the active brief to consume those delivered outputs and name the remaining native open work: hosting-template#33 after its #15 foundation, and #2469’s unreproduced raster-parity observation. The full integrated/host definition of done remains. No new runtime, historical hosted audit, child priority change or epic readiness is claimed.
schlessera commentedon Oct 24, 2026
2026-10-24 triage at main
dc5d3c73282c29a3f0098306d398743ee18ec791: Reconciled the active #2141 reference with its later parked-workflow ruling. All renderer/diagram deliveries and the remaining generated-host #33 and raster-attribution #2469 outcomes remain distinct. No native candidate support, stack action, new renderer proof or epic completion is claimed.schlessera commentedon Nov 3, 2026
Epic state — 2026-11-03
epic/2079-module-renderers, not yet on main: ui-react: diagrams-export free-layout raster parity fails intermittently on identical source #2469 (fix(ui-react): render diagram parity captures from full rasters only #3367) and module-diagrams: frame rendered diagrams like other content blocks, with open and share actions in the header #3397 (CONTRACT: feat(module-diagrams): frame rendered diagrams with header open and share actions #3410). No lane PR to main exists yet; both stay open until one lands.Next: a lane PR for the #2469/#3397 batch, then #3405. The definition of done (integrated chat/print captures, conformance, docs, upstream review) is not yet shown.
Merge pull request #3474 from schlessera/epic/2079-module-renderers
schlessera commentedon Nov 4, 2026
Epic state — 2026-11-04 (inspected main
53b862123d7b8e4c9d039859fabdc9fc6ad4cd36)The #2469/#3367 parity-capture and #3397/#3410 frame/header merges are verified ancestors of the inspected main, and their native issues are closed. Open: #3405’s browser-document pin audit and schlessera/brain-hosting-template#33’s generated-host bundling. The branch-only wait in the body is superseded; existing integrated rendering/print and generated-host completion requirements remain.
The epic remains outside
agent-ready; work continues through its native children.schlessera commentedon Nov 23, 2026
2026-11-23 0.45.0 release reconciliation: 28 of 30 tasks are delivered. The two remaining are schlessera/brain-hosting-template#33 (renderer-pack bundling, blocked by the hosting template's host foundation, schlessera/brain-hosting-template#15) and #3405 (p3 pin re-audit). Neither can or needs to ship in 0.45.0, so the 0.45.0 commitment is removed from the epic and from the template task. The epic stays open.
schlessera commentedon Nov 23, 2026
2026-11-23 triage at main
a3395c4b2(maintainer decision): loweredpriority: p1topriority: p2. Neither remaining task is on the 0.45.0 release path. schlessera/brain-hosting-template#33 is also p2 now, and #3405 stays p3.