feat(markdown): agent-authored widgets, read-only (AGENT-WIDGETS-001 PR-1) - #17
Merged
Merged
Conversation
…GETS-001 PR-1) Agents publish structured JSON in a `buzz-widget` fence; the client owns the rendering via allowlisted React components. Ships `table` and `metric`. No HTML path: raw HTML stays inert (no rehypeRaw, CSP forbids it), and payload strings render as escaped text through JSX. Widget type lives in the JSON, not the fence info string, because extractLanguage keeps only the first info-string token. Unknown types, bad JSON, and oversized payloads degrade to a plain code block so content stays readable on old clients and other surfaces. Tests: 24 new (schema, fence-text recovery, end-to-end render incl. XSS- as-data and prototype pollution). typecheck + biome clean. Pre-existing unrelated failure on product/main: useKnownAgentPubkeys provenance test (verified failing with this work stashed).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The desktop file-size ratchet forbids growing an already-oversized file; markdown.tsx was 1862 lines at base and the widget dispatch pushed it to 1871. Move the fence-dispatch rule into markdown/widgets/MarkdownFence.tsx beside the widget code it belongs to, leaving markdown.tsx one line SMALLER than base. Behavior is unchanged: widget fences render WidgetView, invalid payloads and all other languages fall through to MarkdownCodeBlock.
biome lint/style/useImportType: the module uses React only for the ReactNode type. Matches the convention in AppHuddleBar.tsx and SidebarSection.tsx.
This was referenced Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agents publish structured JSON; the client owns the rendering. First half of
AGENT-WIDGETS-001 — read-only widgets, no interaction yet.
Spec:
~/buzz-program/specs/AGENT-WIDGETS-001-plan.mdFormat
Widget type lives inside the JSON, not the fence info string:
extractLanguage(
CodeBlock.tsx:49) matches/language-(\S+)/and keeps only the first token, so afence of
buzz-widget metricwould arrive aslanguage-buzz-widgetwithmetricsilently dropped. Found by probing the real renderer while writing the spec.
Why not HTML
Raw HTML is already inert — no
rehypeRaw, and the Tauri CSP forbids it(
object-src 'none',frame-ancestors 'none', nounsafe-eval). That is thecorrect posture for a federated app where agent content arrives from machines the
user does not control, so this PR keeps it and never introduces an HTML path.
Values render as text through JSX; no
dangerouslySetInnerHTMLanywhere.Degradation
Unknown type, malformed JSON, or an oversized payload (>32KB) falls back to a plain
code block. Content stays readable on older clients and non-desktop surfaces rather
than rendering blank.
Changes
widgets/schema.ts— validation + client-side type allowlist (table,metric)widgets/fenceText.ts— recover exact fence text from fragmented React childrenwidgets/WidgetView.tsx— renderers matchingMarkdownTablestylingmarkdown.tsx— dispatch in the existingprehandler (single insertion point)Verification
and end-to-end render through the real
react-markdownpipeline<img onerror>and<script>render escaped, and
__proto__in a payload does not pollute the prototypepnpm run checkexit 0;pnpm typecheckclean; biome cleanPre-existing failure, not from this PR: the
useKnownAgentPubkeysprovenancetest fails on
product/maintoo — verified by re-running it with this work stashed.Review notes
noArrayIndexKeyis suppressed in 4 spots with justifications: agent-suppliedrows/cells carry no stable identity. Follows the existing repo convention
(
CustomHarnessForm.tsx,TeamSnapshotImportDialog.tsx).Next (PR-2)
Interaction: widget actions emit
KIND_AGENT_OBSERVER_FRAME(24200) back to theagent, which already subscribes via
subscribe_observer_controls. Addskanbanand
checklist. No new transport needed.