feat(viewer): artifact modal renders structured text, never raw JSON

ArtifactView's fallback (StructuredValue) turns any object/array into labelled
sections, bullet lists and paragraphs (strings as markdown). Verified against the
real F1 gate (kind:"text", {recap, chiarimenti_risolti[], ...}). MarkdownView
uses the real .thot-prose class (Tailwind Typography is not installed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 18:15:48 +02:00
co-authored by Claude Opus 4.8
parent cec6620c00
commit a719ad5990
3 changed files with 66 additions and 8 deletions
+17 -3
View File
@@ -26,9 +26,23 @@ test("question renders markdown headings", () => {
expect(screen.getByText("Domanda")).toBeInTheDocument();
});
test("unknown kind falls back to formatted JSON", () => {
render(<ArtifactView artifact={{ kind: "mystery", data: { a: 1 } }} />);
expect(screen.getByText(/"a": 1/)).toBeInTheDocument();
test("unknown object kind renders as formatted sections, never raw JSON", () => {
render(
<ArtifactView
artifact={{
kind: "phase",
data: {
recap: "Domanda: lista pazienti.",
chiarimenti_risolti: ["finestra_temporale — 5 anni", "tipo_evento — solo impianto"],
},
}}
/>,
);
// Humanized section labels, values as text/bullets — and NO raw JSON braces.
expect(screen.getByText("Recap")).toBeInTheDocument();
expect(screen.getByText("Chiarimenti risolti")).toBeInTheDocument();
expect(screen.getByText("finestra_temporale — 5 anni")).toBeInTheDocument();
expect(screen.queryByText(/"recap"/)).not.toBeInTheDocument();
});
test("schema_linking renders the schema viewer", async () => {