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:
@@ -592,6 +592,18 @@ export function clampVisitIndex(index, count) {
|
||||
* artifacts section always shows for a reached visit. Mirrors
|
||||
* `stageSectionSpecs`.
|
||||
*/
|
||||
/**
|
||||
* Whether a recorded field value is markdown rather than plain text: a heading, a
|
||||
* fenced block, a bullet/ordered list or a table. The new stage turns write
|
||||
* markdown bodies (`# outcome` …), while historical steps store plain maps; this
|
||||
* keeps the old ones rendering as code.
|
||||
*/
|
||||
export function looksLikeMarkdown(value) {
|
||||
const text = typeof value === "string" ? value : "";
|
||||
if (!text) return false;
|
||||
return /^#{1,6}\s/m.test(text) || /```/.test(text) || /^\s*(?:[-*]|\d+\.)\s+/m.test(text) || /^\|.+\|/m.test(text);
|
||||
}
|
||||
|
||||
export function stageSectionSpecs(stageKey, graph, runSteps, visitIndex, runContext) {
|
||||
const specs = [];
|
||||
const stage = (graph?.stages ?? []).find((candidate) => candidate?.key === stageKey);
|
||||
|
||||
Reference in New Issue
Block a user