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:
@@ -31,6 +31,7 @@ import {
|
||||
verdictReasonSegments,
|
||||
outcomeColorToken,
|
||||
stateGlyph,
|
||||
looksLikeMarkdown,
|
||||
} from "../runDetail.js";
|
||||
import {
|
||||
ArtifactKind,
|
||||
@@ -261,8 +262,27 @@ function renderCodeBlock(label, text) {
|
||||
}
|
||||
|
||||
/** One stage-pane field as either the code card (blocks) or a key/value row. */
|
||||
/**
|
||||
* One recorded field value: a markdown body (the new stage turns) is rendered as
|
||||
* markdown; anything else stays an honest monospace block.
|
||||
*/
|
||||
function renderFieldValue(value) {
|
||||
const text = typeof value === "string" ? value : String(value ?? "");
|
||||
if (looksLikeMarkdown(text)) {
|
||||
return h("div", { class: "field-markdown" }, rt.views.chat.renderMarkdown(text));
|
||||
}
|
||||
return h("pre", { class: "field-block" }, h("code", { text }));
|
||||
}
|
||||
|
||||
function renderStageField(field) {
|
||||
if (field.block) return renderCodeBlock(field.label, field.value);
|
||||
if (field.block) {
|
||||
return h(
|
||||
"div",
|
||||
{ class: "codeblock" },
|
||||
h("div", { class: "codeblock-label", text: field.label }),
|
||||
renderFieldValue(field.value),
|
||||
);
|
||||
}
|
||||
return h(
|
||||
"div",
|
||||
{ class: "kv-row" },
|
||||
@@ -282,9 +302,7 @@ function renderRunFieldTab(map, keyPrefix, emptyMessage) {
|
||||
for (const section of sections) {
|
||||
const key = `${keyPrefix}-${section.key}`;
|
||||
wrap.append(
|
||||
renderCollapsible(key, section.title, () =>
|
||||
h("pre", { class: "field-block" }, h("code", { text: section.value })),
|
||||
),
|
||||
renderCollapsible(key, section.title, () => renderFieldValue(section.value)),
|
||||
);
|
||||
}
|
||||
return wrap;
|
||||
|
||||
Reference in New Issue
Block a user