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:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user