Skip to content

Epic: modules render their own content, starting with brain-kit-styled diagrams that theme and print #2079

Open
28 of 30 issues completed

Description

@schlessera

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, dark and print. Every artifact leaving the screen uses print (decision ruling 6).
  • Contract: the manifest key, the fence spec and new --json shapes are contract additions with CONTRACT: 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_block kind

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

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 ```diagram fence 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.md and the integration contract describe the seam, the manifest key and the spec.
  • packages/module-diagrams/UPSTREAM.md exists, 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

  1. added
    type: feat
    area: modules
    priority: p1
    epic
    on Oct 16, 2026
  2. 36 remaining items

  3. schlessera commented on Oct 22, 2026

    @schlessera
    OwnerAuthor

    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.

  4. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    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.

  5. modified the milestones: 0.44.0, 0.45.0 on Oct 25, 2026
  6. schlessera commented on Nov 3, 2026

    @schlessera
    OwnerAuthor

    Epic state — 2026-11-03

    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.

  7. added a commit that references this issue on Nov 3, 2026
  8. schlessera commented on Nov 4, 2026

    @schlessera
    OwnerAuthor

    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.

  9. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    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.

  10. removed this from the 0.45.0 milestone on Nov 23, 2026
  11. added
    priority: p2
    and removed
    priority: p1
    on Nov 23, 2026
  12. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    2026-11-23 triage at main a3395c4b2 (maintainer decision): lowered priority: p1 to priority: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: modulesepicpriority: p2type: feat

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions