Skip to content

Feat/custom component#57

Merged
gitsad merged 12 commits into
mainfrom
feat/custom-component
Jul 21, 2026
Merged

Feat/custom component#57
gitsad merged 12 commits into
mainfrom
feat/custom-component

Conversation

@gitsad

@gitsad gitsad commented Jul 21, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Adds the custom component type — a host-extensible escape hatch for components the built-in types
don't cover. Rather than a new type name per component, it's a stable envelope: name selects a
variant the host registered, props carries its inputs, actions wires its events. The spec stays
intent-level; all rendering lives in the host.

The key difference from the existing custom-type path (type: timer + customSchemas) is that the
envelope is LLM-authorable. A model can't invent type: timer — it isn't in the spec any prompt
teaches — but it can emit type: custom with name: timer once the variant appears in the catalog
the host passes to buildSystemPrompt({ customComponents }). Both paths share the same
customSchemas map, so a schema written for one is reusable by the other.

Also fixes a latent bug found along the way: the markdown pipeline was missing remark-gfm, so the
GFM tables models routinely emit next to charts silently degraded into run-on pipe text.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing behavior to change)
  • Refactor (no functional change)
  • Documentation
  • CI / tooling

Additive only — existing documents parse identically.

Packages Affected

  • @mobile-reality/mdma-spec
  • @mobile-reality/mdma-parser
  • @mobile-reality/mdma-runtime
  • @mobile-reality/mdma-attachables-core
  • @mobile-reality/mdma-renderer-react
  • @mobile-reality/mdma-prompt-pack
  • Blueprint: ___________

Also touched (no version bump — tests/docs only): mdma-mcp, mdma-validator, demo, evals.

Checklist

  • I have read the CONTRIBUTING guide.
  • My code follows the existing code style (pnpm format and pnpm lint pass).
  • I have added or updated tests that cover my changes.
  • All tests pass (pnpm test) — 24/24 tasks.
  • Type-checking passes (pnpm typecheck) — 22/22 tasks.
  • I have added a changeset (pnpm changeset) — minor for the five packages above.
  • New or changed MDMA schemas are backwards-compatible.
  • Sensitive fields are marked with sensitive: true where appropriate — N/A, no new fields.

How to Test

  1. pnpm install && pnpm test && pnpm typecheck — all green.
  2. Envelope + per-name props validation: pnpm --filter @mobile-reality/mdma-parser test.
    Covers a registered name (props validated, errors prefixed props.*) and an unregistered one
    (passes through rather than failing the parse, so a document authored against a richer host still
    renders elsewhere).
  3. 3D showcase: pnpm --filter @mobile-reality/mdma-demo dev → Docs → Components → custom.
    A WebGL 3D bar chart rendered through the envelope via three.js; drag to orbit, click a bar and
    confirm the selection lands in the action log.
  4. Agent authoring it end-to-end: demo → Agent Chat → ▶ auto-play. The scripted run now closes on
    pls generate sample 3D graph; the agent should emit a type: custom / name: graph-3d block
    with its onSelect action wired.
  5. Evals (needs API keys): pnpm --filter @mobile-reality/mdma-evals eval (33 cases incl. 5
    custom scenarios), eval:fixer (16), eval:guidance-coexistence (8).

Screenshots / Examples

type: custom
id: revenue-3d
name: graph-3d
label: "Revenue by Region and Quarter"
props:
  title: "Quarterly Revenue (3D)"
  bars:
    - { x: "EMEA", z: "Q1", y: 42 }
    - { x: "EMEA", z: "Q2", y: 58 }
actions:
  onSelect: bar-selected
Zrzut ekranu 2026-07-21 o 16 46 09

@gitsad
gitsad merged commit 3218c27 into main Jul 21, 2026
1 check passed
@gitsad
gitsad deleted the feat/custom-component branch July 21, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants