# C2-markdown-wire — assistant markdown in the thread and artifact viewer Wires the landed chat markdown renderer into the two call sites it was built for. No parser, inline/block model, chat domain, application route/shell, run, pipeline, graph or schedule file changed. The candidate is uncommitted: no commit, push, merge or deployment was performed. ## Behavior - `ChatThreadView` passes `chatMarkdownText` as `ChatMessageView.textBuilder`. Stored history and live `chat_event` text frames therefore render the supported subset: headings, paragraphs, bullet/ordered lists, tables, fenced code with its language label, inline code, bold/italic, safe/unsafe links and literal HTML. Assistant prose is parsed into native blocks; the raw markers do not reach the screen. - User rows are untouched: they remain the server's exact plain text, including any `**`, `[label](target)`, `` or other markdown-looking characters. The transcript test asserts the exact string and the absence of the parsed form. - Reasoning and tool disclosures are untouched and stay plain text. - `ArtifactGalleryPage` now defaults its `markdownBuilder` to the same `chatMarkdownText`. The public `ArtifactMarkdownBuilder` seam gained the build context (`Widget Function(BuildContext, String)`) so the themed renderer can be injected without a `Builder` shim; `ArtifactPreviewBody` passes its own context and `ArtifactViewerPage`'s standalone default remains plain selectable text. - `.md`/`.markdown` names and `text/markdown` records already classify as the viewer's markdown kind; both now render through the chat renderer while the recorded name/MIME/size, visit facts, paging and external Open/Copy actions stay unchanged. - Unsafe links (`javascript:`, etc.) render as their label with no recognizer or underline. No host link opener was added, so a safe link is also inert: the renderer only underlines links when a caller supplies `onOpenLink`, and this slice did not add an external-open capability to chat. ## Files | Path | Change | Role | | --- | ---: | --- | | `lib/features/chat/conversation/chat_thread_view.dart` | +9/−1 | Pass the markdown builder into each `ChatMessageView` | | `lib/features/artifacts/ui/artifact_gallery_page.dart` | +4/−2 | Default markdown builder is `chatMarkdownText`; docs | | `lib/features/artifacts/ui/artifact_viewer_content.dart` | +8/−6 | Context-aware builder seam; pass context at the markdown kind | | `test/features/chat/conversation/chat_thread_view_test.dart` | +174 | History/live/exact-user/labels/Cupertino 320px tests | | `test/features/artifacts/ui/artifact_viewer_page_test.dart` | +115/−3 | Gallery→viewer markdown wiring, extension-only MIME, 320px Cupertino | | `tool/chat_markdown_wire_probe.dart` | new, 123 | Material/Cupertino real-app fixture (ChatScreen) | | `tool/chat_markdown_wire_probe.mjs` | new, 353 | Chrome CDP capture, OCR and semantics assertions | | `notes/C2-markdown-wire.md` | new | This note | ## Regression coverage Chat thread (`test/features/chat/conversation/chat_thread_view_test.dart`): - Assistant history with `##` heading, bullet list, a `dart` fence and an inline-code/HTML/unsafe-link paragraph renders as blocks on Material and Cupertino; `dart` and the verbatim code text are present; raw `##`, fences and the link target are absent; the HTML stays literal; only the user row keeps `javascript:alert`. - The user row keeps `Keep **these** characters [as-is](javascript:alert) literal.` exactly; the parsed equivalent is absent. - A live text frame (`### Live answer`, ordered list, inline code) renders formatted markdown and keeps the running line. - No `Material` widget is introduced under the Cupertino host. - A formatted answer with heading, table and code renders at 320 logical px, DPR 2, 2x text, dark Cupertino with no exception and native controls only. Artifact viewer (`test/features/artifacts/ui/artifact_viewer_page_test.dart`): - Tapping a `text/markdown` row in the real `ArtifactGalleryPage` opens `ArtifactViewerPage`, which draws `ChatMarkdownView` with the heading, table, `dart` label and code; raw `# Report` is absent; `1 of 1 · text/markdown`, `text/markdown · 4.0 KiB` and `review · visit 1` remain visible. - A `.markdown` name without a recorded MIME uses the same renderer and reports `type not recorded`. - The same path at 320 logical px, DPR 2, 2x text in dark Cupertino raises no exception and contains no `Material` widget. - Existing injected-builder/text-default/paging/external/unsupported tests were updated only for the new builder signature. ## Checks (actual) - `flutter test` — **953 tests passed**. - `flutter test test/features/chat test/features/artifacts test/application` — **279 tests passed**. - `flutter analyze` — **No issues found**. - `dart format --output=none --set-exit-if-changed` on the six changed/new Dart files — exit 0 (0 changed at the final check). - `node --check tool/chat_markdown_wire_probe.mjs` — exit 0. - `flutter build web` (`lib/main.dart`) — built successfully. - `flutter build web -t tool/chat_markdown_wire_probe.dart` with `CHAT_MARKDOWN_WIRE_PROBE_STYLE=material` and `=cupertino` — both built. - Browser probes, real headless Chrome, 390x844 at DPR 2, dark appearance, isolated loopback OS-assigned ports: - Material and Cupertino both opened the real `/chat` list, selected `Markdown wire`, found `User message`, `Assistant message` and `Reasoning`, captured the thread, OCR-confirmed `Quarterly status`, `release`, `review pending`, `dart`, `count = 3`, `unsafe stay visible` and the exact user string `Keep **this** exactly`, and confirmed the raw markers `## Quarterly`, `` ```dart ``, `| --- |`, `**release**` and `unsafe](javascript` were absent. - The semantics tree exposed the formatted heading at level 2 in both hosts. - Both runs exited 0 and wrote evidence JSON. ## Browser evidence `/Users/alan/.local/share/pipelines/data/artifacts/91/public/c2-markdown-wire/` - `material-markdown-thread.png`, `material-evidence.json` - `cupertino-markdown-thread.png`, `cupertino-evidence.json` SHA-256: ``` e9813cee1a69487a42025df4079dbafb05322070363f0d22eaccbc67fe45f390 material-markdown-thread.png 3726583850d74693fadb1aa8ddd8d2f2e6f8d49a28c8f661f49012e9c46fe5ec cupertino-markdown-thread.png ``` Both captures show the exact user characters, collapsed `Reasoning`, the formatted `Quarterly status` heading, bold `release`, inline-code fill on `gateway`, both list items, the table with a distinct header, the `dart` code label with verbatim code, literal `markup`, and the inert `unsafe` label inside the real Chat destination. The Cupertino capture is the dark native layout with its own bar, buttons and grouped list styling. ## Not done / unverified - No browser capture of the artifact viewer markdown path was taken; that wiring is covered by the widget tests above. The only requested per-host browser capture (a formatted assistant answer) is present. - Safe links are not activatable in chat or the viewer; the renderer's `onOpenLink` is unset because no host link-opening capability exists yet. - Mobile/Android/iOS/macOS builds and device behavior were not run or verified; this is web-only evidence. - `PARITY.md` was not edited; its Chat message surfaces and Artifact preview rows still need the manager's integrated update. ## Manager completion after a server persistence failure The run ended with the server's duplicate step-evidence bug (since fixed and deployed). The retained call-site changes are complete: 234 chat/artifacts tests pass. Manager merged them directly. The artifact viewer now takes a context-aware markdown builder so it can render themed markdown, and the gallery passes the same renderer the chat uses, keeping the standalone default honest.