Render Mermaid diagrams and worktree images in agent Markdown
This commit is contained in:
Vendored
+7
-6
@@ -1,7 +1,8 @@
|
||||
import { post } from "./api.js";
|
||||
import { mountChanges } from "./changes.js";
|
||||
import { ago, errorText, h, replace, showAlert } from "./dom.js";
|
||||
import { inlineMarkdown, markdown } from "./markdown.js";
|
||||
import { image, inlineMarkdown, markdown } from "./markdown.js";
|
||||
import { diagram } from "./mermaid.js";
|
||||
import { findTask, onEach, state } from "./state.js";
|
||||
const checked = new Map();
|
||||
const texts = new Map();
|
||||
@@ -277,10 +278,10 @@ function card(item) {
|
||||
};
|
||||
switch (item.kind) {
|
||||
case "question":
|
||||
replace(body, markdown(String(p["context"]), "md context", choice), markdown(String(p["question"]), "md question"), h("p", { class: "why" }, h("strong", {}, "Blocked on: "), inlineMarkdown(String(p["why_blocked"]))), attachments(p["attachments"] ?? []));
|
||||
replace(body, markdown(String(p["context"]), "md context", { choice, taskId: item.task_id }), markdown(String(p["question"]), "md question", { taskId: item.task_id }), h("p", { class: "why" }, h("strong", {}, "Blocked on: "), inlineMarkdown(String(p["why_blocked"]), { taskId: item.task_id })), attachments(p["attachments"] ?? [], item.task_id));
|
||||
break;
|
||||
case "report":
|
||||
replace(body, markdown(String(p["text"] ?? ""), "md summary"));
|
||||
replace(body, markdown(String(p["text"] ?? ""), "md summary", { taskId: item.task_id }));
|
||||
break;
|
||||
case "session_error":
|
||||
replace(body, h("p", { class: "error-text" }, String(p["error"])));
|
||||
@@ -301,7 +302,7 @@ function thread(item) {
|
||||
}
|
||||
return h("ul", { class: "thread" }, ...item.responses.map((r) => h("li", {}, h("strong", {}, r.user), ` ${r.type.replace("_", " ")}`, r.options ? `: ${r.options.join("; ")}` : "", r.text ? ` — ${r.text}` : "")));
|
||||
}
|
||||
function attachments(list) {
|
||||
function attachments(list, taskId) {
|
||||
if (list.length === 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -315,9 +316,9 @@ function attachments(list) {
|
||||
case "diff":
|
||||
return h("li", {}, "diff ", h("code", {}, a.ref ?? ""), caption);
|
||||
case "image":
|
||||
return h("li", {}, a.image?.startsWith("data:image/") ? h("img", { src: a.image, alt: a.caption ?? "" }) : null, caption);
|
||||
return h("li", {}, a.image || a.path ? image(a.image || a.path, a.caption ?? "", taskId) : null, caption);
|
||||
case "diagram":
|
||||
return h("li", {}, h("pre", { class: "mermaid-source" }, a.mermaid ?? ""), caption);
|
||||
return h("li", {}, diagram(a.mermaid ?? ""), caption);
|
||||
case "task":
|
||||
return h("li", {}, h("a", { href: `#/task/${a.task_id}` }, "task ", a.task_id ?? ""), caption);
|
||||
case "snapshot":
|
||||
|
||||
Reference in New Issue
Block a user