import type {
QaBusAttachment,
QaBusMessage,
QaBusSnapshotConversation,
} from "openclaw/plugin-sdk/qa-channel-protocol";
import {
conversationSelectionKey,
findConversationBySelectionKey,
messageConversationSelectionKey,
threadConversationSelectionKey,
} from "./ui-conversation-key.js";
import { findScenarioOutcome } from "./ui-render-scenario.js";
import { badgeHtml, esc, formatIso, formatTime } from "./ui-render-utils.js";
import type { SeedScenario, UiState } from "./ui-types.js";
function attachmentSourceUrl(attachment: QaBusAttachment): string | null {
if (attachment.url?.trim()) {
return attachment.url;
}
if (attachment.contentBase64?.trim()) {
return `data:${attachment.mimeType};base64,${attachment.contentBase64}`;
}
return null;
}
function renderMessageAttachments(message: QaBusMessage): string {
const attachments = message.attachments ?? [];
if (attachments.length === 0) {
return "";
}
const items = attachments
.map((attachment) => {
const sourceUrl = attachmentSourceUrl(attachment);
const label = attachment.fileName || attachment.altText || attachment.mimeType;
if (attachment.kind === "image" && sourceUrl) {
return `
${esc(state.latestReport?.markdown ?? "Run the suite or self-check to generate a report.")}