web: render markdown stage bodies as prose

The turn protocol writes a markdown body; the run detail now renders a field as
markdown when it has markdown structure (heading, fence, list, table) and keeps
the honest monospace block for historical plain-text fields. Pure helper with
tests.
This commit is contained in:
2026-10-19 21:41:41 +01:00
parent 94c99f36bb
commit 6c0c813c2c
4 changed files with 52 additions and 4 deletions
+12
View File
@@ -8,6 +8,7 @@ import assert from "node:assert/strict";
import {
RUN_DETAIL_TABS,
looksLikeMarkdown,
RENDERED_RUN_TABS,
EMPTY_INPUT_MESSAGE,
EMPTY_OUTPUT_MESSAGE,
@@ -608,3 +609,14 @@ test("outcomeColorToken uses the status palette then the flow palette", () => {
assert.equal(stateGlyph("succeeded"), "✓");
assert.equal(stateGlyph("nonsense"), "?");
});
test("looksLikeMarkdown recognises stage bodies and leaves legacy maps alone", () => {
assert.equal(looksLikeMarkdown("# outcome\nsuccess\n\n# notes\nDone."), true);
assert.equal(looksLikeMarkdown("Some text\n\n- one\n- two"), true);
assert.equal(looksLikeMarkdown("```js\nconst a = 1;\n```"), true);
assert.equal(looksLikeMarkdown("| a | b |\n| --- | --- |\n| 1 | 2 |"), true);
// Historical field text is a plain map, not markdown.
assert.equal(looksLikeMarkdown("summary: ok\nfindings: none"), false);
assert.equal(looksLikeMarkdown(""), false);
assert.equal(looksLikeMarkdown(null), false);
});