From 2a8a5bf334dc32469cdc6aaa2931d54f7f703792 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Tue, 20 Oct 2026 01:15:09 +0100 Subject: [PATCH] web: show the turn files in the audit, with raw and rendered views - The audit Input/Output/Memory tabs fetch the actual input.md/output.md/ memory.md, so the outcome section is visible and each document has a Rendered/Raw switch plus an Open raw file link. The Session tab renders the exported HTML in place with the same link. - The audit's selected tab uses the normal selected surface, not the accent tint. - The run Summary no longer carries an Audit & debug section; the stage pane's Audit & debug button is the one door. - Search results all lead with one 56px tile: image thumbnails, artifact type tiles, or a kind glyph (pipeline/version/run/step/field); no text kind labels. - Chat star and more sit on the row's top-right and bottom-right corners, revealed on hover/focus, and the row menu opens below them without losing clicks. - The chat spinner starts at the wall-clock animation phase, so frequent streaming re-renders no longer snap it back to the animation start. --- web/chat.css | 52 ++++++++---- web/dialogs.css | 41 ++++++++- web/src/views/chat.js | 7 +- web/src/views/runDetail.js | 166 ++++++++++++++++++++++--------------- web/src/views/search.js | 54 +++++++++++- 5 files changed, 232 insertions(+), 88 deletions(-) diff --git a/web/chat.css b/web/chat.css index a33c53b0..819e8195 100644 --- a/web/chat.css +++ b/web/chat.css @@ -138,40 +138,56 @@ .chat-row .row-title { min-width: 0; } .chat-row .row-meta { grid-column: 1; } .chat-row-model { font-size: 11px; } -/* Star + actions live in a hover/focus overlay, so the title uses the row's full - width instead of losing a permanent column on the right. */ +/* Star (top-right) and the more menu (bottom-right) sit over the row's own + corners on hover/focus, so they never become an extra row or reserve width. */ .chat-row-actions { position: absolute; - top: 50%; - right: 8px; - transform: translateY(-50%); - display: flex; - align-items: center; - gap: 2px; - padding: 2px; - border-radius: var(--radius-control); - background: var(--color-surface); - box-shadow: 0 0 0 1px var(--color-divider); + inset: 0; opacity: 0; pointer-events: none; transition: opacity 100ms ease-out; } +.chat-row-actions > .chat-star, +.chat-row-actions > .chat-menu-button, +.chat-row-actions > .chat-menu-panel { pointer-events: auto; } .chat-row:hover .chat-row-actions, .chat-row:focus-within .chat-row-actions, -.chat-row.menu-open .chat-row-actions { - opacity: 1; - pointer-events: auto; -} +.chat-row.menu-open .chat-row-actions { opacity: 1; } + /* An open menu paints above the rows below it, not under their content. */ .chat-row.menu-open { z-index: 30; } @media (hover: none) { - .chat-row-actions { position: static; transform: none; opacity: 1; pointer-events: auto; background: transparent; box-shadow: none; margin-top: 4px; } + .chat-row-actions { opacity: 1; } + .chat-row-actions > .chat-star, + .chat-row-actions > .chat-menu-button, + .chat-row-actions > .chat-menu-panel { pointer-events: auto; } } .chat-row-actions button { padding: 3px 10px; font-size: 12px; } /* The local star: outline when unstarred, filled and accented when starred. */ -.chat-star { min-width: 28px; padding: 3px 6px; color: var(--muted); font-size: 15px; line-height: 1; } +.chat-star { + position: absolute; + top: 6px; + right: 8px; + min-width: 26px; + padding: 2px 5px; + border-radius: var(--radius-control); + background: var(--color-surface); + color: var(--muted); + font-size: 15px; + line-height: 1; +} .chat-star:hover { color: var(--color-text); } .chat-star.starred { color: var(--color-accent); } +.chat-row .chat-menu-button { + position: absolute; + right: 8px; + bottom: 6px; + background: var(--color-surface); + border-radius: var(--radius-control); +} +/* The row menu opens below the bottom-right button; the open row stacks above + its neighbours so the panel is not covered by the next row. */ +.chat-row .chat-menu-panel { top: calc(100% + 4px); bottom: auto; right: 8px; } .chat-menu-wrap { position: relative; } .chat-menu-button { min-width: 30px; font-size: 15px; line-height: 1; } .chat-menu-panel { diff --git a/web/dialogs.css b/web/dialogs.css index 732abf1b..a6bfe631 100644 --- a/web/dialogs.css +++ b/web/dialogs.css @@ -306,7 +306,8 @@ .search-kind { flex: 0 0 auto; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; } /* An artifact result shows the artifact: a real thumbnail for an image, a type tile for everything else, so "artifact" never stands in for the content. */ -.search-row-artifact { align-items: center; } +.search-row-artifact, +.search-row-with-icon { align-items: center; } .search-thumb { flex: 0 0 auto; width: 56px; @@ -320,6 +321,7 @@ flex: 0 0 auto; width: 56px; height: 56px; + color: var(--color-muted); display: inline-flex; align-items: center; justify-content: center; @@ -330,6 +332,7 @@ font-size: 10px; letter-spacing: 0.04em; } +.search-type svg { width: 22px; height: 22px; } .search-open-run { margin-top: 4px; padding: 2px 8px; @@ -608,7 +611,7 @@ } .audit-tab:hover { background: var(--tint-hover); color: var(--color-text); } .audit-tab.active { - background: var(--tint-selected); + background: var(--color-bg); color: var(--color-text); font-weight: var(--weight-semibold); box-shadow: inset 2px 0 0 var(--color-accent); @@ -626,3 +629,37 @@ } .audit-tab { white-space: nowrap; } } + + +/* Audit documents: rendered/raw switch, the file link, and the session frame. */ +.audit-doc-bar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 10px; + margin-bottom: 10px; +} +.audit-doc-toggle { + display: inline-flex; + border: 1px solid var(--border); + border-radius: var(--radius-control); + overflow: hidden; +} +.audit-doc-mode { + padding: 4px 10px; + border: 0; + background: transparent; + color: var(--muted); + font-size: 12px; +} +.audit-doc-mode:hover { background: var(--tint-hover); color: var(--color-text); } +.audit-doc-mode.active { background: var(--color-bg); color: var(--color-text); font-weight: 600; } +.audit-doc-open { color: var(--color-accent); font-size: 12px; } +.audit-doc-body { min-height: 0; } +.audit-session-frame { + width: 100%; + height: min(70vh, 720px); + border: 1px solid var(--border); + border-radius: var(--radius-card); + background: var(--color-bg); +} diff --git a/web/src/views/chat.js b/web/src/views/chat.js index 49c7dd33..a37a3012 100644 --- a/web/src/views/chat.js +++ b/web/src/views/chat.js @@ -2340,7 +2340,12 @@ function approvalControl(label, decision, sessionId, requestId, extraClass = "") function renderChatRunningIndicator(thread, now) { const wrap = h("div", { class: "chat-running", id: "chatRunning" }); const head = h("div", { class: "chat-running-head" }); - head.append(h("span", { class: "spinner chat-running-spinner", "aria-hidden": "true" })); + const spinner = h("span", { class: "spinner chat-running-spinner", "aria-hidden": "true" }); + // Every streamed delta re-renders the transcript, so a fresh spinner would + // restart its CSS rotation at 0deg many times a second and look frozen. Start + // it at the wall-clock phase instead, so re-renders continue the same turn. + spinner.style.animationDelay = `-${(performance.now() % 800) / 1000}s`; + head.append(spinner); head.append( h("span", { class: "chat-running-label", diff --git a/web/src/views/runDetail.js b/web/src/views/runDetail.js index 36d3e9f4..922e4d8c 100644 --- a/web/src/views/runDetail.js +++ b/web/src/views/runDetail.js @@ -209,93 +209,131 @@ function latestVisitIndex(d, key) { return Math.max(0, visits.length - 1); } -/** The summary's Audit & debug section: one audit door per visit. */ -function renderRunAuditSection(d) { - return renderCollapsible("summary-audit", "Audit & debug", () => { - const timeline = runTimeline(d.steps ?? []); - const body = h("div", { class: "audit-list" }); - if (!timeline.entries.length) { - body.append(h("div", { class: "muted", text: EMPTY_TIMELINE_MESSAGE })); - return body; - } - for (const entry of timeline.entries) { - const used = systemArtifacts(entry.step).length; - const row = h("div", { class: "audit-row" }); - row.append( - h("span", { - class: "audit-row-label", - text: `${entry.stageKey} · visit ${entry.visitIndex + 1}`, - }), - h("span", { class: "audit-row-meta muted", text: `${used} system file${used === 1 ? "" : "s"}` }), - ); - const open = h("button", { - class: "ghost audit-open", - type: "button", - text: "Audit", - }); - open.addEventListener("click", () => openAuditFor(d, entry.step, entry.stageKey, entry.visitIndex)); - row.append(open); - body.append(row); - } - return body; - }); -} - /** Open the audit dialog for one visit: its turn files, session and definition. */ function openAuditFor(d, step, stageKey, visitIndex) { if (!step) return; const graph = d.graph ?? { stages: [] }; const stage = (graph.stages ?? []).find((candidate) => candidate.key === stageKey) ?? null; - const fields = runStepFields(step); - const valueOf = (label) => fields.find((field) => field.label === label)?.value ?? ""; showStageAudit({ title: `${nodeLabel(stageKey)} audit`, subtitle: `Visit ${visitIndex + 1} · ${runLabelFor(d)}`, tabs: [ - { key: "input", label: "Input", body: () => auditDocument(valueOf("Input"), EMPTY_INPUT_MESSAGE) }, - { key: "output", label: "Output", body: () => auditDocument(valueOf("Output"), EMPTY_OUTPUT_MESSAGE) }, - { key: "memory", label: "Memory", body: () => auditMemory(step) }, - { key: "session", label: "Session", body: () => renderSessionExport(step) }, + { key: "input", label: "Input", body: () => auditArtifact(step, "input.md", EMPTY_INPUT_MESSAGE) }, + { key: "output", label: "Output", body: () => auditArtifact(step, "output.md", EMPTY_OUTPUT_MESSAGE) }, + { key: "memory", label: "Memory", body: () => auditArtifact(step, "memory.md", "No memory recorded for this visit.") }, + { key: "session", label: "Session", body: () => auditSession(step) }, { key: "definition", label: "Definition", body: () => auditDefinition(stage, stageKey, graph) }, ], }); } -/** One audit tab body: a markdown document, or the honest empty sentence. */ -function auditDocument(text, emptyMessage) { - const value = String(text ?? "").trim(); - if (value === "") return h("div", { class: "muted", text: emptyMessage }); - if (looksLikeMarkdown(value)) { - return h("div", { class: "audit-doc field-markdown" }, rt.views.chat.renderMarkdown(value)); +/** + * One turn file in the audit: the raw bytes and the rendered markdown, with a + * Rendered/Raw switch and a link to the file on the server. The file is fetched + * (not the step's field map), so the outcome section is visible exactly as the + * stage wrote it. + */ +function auditArtifact(step, name, emptyMessage) { + const artifact = systemArtifacts(step).find((entry) => entry.name === name); + const wrap = h("div", { class: "audit-doc" }); + if (!artifact) { + wrap.append(h("div", { class: "muted", text: emptyMessage })); + return wrap; } - return h("pre", { class: "field-block" }, h("code", { text: value })); -} - -/** The memory.md of this visit, rendered once it loads. */ -function auditMemory(step) { - const artifact = systemArtifacts(step).find((entry) => entry.name === "memory.md"); - if (!artifact) return h("div", { class: "muted", text: "No memory recorded for this visit." }); const resolved = resolvedArtifactUrl(artifact, state.url); - if (!resolved) return h("div", { class: "muted", text: ARTIFACT_SERVER_HINT }); - const body = h("div", { class: "audit-doc" }, h("div", { class: "muted", text: "Loading memory…" })); + if (!resolved) { + wrap.append(h("div", { class: "muted", text: ARTIFACT_SERVER_HINT })); + return wrap; + } + let text = ""; + let mode = "rendered"; + const bar = h("div", { class: "audit-doc-bar" }); + const toggle = h("div", { class: "audit-doc-toggle", role: "group", "aria-label": "Document view" }); + const out = h("div", { class: "audit-doc-body" }); + const draw = () => { + toggle.replaceChildren( + ...[ + ["rendered", "Rendered"], + ["raw", "Raw"], + ].map(([key, label]) => + h("button", { + class: `audit-doc-mode${mode === key ? " active" : ""}`, + type: "button", + "aria-pressed": mode === key ? "true" : "false", + text: label, + onclick: () => { + mode = key; + draw(); + }, + }), + ), + ); + out.replaceChildren(); + if (mode === "raw" || !looksLikeMarkdown(text)) { + out.append(h("pre", { class: "field-block" }, h("code", { text }))); + return; + } + out.append(h("div", { class: "field-markdown" }, rt.views.chat.renderMarkdown(text))); + }; + bar.append( + toggle, + h("a", { + class: "audit-doc-open", + href: resolved, + target: "_blank", + rel: "noreferrer", + text: "Open raw file", + }), + ); + wrap.append(bar, out); + out.append(h("div", { class: "muted", text: "Loading…" })); fetch(resolved) .then((response) => { if (!response.ok) throw new Error(`The server answered ${response.status}.`); return response.text(); }) - .then((text) => { - if (text.trim() === "") { - body.replaceChildren(h("div", { class: "muted", text: "No completed turns were recorded before this visit." })); - return; - } - const article = h("div", { class: "field-markdown" }); - article.append(rt.views.chat.renderMarkdown(text)); - body.replaceChildren(article); + .then((body) => { + text = body; + draw(); }) .catch((error) => { - body.replaceChildren(h("div", { class: "muted", text: describeError(error) })); + out.replaceChildren(h("div", { class: "muted", text: describeError(error) })); }); - return body; + return wrap; +} + +/** The exported session, rendered in place, with the raw file one click away. */ +function auditSession(step) { + const artifact = systemArtifacts(step).find((entry) => entry.name === "session.html"); + if (!artifact) return renderSessionExport(step); + const resolved = resolvedArtifactUrl(artifact, state.url); + const wrap = h("div", { class: "audit-session" }); + if (!resolved) { + wrap.append(h("div", { class: "muted", text: ARTIFACT_SERVER_HINT })); + return wrap; + } + wrap.append( + h( + "div", + { class: "audit-doc-bar" }, + h("a", { + class: "audit-doc-open", + href: resolved, + target: "_blank", + rel: "noreferrer", + text: "Open raw file", + }), + ), + ); + wrap.append( + h("iframe", { + class: "audit-session-frame", + src: resolved, + title: `Session export · ${step.stage}`, + sandbox: "", + }), + ); + return wrap; } /** The stage's own definition (prompt, tools, configs, edges) in the audit. */ @@ -356,8 +394,6 @@ function renderRunSummaryTab(d, now) { ), ); - // Everything the system wrote for each visit, behind one explicit door. - wrap.append(renderRunAuditSection(d)); return wrap; } diff --git a/web/src/views/search.js b/web/src/views/search.js index 13f3fa67..30cf6779 100644 --- a/web/src/views/search.js +++ b/web/src/views/search.js @@ -397,6 +397,54 @@ function fillSearchResults(area) { area.replaceChildren(...nodes); } +/** The inline glyph for a non-artifact search result's kind. */ +function searchKindGlyph(kind) { + const ns = "http://www.w3.org/2000/svg"; + const svg = document.createElementNS(ns, "svg"); + svg.setAttribute("viewBox", "0 0 24 24"); + svg.setAttribute("aria-hidden", "true"); + svg.setAttribute("focusable", "false"); + const paths = { + pipeline: "M7 12h5V6h4M12 12v6h4", + version: "M12 3l9 5-9 5-9-5 9-5ZM3 12l9 5 9-5", + run: "M8 5l11 7-11 7V5Z", + step: "M5 12h10M13 8l4 4-4 4", + field: "M5 7h14M5 12h14M5 17h9", + unknown: "M12 8v8M8 12h8", + }; + const path = document.createElementNS(ns, "path"); + path.setAttribute("d", paths[kind] ?? paths.unknown); + path.setAttribute("fill", "none"); + path.setAttribute("stroke", "currentColor"); + path.setAttribute("stroke-width", "1.8"); + path.setAttribute("stroke-linecap", "round"); + path.setAttribute("stroke-linejoin", "round"); + svg.append(path); + if (kind === "pipeline") { + for (const [cx, cy] of [[4, 12], [19, 6], [19, 18]]) { + const dot = document.createElementNS(ns, "circle"); + dot.setAttribute("cx", String(cx)); + dot.setAttribute("cy", String(cy)); + dot.setAttribute("r", "2"); + dot.setAttribute("fill", "currentColor"); + svg.append(dot); + } + } + return svg; +} + +/** The fixed-size leading tile for a non-artifact result: a kind glyph only. */ +function searchKindTile(hit) { + const label = searchResultKindLabel(hit); + const tile = h("span", { + class: "search-type search-type-kind", + title: label, + "aria-label": label, + }); + tile.append(searchKindGlyph(String(hit?.kind ?? "unknown"))); + return tile; +} + /** The short caption on a non-image artifact's type tile. */ function artifactTypeBadge(kind, artifact) { const name = String(artifact?.name ?? "").toLowerCase(); @@ -460,7 +508,7 @@ function renderSearchResultRow(hit) { const target = searchTarget(hit); const artifactHit = hit?.kind === "artifact" && hit.artifact ? hit.artifact : null; const element = h("div", { - class: `search-row${target ? " clickable" : " readonly"}${artifactHit ? " search-row-artifact" : ""}`, + class: `search-row${target ? " clickable" : " readonly"} search-row-with-icon${artifactHit ? " search-row-artifact" : ""}`, "data-kind": String(hit?.kind ?? ""), }); if (target) { @@ -506,7 +554,9 @@ function renderSearchResultRow(hit) { ); } } else { - element.append(h("span", { class: "search-kind muted", text: searchResultKindLabel(hit) })); + // Every row leads with the same fixed-size tile; kinds are symbols, never + // words like "PIPELINE" that make one row look different from another. + element.append(searchKindTile(hit)); } const main = h("div", { class: "search-row-main" }); main.append(h("div", { class: "search-row-title", text: row.title }));