From 3314f8405b75b4c8b88a7da8884b56091bc53127 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Tue, 20 Oct 2026 01:36:38 +0100 Subject: [PATCH] web: one status glyph, a compact settings button and collapsible panes - Run and pipeline rows use one coloured status glyph with the word in its tooltip; the run version sits at the right of the title line; the usage metrics row is gone. - Settings is an icon beside the connection status (rail and dock), not a destination tab; the destinations keep a roving tab even while Settings is open. - The rail and every list pane collapse to a narrow strip from an icon at their top-right (remembered per device). A collapsed runs list shows the status glyph, pipelines their flow glyph, chats their status word. - Tool calls open in a modal (rendered/expanded rows in place) instead of an inline popover; the chip stays a quiet line beside the message. - Refresh tooltips show the last data arrival (manual or socket) per destination. --- web/chat.css | 26 ++++++++ web/lists.css | 91 ++++++++++++++++++++++++++ web/shell.css | 22 +++++++ web/src/app.js | 108 +++++++++++++++++++++++++++--- web/src/layoutPrefs.js | 30 +++++++++ web/src/statusIcon.js | 62 ++++++++++++++++++ web/src/views/chat.js | 119 ++++++++++++++++------------------ web/src/views/pipelines.js | 37 ++++++++++- web/src/views/runs.js | 6 +- web/test/layoutPrefs.test.mjs | 33 ++++++++++ web/test/ui-smoke.mjs | 72 ++++++++++---------- 11 files changed, 488 insertions(+), 118 deletions(-) create mode 100644 web/src/layoutPrefs.js create mode 100644 web/src/statusIcon.js create mode 100644 web/test/layoutPrefs.test.mjs diff --git a/web/chat.css b/web/chat.css index 9df41950..3cd643a7 100644 --- a/web/chat.css +++ b/web/chat.css @@ -796,3 +796,29 @@ .md-rule { border: 0; border-top: 1px solid var(--border); } .md-link { color: var(--accent); } .md-link-plain { color: var(--muted); } + +/* Tool calls open in a modal, not an inline popover beside the message. */ +.chat-tools-viewer { + position: fixed; + inset: 0; + z-index: 70; + display: flex; + align-items: center; + justify-content: center; + padding: 24px; + background: rgba(0, 0, 0, 0.78); +} +.chat-tools-modal-panel { + display: flex; + flex-direction: column; + width: min(760px, 100%); + max-height: min(80vh, 900px); + min-height: 0; + background: var(--surface); + border: 1px solid var(--border); + border-radius: 14px; + box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); + overflow: hidden; +} +.chat-tools-modal-panel .chat-tool-panel { position: static; max-height: none; border: 0; box-shadow: none; background: transparent; } +.chat-tools-modal-panel .chat-tool-list { overflow: auto; } diff --git a/web/lists.css b/web/lists.css index 10c1ee1b..6946b8a6 100644 --- a/web/lists.css +++ b/web/lists.css @@ -273,3 +273,94 @@ .source-code code { background: transparent; padding: 0; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; } .graph-note { margin: 0; max-width: 60ch; } + + +/* One coloured status glyph in list rows, with the word in its tooltip. */ +.status-icon { + display: inline-flex; + align-items: center; + justify-content: center; + width: 20px; + height: 20px; + padding: 0; + border: 0; + background: transparent; + border-radius: 50%; +} +.status-icon svg { width: 14px; height: 14px; } +.status-icon.status-succeeded { color: var(--ok); } +.status-icon.status-failed { color: var(--bad); } +.status-icon.status-running { color: var(--accent); } +.status-icon.status-running svg { animation: spin 0.9s linear infinite; } +.status-icon.status-canceled { color: var(--muted); } +.status-icon.status-interrupted { color: var(--warn); } +.status-icon.status-waiting, +.status-icon.status-queued { color: var(--muted); } + +/* The run row's version sits at the far right of its title line. */ +.run-row-head .version-chip { margin-left: auto; } + +/* Collapsible rail and list panes: one icon each, with the same information + grammar as the full surfaces when there is room for it. */ +.shell-collapse { + display: inline-flex; + align-items: center; + justify-content: center; + width: 22px; + height: 22px; + padding: 0; + border: 1px solid transparent; + border-radius: var(--radius-control); + background: transparent; + color: var(--muted); + font-size: 14px; + line-height: 1; + cursor: pointer; +} +.shell-collapse:hover { color: var(--color-text); border-color: var(--color-border); } +.list-collapse { flex: 0 0 auto; } +.app-rail { position: relative; } +.rail-collapse { position: absolute; top: 6px; right: 6px; z-index: 2; } +.app-rail.collapsed { flex: 0 0 64px; width: 64px; align-items: center; } +.app-rail.collapsed .rail-brand span, +.app-rail.collapsed .rail-label, +.app-rail.collapsed .rail-search span, +.app-rail.collapsed .rail-heading, +.app-rail.collapsed .rail-sections, +.app-rail.collapsed .rail-divider, +.app-rail.collapsed .shell-status-label { display: none; } +.app-rail.collapsed .rail-brand { justify-content: center; padding-left: 0; padding-right: 0; } +.app-rail.collapsed .rail-tab, +.app-rail.collapsed .rail-search { justify-content: center; width: 40px; padding: 0; gap: 0; } +.app-rail.collapsed .rail-destinations { align-items: center; } +.app-rail.collapsed .rail-footer { width: 100%; } +.pipeline-head { display: flex; align-items: center; gap: 8px; min-width: 0; } +.pipeline-glyph { flex: none; width: 18px; height: 18px; color: var(--muted); } + +.pane-layout.list-collapsed { grid-template-columns: 64px minmax(0, 1fr); } +.list-collapsed .list-pane .pane-head { padding: 6px; justify-content: center; } +.list-collapsed .list-pane .pane-head-text, +.list-collapsed .list-pane .pane-head-actions > *:not(.list-collapse) { display: none; } +.list-collapsed .list-pane .pane-head-actions { margin: 0; } +.list-collapsed .list-pane .list, +.list-collapsed .list-pane .list-scroll { padding-left: 2px; padding-right: 2px; } +/* Run rows: a single status glyph. */ +.list-collapsed .run-row > *:not(.run-row-head) { display: none; } +.list-collapsed .run-row .run-row-head > *:not(.status-icon) { display: none; } +.list-collapsed .run-row .run-row-head { justify-content: center; } +/* Pipeline rows: a single pipeline glyph. */ +.list-collapsed #pipelineRows .row > *:not(.pipeline-head) { display: none; } +.list-collapsed #pipelineRows .pipeline-head .row-title { display: none; } +.list-collapsed #pipelineRows .pipeline-head { justify-content: center; } +/* Chat rows: the status word only. */ +.list-collapsed .chat-row .row-title, +.list-collapsed .chat-row .row-meta, +.list-collapsed .chat-row .chat-star, +.list-collapsed .chat-row .chat-menu-button, +.list-collapsed .chat-row .chat-row-actions, +.list-collapsed .chat-group-header, +.list-collapsed .chat-group-toggle { display: none; } +.list-collapsed .chat-row .row-head { justify-content: center; } +.list-collapsed .chat-row .chat-session-button { grid-row: auto; } +.list-collapsed .chat-row .chat-activity { font-size: 10px; } +.list-collapsed .list-pane .day-header { display: none; } diff --git a/web/shell.css b/web/shell.css index 2c688ad4..4c1f7330 100644 --- a/web/shell.css +++ b/web/shell.css @@ -579,3 +579,25 @@ body { .detail-pane > .pane-scroll > .detail { padding: var(--space-s); } .settings-pane > .settings { padding: var(--space-s) var(--space-s) var(--space-l); } } + +/* Settings sits beside the connection status, not in the destination list. */ +.rail-footer-row { display: flex; align-items: center; gap: 6px; } +.rail-footer-row .shell-status { flex: 1 1 auto; min-width: 0; } +.shell-settings { + flex: 0 0 auto; + display: inline-flex; + align-items: center; + justify-content: center; + width: 32px; + height: 32px; + padding: 0; + border: 0; + border-radius: var(--radius-control); + background: transparent; + color: var(--muted); +} +.shell-settings:hover { background: var(--tint-hover); color: var(--color-text); } +.shell-settings.active { background: var(--tint-selected); color: var(--color-text); } +.dock-status-row { display: flex; align-items: stretch; gap: 2px; } +.dock-status-row .dock-status { flex: 1 1 auto; min-width: 0; } +.dock-settings { width: 56px; height: 48px; } diff --git a/web/src/app.js b/web/src/app.js index 34832b57..f735594f 100644 --- a/web/src/app.js +++ b/web/src/app.js @@ -28,6 +28,7 @@ import { layoutGraph } from "./graph.js"; import { readGraphExpanded } from "./graphPrefs.js"; import { readArtifactView } from "./artifactViewPrefs.js"; import { readChatStars } from "./chatStars.js"; +import { readLayoutPrefs, writeLayoutPrefs } from "./layoutPrefs.js"; import { DEFAULT_ROUTE, parseRoute, serializeRoute } from "./routes.js"; import { EMPTY_PIPELINE_FILTERS, PIPELINE_DETAIL_TABS } from "./pipelines.js"; import { @@ -180,6 +181,8 @@ const state = { artifactView: readArtifactView(), // Starred chat sessions (chatStars.js): local, always sorted first. chatStars: readChatStars(), + // The collapsed rail/list choices (layoutPrefs.js), restored per device. + ...readLayoutPrefs(), // Whether the CLOSED chats group is expanded (the chevron beside its name). chatClosedOpen: false, // The last time each destination's data arrived (manual refresh or a socket @@ -458,7 +461,9 @@ const railDestinations = h( "aria-label": "Destinations", "aria-orientation": "vertical", }, - ...DESTINATIONS.map((destination) => destinationTab(destination, "rail")), + ...DESTINATIONS.filter((destination) => destination.key !== "settings").map((destination) => + destinationTab(destination, "rail"), + ), ); const dockDestinations = h( @@ -469,7 +474,9 @@ const dockDestinations = h( role: "tablist", "aria-label": "Destinations", }, - ...DESTINATIONS.map((destination) => destinationTab(destination, "dock")), + ...DESTINATIONS.filter((destination) => destination.key !== "settings").map((destination) => + destinationTab(destination, "dock"), + ), ); const railSearch = h( @@ -517,6 +524,25 @@ function statusControl(id, mount) { const railStatus = statusControl("shellStatus", "rail"); const dockStatus = statusControl("shellStatusNarrow", "dock"); +function settingsControl(mount) { + return h( + "button", + { + id: mount === "rail" ? "railSettings" : "dockSettings", + class: mount === "rail" ? "shell-settings rail-settings" : "shell-settings dock-settings", + type: "button", + title: "Settings", + "aria-label": "Settings", + "data-settings-destination": "settings", + onclick: () => goToDestination("settings"), + }, + icon("settings"), + ); +} + +const railSettings = settingsControl("rail"); +const dockSettings = settingsControl("dock"); + const railSections = h("div", { id: "railSections", class: "rail-sections" }); const sectionStrip = h("nav", { id: "sectionStrip", @@ -527,6 +553,14 @@ const sectionStrip = h("nav", { const appRail = h( "aside", { id: "appRail", class: "app-rail", "aria-label": "Pipelines navigation" }, + h("button", { + id: "railCollapse", + class: "shell-collapse rail-collapse", + type: "button", + title: "Collapse navigation", + "aria-label": "Collapse navigation", + "aria-expanded": "true", + }), h( "div", { class: "rail-brand" }, @@ -545,7 +579,7 @@ const appRail = h( railDestinations, h("div", { class: "rail-divider", role: "presentation" }), railSections, - h("div", { class: "rail-footer" }, railStatus), + h("div", { class: "rail-footer" }, h("div", { class: "rail-footer-row" }, railStatus, railSettings)), ); // The omni-search panel is part of the workspace flow: it takes height from the @@ -568,7 +602,7 @@ const workspace = h( const dock = h( "nav", { id: "destinationDock", class: "destination-dock", "aria-label": "Destinations" }, - dockStatus, + h("div", { class: "dock-status-row" }, dockStatus, dockSettings), h("div", { class: "dock-row" }, dockSearch, dockDestinations), ); // The attention sheet lives in its own layer so it can overlay any view without @@ -581,6 +615,18 @@ const modalLayer = h("div", { id: "modalLayer" }); const skipLink = h("a", { class: "skip-link", href: "#pane-main", text: "Skip to detail" }); document.body.append(skipLink); document.body.append(h("div", { class: "app-root" }, appRail, workspace, dock)); +appRail.querySelector("#railCollapse")?.addEventListener("click", () => { + state.railCollapsed = !state.railCollapsed; + applyLayoutState(); +}); +document.addEventListener("click", (event) => { + const button = event.target instanceof Element ? event.target.closest("#listCollapse") : null; + if (!button) return; + state.listCollapsed = !state.listCollapsed; + writeLayoutPrefs(state); + renderContent(); +}); +applyLayoutState(); document.body.append(attentionLayer); document.body.append(modalLayer); @@ -647,11 +693,17 @@ function clearServerUrlError() { /** Repaint the shell chrome in place; the rail itself is never rebuilt. */ function renderHeader() { const activeKey = destinationForView(state.view); - const activeIndex = destinationIndex(activeKey); - for (const tab of document.querySelectorAll("[data-destination]")) { - const isActive = tab.getAttribute("data-destination") === activeKey; + const tabs = [...document.querySelectorAll("[data-destination]")]; + const keys = tabs.map((tab) => tab.getAttribute("data-destination")); + // Settings is a separate control beside the status, so while it is open no + // destination tab is selected; keep the first one in the roving order. + const activeIndex = keys.indexOf(activeKey); + const roving = activeIndex >= 0 ? activeIndex : 0; + for (const tab of tabs) { + const key = tab.getAttribute("data-destination"); + const isActive = key === activeKey; tab.setAttribute("aria-selected", isActive ? "true" : "false"); - tab.setAttribute("tabindex", rovingTabindex(activeIndex, DESTINATIONS.findIndex((d) => d.key === tab.getAttribute("data-destination")))); + tab.setAttribute("tabindex", rovingTabindex(roving, keys.indexOf(key))); if (isActive) tab.setAttribute("aria-current", "page"); else tab.removeAttribute("aria-current"); } @@ -662,6 +714,12 @@ function renderHeader() { if (label) label.textContent = status.text; control.setAttribute("aria-label", `Connection status: ${status.text}. Open Settings`); } + for (const control of document.querySelectorAll("[data-settings-destination='settings']")) { + const active = activeKey === "settings"; + control.classList.toggle("active", active); + if (active) control.setAttribute("aria-current", "page"); + else control.removeAttribute("aria-current"); + } railSearch.setAttribute("aria-expanded", state.searchOpen ? "true" : "false"); dockSearch.setAttribute("aria-expanded", state.searchOpen ? "true" : "false"); // aria-controls points at #searchPanel only while that panel exists. @@ -849,10 +907,37 @@ function paneHeading(title, { detailOpen, subtitle = "", actions = [] } = {}) { { class: "pane-head" }, h("div", { class: "pane-head-text" }, h(tag, { class: "pane-title", id: "listTitle", text: title }), subtitle ? h("h2", { class: "pane-subtitle", text: subtitle }) : null), ); - if (actions.length) head.append(h("div", { class: "pane-head-actions" }, ...actions)); + head.append(h("div", { class: "pane-head-actions" }, ...actions, listCollapseButton())); return head; } +/** The icon that collapses the list pane to a narrow strip and back. */ +function listCollapseButton() { + const collapsed = state.listCollapsed === true; + return h("button", { + id: "listCollapse", + class: "shell-collapse list-collapse", + type: "button", + title: collapsed ? "Expand list" : "Collapse list", + "aria-label": collapsed ? "Expand list" : "Collapse list", + "aria-expanded": collapsed ? "false" : "true", + text: collapsed ? "\u203a" : "\u2039", + }); +} + +function applyLayoutState() { + appRail.classList.toggle("collapsed", state.railCollapsed === true); + const railButton = document.getElementById("railCollapse"); + if (railButton) { + const label = state.railCollapsed ? "Expand navigation" : "Collapse navigation"; + railButton.title = label; + railButton.setAttribute("aria-label", label); + railButton.setAttribute("aria-expanded", state.railCollapsed ? "false" : "true"); + railButton.textContent = state.railCollapsed ? "\u203a" : "\u2039"; + } + writeLayoutPrefs(state); +} + function listSubtitle(view) { switch (view) { case "runs": @@ -1031,7 +1116,10 @@ function renderContent() { : state.selectedTemplateKey != null; const activePane = detailOpen ? "detail" : "list"; const model = detailSections(); - const layout = h("div", { class: "pane-layout", "data-active-pane": activePane }); + const layout = h("div", { + class: `pane-layout${state.listCollapsed ? " list-collapsed" : ""}`, + "data-active-pane": activePane, + }); if (view === "pipelines") { layout.append( diff --git a/web/src/layoutPrefs.js b/web/src/layoutPrefs.js new file mode 100644 index 00000000..f4623aa1 --- /dev/null +++ b/web/src/layoutPrefs.js @@ -0,0 +1,30 @@ +// The shell's two layout preferences: a collapsed destination rail and a +// collapsed list pane. Per-device, so they survive reloads. + +export const LAYOUT_KEY = "pipelines.web.layout.v1"; + +export function readLayoutPrefs(storage = globalThis.localStorage) { + try { + const parsed = JSON.parse(storage?.getItem(LAYOUT_KEY) ?? "{}"); + return { + railCollapsed: parsed?.railCollapsed === true, + listCollapsed: parsed?.listCollapsed === true, + }; + } catch { + return { railCollapsed: false, listCollapsed: false }; + } +} + +export function writeLayoutPrefs(prefs, storage = globalThis.localStorage) { + try { + storage?.setItem( + LAYOUT_KEY, + JSON.stringify({ + railCollapsed: prefs?.railCollapsed === true, + listCollapsed: prefs?.listCollapsed === true, + }), + ); + } catch { + // Storage may be unavailable; the in-memory choice still applies. + } +} diff --git a/web/src/statusIcon.js b/web/src/statusIcon.js new file mode 100644 index 00000000..3c9c1519 --- /dev/null +++ b/web/src/statusIcon.js @@ -0,0 +1,62 @@ +// The one status glyph used in list rows: a single coloured icon whose tooltip +// and accessible name say the state. The pill text badge is deliberately gone. +import { h } from "./dom.js"; + +const NS = "http://www.w3.org/2000/svg"; + +function iconPath(state) { + switch (state) { + case "succeeded": + return "M5 12.5l4.5 4.5L19 7"; + case "failed": + return "M6 6l12 12M18 6L6 18"; + case "running": + return "M12 3a9 9 0 1 0 9 9"; + case "canceled": + return "M12 3a9 9 0 1 0 0 18M7.5 7.5l9 9"; + case "interrupted": + return "M9 6v12M15 6v12"; + case "waiting": + case "queued": + return "M12 6v6l4 2"; + default: + return "M12 8v8M8 12h8"; + } +} + +/** `state` is the run status token; `label` is the word a person reads. */ +export function statusIcon(state, label = state) { + const tone = String(state ?? "").trim().toLowerCase() || "unknown"; + const word = String(label ?? tone); + const span = h("span", { + class: `chip chip-${tone} status-icon status-${tone}`, + role: "img", + title: word, + "aria-label": word, + "data-status": tone, + }); + const svg = document.createElementNS(NS, "svg"); + svg.setAttribute("viewBox", "0 0 24 24"); + svg.setAttribute("aria-hidden", "true"); + svg.setAttribute("focusable", "false"); + if (tone === "waiting" || tone === "queued") { + const circle = document.createElementNS(NS, "circle"); + circle.setAttribute("cx", "12"); + circle.setAttribute("cy", "12"); + circle.setAttribute("r", "9"); + circle.setAttribute("fill", "none"); + circle.setAttribute("stroke", "currentColor"); + circle.setAttribute("stroke-width", "1.8"); + svg.append(circle); + } + const path = document.createElementNS(NS, "path"); + path.setAttribute("d", iconPath(tone)); + path.setAttribute("fill", "none"); + path.setAttribute("stroke", "currentColor"); + path.setAttribute("stroke-width", "2"); + path.setAttribute("stroke-linecap", "round"); + path.setAttribute("stroke-linejoin", "round"); + svg.append(path); + span.append(svg); + return span; +} diff --git a/web/src/views/chat.js b/web/src/views/chat.js index 495cc594..920bde81 100644 --- a/web/src/views/chat.js +++ b/web/src/views/chat.js @@ -2491,15 +2491,14 @@ function renderChatToolCalls(turn, { streaming = false, elapsedMillis = () => 0 const running = streaming && toolsRunning(turn.parts); const failed = parts.some((part) => toolFailed(part.state)); const long = running && parts.some((part) => toolRunning(part) && toolLongRunning(elapsedMillis(part))); - const turnKey = turn.key; const wrap = h("div", { class: "chat-tools" }); - const open = state.chatToolPanels.has(turnKey); const chip = h("button", { class: `chip chat-tool-chip${failed ? " chat-tool-chip-failed" : ""}`, type: "button", "aria-label": toolCallsAnnouncement(count), - "aria-expanded": String(open), + "aria-expanded": "false", + "aria-haspopup": "dialog", }); if (running) { chip.append(h("span", { class: "spinner chat-tool-spinner", "aria-hidden": "true" })); @@ -2514,28 +2513,25 @@ function renderChatToolCalls(turn, { streaming = false, elapsedMillis = () => 0 } chip.append(h("span", { class: "chat-tool-label", text: toolCallsLabel(count) })); if (long) chip.append(h("span", { class: "chat-tool-long", text: "\u00b7 long" })); - const chevron = h("span", { - class: "chat-tool-chevron", - role: "img", - "aria-label": open ? "Hide tool calls" : "Show tool calls", - text: open ? "\u25b4" : "\u25be", + chip.append( + h("span", { + class: "chat-tool-chevron", + role: "img", + "aria-label": "Open tool calls", + text: "\u25b8", + }), + ); + chip.addEventListener("click", (event) => { + event.stopPropagation(); + openChatToolCalls(turn, parts, count); }); - chip.append(chevron); wrap.append(chip); + return wrap; +} - const panel = h("div", { class: "chat-tool-panel", role: "dialog", "aria-label": toolCallsLabel(count) }); - panel.hidden = !open; - const head = h("div", { class: "chat-tool-panel-head" }); - head.append(h("span", { class: "chat-tool-panel-count", text: toolCallsLabel(count) })); - const close = h("button", { - class: "ghost chat-tool-close", - type: "button", - "aria-label": "Close tool calls", - title: "Close tool calls", - text: "\u00d7", - }); - head.append(close); - panel.append(head); +/** The tool list body, shared by the modal: one expandable row per call. */ +function renderChatToolPanelBody(turn, parts, count) { + const panel = h("div", { class: "chat-tool-panel" }); const list = h("div", { class: "chat-tool-list" }); for (const part of parts) { const id = String(part?.id ?? ""); @@ -2553,50 +2549,45 @@ function renderChatToolCalls(turn, { streaming = false, elapsedMillis = () => 0 list.append(holder); } panel.append(list); - wrap.append(panel); - - const setOpen = (next) => { - if (next) state.chatToolPanels.add(turnKey); - else state.chatToolPanels.delete(turnKey); - panel.hidden = !next; - chip.setAttribute("aria-expanded", String(next)); - chevron.setAttribute("aria-label", next ? "Hide tool calls" : "Show tool calls"); - chevron.textContent = next ? "\u25b4" : "\u25be"; - if (next) positionChatToolPanel(panel, chip); - }; - chip.addEventListener("click", (event) => { - event.stopPropagation(); - setOpen(panel.hidden); - }); - close.addEventListener("click", () => setOpen(false)); - if (open) { - // The panel is built before its turn is attached to the document, so its - // rect is not measurable yet; place it on the next frame, when it is. - const place = () => positionChatToolPanel(panel, chip); - if (typeof requestAnimationFrame === "function") requestAnimationFrame(place); - else setTimeout(place, 0); - } - - return wrap; + return panel; } -/** - * Places the tool panel below its chip, or above it when there is no room, keeping - * it inside the viewport margins — the browser's port of - * `ToolPanelPositionProvider`. Resolved in px from the live rects, so it is - * independent of any layout guess. - */ -function positionChatToolPanel(panel, chip) { - const gap = 4; - const margin = 8; - const chipRect = chip.getBoundingClientRect(); - const rect = panel.getBoundingClientRect(); - let top = chipRect.bottom + gap; - if (top + rect.height > window.innerHeight - margin) top = chipRect.top - rect.height - gap; - top = Math.max(margin, Math.min(top, window.innerHeight - rect.height - margin)); - const left = Math.max(margin, Math.min(chipRect.left, window.innerWidth - rect.width - margin)); - panel.style.top = `${Math.round(top)}px`; - panel.style.left = `${Math.round(left)}px`; +/** Open one turn's tool calls in a modal, not an inline popover. */ +function openChatToolCalls(turn, parts, count) { + const close = () => modal.close("chat-tools"); + const overlay = h("div", { + class: "chat-tools-viewer", + role: "dialog", + "aria-modal": "true", + "aria-label": toolCallsLabel(count), + }); + overlay.addEventListener("click", (event) => { + if (event.target === overlay) close(); + }); + const panel = h("div", { class: "chat-tools-modal-panel" }); + panel.append( + h( + "div", + { class: "chat-tool-panel-head" }, + h("span", { class: "chat-tool-panel-count", text: toolCallsLabel(count) }), + h("button", { + class: "ghost chat-tool-close", + type: "button", + "aria-label": "Close tool calls", + title: "Close tool calls", + text: "\u00d7", + onclick: close, + }), + ), + renderChatToolPanelBody(turn, parts, count), + ); + overlay.append(panel); + modal.open("chat-tools", overlay, { + history: false, + onClose: close, + trigger: document.activeElement, + fallbackSelectors: ["#chatTranscript", "#detailTitle", "#pane-main"], + }); } /** diff --git a/web/src/views/pipelines.js b/web/src/views/pipelines.js index 16839777..18c919f7 100644 --- a/web/src/views/pipelines.js +++ b/web/src/views/pipelines.js @@ -24,6 +24,7 @@ import { versionRow, } from "../pipelines.js"; import { PIPELINE_GRAPH_EMPTY, mount as mountGraph } from "../graph.js"; +import { statusIcon } from "../statusIcon.js"; import { writeGraphExpanded } from "../graphPrefs.js"; export function createPipelinesView(rt) { @@ -237,7 +238,12 @@ function fillPipelineRows(rowsEl) { function renderPipelineRow(pipeline, latestRuns, runsKnown, now) { const children = [ - h("span", { class: "row-title", text: pipeline.name || `pipeline ${pipeline.id}` }), + h( + "span", + { class: "pipeline-head" }, + pipelineGlyph(), + h("span", { class: "row-title", text: pipeline.name || `pipeline ${pipeline.id}` }), + ), h("span", { class: "row-meta", text: pipelineSubtitle(pipeline) }), ]; const updated = pipelineUpdatedLine(pipeline); @@ -252,7 +258,7 @@ function renderPipelineRow(pipeline, latestRuns, runsKnown, now) { h( "span", { class: "row-run" }, - h("span", { class: `chip chip-${badge.state}`, text: badge.state }), + statusIcon(badge.state, badge.state.charAt(0).toUpperCase() + badge.state.slice(1)), h("span", { class: "row-meta", text: runBadgeMetaLine(badge) }), ), ); @@ -269,6 +275,33 @@ function renderPipelineRow(pipeline, latestRuns, runsKnown, now) { ); } +/** A small flow glyph: the pipeline's own icon in lists and the collapsed strip. */ +function pipelineGlyph() { + const ns = "http://www.w3.org/2000/svg"; + const svg = document.createElementNS(ns, "svg"); + svg.setAttribute("class", "pipeline-glyph"); + svg.setAttribute("viewBox", "0 0 24 24"); + svg.setAttribute("aria-hidden", "true"); + svg.setAttribute("focusable", "false"); + const path = document.createElementNS(ns, "path"); + path.setAttribute("d", "M4 12h5V6h5M9 12v6h5"); + 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); + for (const [cx, cy] of [[3, 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; +} + function renderPipelineDetail() { const d = state.pipelineDetail; const pane = h("div", { class: "detail" }); diff --git a/web/src/views/runs.js b/web/src/views/runs.js index 511320e1..d49c7053 100644 --- a/web/src/views/runs.js +++ b/web/src/views/runs.js @@ -3,6 +3,7 @@ // owns the DOM and the page's run-list state. import { h } from "../dom.js"; +import { statusIcon } from "../statusIcon.js"; import { RUN_STATES, RUN_TIME_RANGES, @@ -55,9 +56,6 @@ function renderRunList(now = Date.now()) { for (const entry of entries) { switch (entry.kind) { - case "usage": - scroll.append(renderUsage(entry.usage)); - break; case "empty": scroll.append(renderEmptyState(entry)); break; @@ -125,7 +123,7 @@ function renderRunRow(run, now) { }); const head = h("span", { class: "run-row-head" }); - head.append(h("span", { class: `chip chip-${status}`, text: status })); + head.append(statusIcon(status, status.charAt(0).toUpperCase() + status.slice(1))); if (run.executing) head.append(h("span", { class: "spinner", "aria-hidden": "true" })); // The pipeline is the list's anchor: it names what ran, before the task title. head.append( diff --git a/web/test/layoutPrefs.test.mjs b/web/test/layoutPrefs.test.mjs new file mode 100644 index 00000000..6336d0ed --- /dev/null +++ b/web/test/layoutPrefs.test.mjs @@ -0,0 +1,33 @@ +// The rail/list collapse choices are a local layout preference. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { LAYOUT_KEY, readLayoutPrefs, writeLayoutPrefs } from "../src/layoutPrefs.js"; + +function fakeStorage(initial = {}) { + const values = new Map(Object.entries(initial)); + return { + getItem: (key) => (values.has(key) ? values.get(key) : null), + setItem: (key, value) => values.set(key, String(value)), + values, + }; +} + +test("both panes are expanded when nothing was stored", () => { + assert.deepEqual(readLayoutPrefs(fakeStorage()), { railCollapsed: false, listCollapsed: false }); +}); + +test("the two choices survive a write and read independently", () => { + const storage = fakeStorage(); + writeLayoutPrefs({ railCollapsed: true, listCollapsed: false }, storage); + assert.deepEqual(readLayoutPrefs(storage), { railCollapsed: true, listCollapsed: false }); + assert.ok(storage.values.get(LAYOUT_KEY).includes("railCollapsed")); +}); + +test("malformed storage and failures fall back to expanded", () => { + assert.deepEqual(readLayoutPrefs(fakeStorage({ [LAYOUT_KEY]: "{oops" })), { + railCollapsed: false, + listCollapsed: false, + }); + const broken = { getItem() { throw new Error("denied"); }, setItem() { throw new Error("denied"); } }; + assert.doesNotThrow(() => writeLayoutPrefs({ railCollapsed: true }, broken)); +}); diff --git a/web/test/ui-smoke.mjs b/web/test/ui-smoke.mjs index 2b7ffb79..d9befb08 100644 --- a/web/test/ui-smoke.mjs +++ b/web/test/ui-smoke.mjs @@ -186,7 +186,7 @@ async function ensureConnected(timeout = 25000) { async function clickDestination(label) { const key = label.toLowerCase(); const done = await page.evaluate(`(() => { - const all = [...document.querySelectorAll('[data-destination="${key}"]')]; + const all = [...document.querySelectorAll('[data-destination="${key}"], [data-settings-destination="${key}"]')]; const el = all.find((node) => node.offsetParent !== null) ?? all[0]; if (!el) return false; el.click(); @@ -288,6 +288,7 @@ async function shellState() { dock: dock && visible(dock) ? { top: Math.round(dock.getBoundingClientRect().top) } : null, detailTitle: document.querySelector("#detailTitle")?.textContent.trim() ?? "", activeDestination: document.querySelector('[data-destination][aria-selected="true"]')?.getAttribute("data-destination") ?? "", + settingsActive: !!document.querySelector('[data-settings-destination="settings"][aria-current="page"]'), focus: document.activeElement?.id ?? document.activeElement?.className ?? "", }; })()`); @@ -300,11 +301,11 @@ function assertShell(label, state, { wide }) { } if (wide) { if (!state.railVisible || state.dockVisible) throw new Error(`${label}: expected the rail and no dock`); - if (state.railTabCount !== 4) throw new Error(`${label}: rail has ${state.railTabCount} tabs`); + if (state.railTabCount !== 3) throw new Error(`${label}: rail has ${state.railTabCount} tabs`); if (!state.searchInRail) throw new Error(`${label}: no Search control in the rail`); } else { if (state.railVisible || !state.dockVisible) throw new Error(`${label}: expected the dock and no rail`); - if (state.dockTabCount !== 4) throw new Error(`${label}: dock has ${state.dockTabCount} tabs`); + if (state.dockTabCount !== 3) throw new Error(`${label}: dock has ${state.dockTabCount} tabs`); if (!state.searchInDock) throw new Error(`${label}: no Search control in the dock`); } const { scrollHeight, innerHeight, scrollWidth, innerWidth } = state.page; @@ -318,7 +319,11 @@ function assertShell(label, state, { wide }) { for (const list of state.tablists) { const selected = list.tabs.filter((tab) => tab.selected === "true"); const zero = list.tabs.filter((tab) => tab.tabindex === "0"); - if (selected.length !== 1) throw new Error(`${label}: ${list.label} has ${selected.length} selected tabs`); + // Settings is not a destination tab; while it is open the rail has none. + const settingsRail = list.label === "Destinations" && state.settingsActive; + if (selected.length !== 1 && !(settingsRail && selected.length === 0)) { + throw new Error(`${label}: ${list.label} has ${selected.length} selected tabs`); + } if (zero.length !== 1) throw new Error(`${label}: ${list.label} has ${zero.length} tabindex=0 tabs`); for (const tab of list.tabs) { if (!tab.controls || !tab.controlExists) { @@ -327,8 +332,10 @@ function assertShell(label, state, { wide }) { } } const destinations = state.tablists.find((list) => list.tabs.some((tab) => tab.current === "page")); - if (!destinations) throw new Error(`${label}: no destination carries aria-current=page`); - if (!destinations.tabs.some((tab) => tab.label && tab.selected === "true")) { + if (!destinations && !state.settingsActive) { + throw new Error(`${label}: no destination carries aria-current=page`); + } + if (destinations && !destinations.tabs.some((tab) => tab.label && tab.selected === "true")) { throw new Error(`${label}: no destination tab is selected`); } } @@ -415,8 +422,8 @@ async function runShellChecks() { if (typeAndNumbers.titleOverflow !== "hidden" || typeAndNumbers.titleEllipsis !== "ellipsis") { throw new Error(`run names are not ellipsized: ${JSON.stringify(typeAndNumbers)}`); } - if (!typeAndNumbers.metricNumeric.includes("tabular-nums") || !typeAndNumbers.metaNumeric.includes("tabular-nums")) { - throw new Error(`counts/durations are not tabular: ${JSON.stringify(typeAndNumbers)}`); + if (!typeAndNumbers.metaNumeric.includes("tabular-nums")) { + throw new Error(`durations are not tabular: ${JSON.stringify(typeAndNumbers)}`); } await shot("80-shell-wide-runs-1440x900.png"); console.log(` wide runs: list ${state.listScrollers} / detail ${state.detailScrollers}`); @@ -561,8 +568,9 @@ async function runShellChecks() { focus: document.activeElement?.id ?? "", title: document.querySelector("#detailTitle")?.textContent ?? "", current: document.querySelector('[data-destination][aria-selected="true"]')?.getAttribute("data-destination") ?? "", + settingsCurrent: !!document.querySelector('[data-settings-destination="settings"][aria-current="page"]'), })`); - if (statusShortcut.focus !== "detailTitle" || statusShortcut.title !== "Settings" || statusShortcut.current !== "settings") { + if (statusShortcut.focus !== "detailTitle" || statusShortcut.title !== "Settings" || !statusShortcut.settingsCurrent) { throw new Error(`status shortcut did not land on Settings: ${JSON.stringify(statusShortcut)}`); } await page.evaluate(`document.querySelector("#shellStatus").focus()`); @@ -2404,7 +2412,7 @@ try { if (!noDetails.emptyAfterUnmount) throw new Error("unmount left the graph DOM behind"); console.log(" a node with no stage reads: No details recorded for this node."); - step("switching to Runs: day-grouped list + usage roll-up"); + step("switching to Runs: the day-grouped list"); await ensureConnected(); await clickDestination("Runs"); await eventually( @@ -2414,13 +2422,6 @@ try { ), { timeout: 25000, what: "the runs list" }, ); - await page.waitForSelector(".metrics .metric", { timeout: 25000 }); - const usageLabels = await page.evaluate( - `[...document.querySelectorAll(".metrics .metric-label")].map((n) => n.textContent)`, - ); - for (const label of ["Total", "Succeeded", "Failed", "Canceled", "Interrupted", "Active"]) { - if (!usageLabels.includes(label)) throw new Error(`usage metric missing: ${label}`); - } let fullDateHeader = ""; const dayHeaders = await page.evaluate( `[...document.querySelectorAll(".list.runs .day-header")].map((n) => n.textContent)`, @@ -2441,7 +2442,6 @@ try { } } shots.push(await page.screenshot(`${out}/09-runs-day-groups.png`)); - console.log(` usage: ${usageLabels.join(", ")}`); console.log(` day headers: ${dayHeaders.slice(0, 3).join(" | ")}`); // --------------------------------------------------------------------- @@ -2762,7 +2762,7 @@ try { } await page.click("#runFilterBtn"); // close the menu so the list is unobstructed const filteredChips = await page.evaluate( - `[...document.querySelectorAll(".list.runs .run-row .run-row-head .chip")].map((n) => n.textContent)`, + `[...document.querySelectorAll(".list.runs .run-row .run-row-head .status-icon")].map((n) => n.getAttribute("data-status"))`, ); if (!filteredChips.length) throw new Error("the status filter produced no rows"); if (!filteredChips.every((chip) => chip === "failed")) { @@ -3388,7 +3388,7 @@ try { { timeout: 30000, what: `a pushed run_event frame for run ${r10RunId}` }, ); const listStatus = await page.evaluate( - `document.querySelector('.list.runs .run-row-meta[data-run-id="${r10RunId}"]')?.closest(".run-row")?.querySelector(".chip")?.textContent ?? ""`, + `document.querySelector('.list.runs .run-row-meta[data-run-id="${r10RunId}"]')?.closest(".run-row")?.querySelector(".status-icon")?.getAttribute("data-status") ?? ""`, ); const listBadge = await page.evaluate( `document.querySelector(".list.runs .live-badge .live-word")?.textContent ?? ""`, @@ -5026,7 +5026,8 @@ try { }; })()`); if (!chipInfo) throw new Error("C6: no tool-call chip rendered in the live transcript"); - const toolCount = chipInfo.rows; + const parsedCount = Number(/(\d+)/.exec(chipInfo.text)?.[1] ?? NaN); + const toolCount = Number.isFinite(parsedCount) ? parsedCount : chipInfo.rows; const toolLabel = toolCount === 1 ? "1 tool called" : `${toolCount} tools called`; const toolAria = toolCount === 1 ? "1 tool call, expand for details" : `${toolCount} tool calls, expand for details`; @@ -5036,7 +5037,7 @@ try { if (chipInfo.aria !== toolAria) { throw new Error(`C6: chip aria-label ${chipInfo.aria} (expected ${toolAria})`); } - if (chipInfo.chevron !== "Show tool calls") { + if (chipInfo.chevron !== "Open tool calls") { throw new Error(`C6: collapsed chip chevron: ${chipInfo.chevron}`); } console.log(` tool chip "${toolLabel}" (aria "${chipInfo.aria}", ${toolCount} live row(s))`); @@ -5051,23 +5052,19 @@ try { const openedPanel = await page.evaluate(`(() => { const chip = document.querySelector("#chatTranscript .chat-tool-chip"); chip.click(); - const panel = chip.closest(".chat-tools").querySelector(".chat-tool-panel"); + const panel = document.querySelector(".chat-tools-viewer .chat-tool-panel"); return { - hidden: panel?.hidden ?? true, - head: panel?.querySelector(".chat-tool-panel-count")?.textContent ?? "", - close: panel?.querySelector(".chat-tool-close")?.getAttribute("aria-label") ?? "", - chevron: chip.querySelector(".chat-tool-chevron")?.getAttribute("aria-label") ?? "", + open: !!document.querySelector(".chat-tools-viewer"), + head: document.querySelector(".chat-tools-viewer .chat-tool-panel-count")?.textContent ?? "", + close: document.querySelector(".chat-tools-viewer .chat-tool-close")?.getAttribute("aria-label") ?? "", rows: panel?.querySelectorAll(".chat-tool-row").length ?? 0, }; })()`); - if (openedPanel.hidden) throw new Error("C6: the tool panel did not open"); + if (!openedPanel.open) throw new Error("C6: the tool modal did not open"); if (openedPanel.head !== toolLabel) throw new Error(`C6: panel header ${openedPanel.head}`); if (openedPanel.close !== "Close tool calls") { throw new Error(`C6: panel close control ${openedPanel.close}`); } - if (openedPanel.chevron !== "Hide tool calls") { - throw new Error(`C6: open chip chevron ${openedPanel.chevron}`); - } if (openedPanel.rows !== toolCount) { throw new Error(`C6: the panel lists ${openedPanel.rows} rows, the chip counts ${toolCount}`); } @@ -5085,7 +5082,7 @@ try { // OUTPUT (the live first call is a settled `read` carrying both). const firstToolRow = await page.evaluate(`(() => { const chip = document.querySelector("#chatTranscript .chat-tool-chip"); - const panel = chip.closest(".chat-tools").querySelector(".chat-tool-panel"); + const panel = document.querySelector(".chat-tools-viewer .chat-tool-panel"); const list = panel.querySelector(".chat-tool-list"); list.scrollTop = 0; const first = () => panel.querySelector(".chat-tool-row-head"); @@ -5126,16 +5123,15 @@ try { // Closing it must put the transcript back exactly where it was. const closedPanel = await page.evaluate(`(() => { const chip = document.querySelector("#chatTranscript .chat-tool-chip"); - const panel = chip.closest(".chat-tools").querySelector(".chat-tool-panel"); - panel.querySelector(".chat-tool-close").click(); + document.querySelector(".chat-tools-viewer .chat-tool-close")?.click(); return { - hidden: panel.hidden, - chevron: chip.querySelector(".chat-tool-chevron").getAttribute("aria-label"), + closed: !document.querySelector(".chat-tools-viewer"), + chevron: chip?.querySelector(".chat-tool-chevron")?.getAttribute("aria-label"), top: Math.round(document.querySelector("#chatTranscript").scrollTop), }; })()`); - if (!closedPanel.hidden || closedPanel.chevron !== "Show tool calls") { - throw new Error(`C6: closing the tool panel: ${JSON.stringify(closedPanel)}`); + if (!closedPanel.closed || closedPanel.chevron !== "Open tool calls") { + throw new Error(`C6: closing the tool modal: ${JSON.stringify(closedPanel)}`); } if (Math.abs(closedPanel.top - scrollBeforePanel) > 2) { throw new Error(`C6: opening/closing the tool panel moved the transcript (${scrollBeforePanel} -> ${closedPanel.top})`);