web: shared chat stars, pipeline mini graphs and agent questions

- Persist chat stars in the operator-session registry (chat_star) so every
  browser/device shows the same Starred group; migrate old local stars once.
- Add a compact pipeline graph shape to list responses and draw a lightweight
  list miniature; replace the cryptic id/version line with the stage count.
- Surface OpenCode form questions as a chat card (chat_answer), replay a
  pending form to late subscribers, and notify for background questions.
- Make the mobile dock's Search cell equal to every destination, keep the
  tab row visible with 100svh, and let Source use the full pane height.
- Let a fresh sign-in auto-connect to its own origin; use a Lax session cookie
  with Expires so Remember me survives app/link launches.
- Keep shipped starters and the skill agnostic: no repository paths, project
  areas or personal device commands; add Diagnose/Fix and Research starters.
- Refresh the installed skill and document the new browser conventions.
This commit is contained in:
2026-10-20 03:11:37 +01:00
parent caae8a8038
commit 526c19fc21
46 changed files with 1547 additions and 611 deletions
+6 -3
View File
@@ -16,9 +16,12 @@ not this one, decides whether a feature is done.
`lists.css`, `run-detail.css`, `chat.css`, `graph.css`, `dialogs.css`,
`settings.css`), the app's dark palette and spacing, real attention to
hierarchy and detail. "Simple" is about the stack, never about the finish.
- **Trusted LAN/VPN only.** The server has no authentication; the page stores
nothing but the server URL in `localStorage`. Never bake in a server address,
never store secrets, never expose the API to an untrusted network.
- **Authenticated proxy, not a public API.** `serve.mjs` gates pages, assets,
artifacts and `/connect` behind a signed session cookie. The Pipelines server
and the agent harness remain unauthenticated control APIs; bind them to
loopback and expose only the authenticated proxy. The browser stores no
credentials. Tests that start their own proxy use
`PIPELINES_WEB_AUTH=disabled`; never run a real service that way.
## Layout
+11
View File
File diff suppressed because one or more lines are too long
+52
View File
@@ -837,3 +837,55 @@
.tok-number { color: #d8b46a; }
.tok-keyword { color: #93add0; font-weight: 600; }
.tok-literal { color: #c58fb0; }
/* The agent's structured question (OpenCode form kind=question): the transcript's
last item while the tool call is paused. Same surface as an approval card, with
an accent hairline and one block per form field. */
.chat-question {
display: flex;
flex-direction: column;
gap: 12px;
padding: 12px;
background: var(--surface-2);
border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
border-radius: var(--radius-card);
}
.chat-question-head { display: grid; gap: 2px; }
.chat-question-title { font-weight: 600; }
.chat-question-status { font-size: 12px; }
.chat-question-field { display: grid; gap: 6px; }
.chat-question-label { font-weight: 600; }
.chat-question-desc { font-size: 12px; }
.chat-question-options { display: grid; gap: 6px; }
.chat-question-option {
display: grid;
gap: 2px;
width: 100%;
padding: 8px 10px;
text-align: left;
border: 1px solid var(--border);
border-radius: var(--radius-control);
background: var(--surface);
color: var(--text);
font: inherit;
cursor: pointer;
}
.chat-question-option:hover { background: var(--surface-2); }
.chat-question-option.selected {
border-color: var(--accent);
background: var(--tint-selected);
}
.chat-question-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chat-question-option-desc { color: var(--muted); font-size: 12px; }
.chat-question-input {
width: 100%;
padding: 8px 10px;
border: 1px solid var(--border);
border-radius: var(--radius-control);
background: var(--bg);
color: var(--text);
font: inherit;
}
.chat-question-error { color: var(--bad); font-size: 12px; }
.chat-question-controls { display: flex; gap: 10px; }
.chat-question-submit { padding: 6px 12px; }
+25 -1
View File
@@ -269,7 +269,7 @@
.version-row { display: flex; gap: 12px; align-items: baseline; border: 1px solid var(--border); border-radius: var(--radius-control); padding: 6px 10px; }
.version-title { font-weight: 600; }
.source-code { margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 12px; overflow: auto; max-height: 60vh; }
.source-code { margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 12px; overflow: auto; }
.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; }
@@ -368,3 +368,27 @@
.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; }
/* The list-row shape cue: the pipeline's route at a glance, without labels. */
.pipeline-mini {
display: block;
width: 100%;
max-width: 260px;
height: 22px;
margin: 3px 0 1px;
color: var(--color-muted);
}
.pipeline-mini-graph { display: block; width: 100%; height: 100%; overflow: visible; }
.pipeline-mini-edge {
fill: none;
stroke: currentColor;
stroke-width: 1.2;
opacity: 0.5;
vector-effect: non-scaling-stroke;
}
.pipeline-mini-node { fill: currentColor; opacity: 0.55; }
.row.selected .pipeline-mini { color: var(--color-accent); }
.row:hover .pipeline-mini { color: var(--color-text); }
@media (prefers-reduced-motion: no-preference) {
.pipeline-mini { transition: color 120ms ease-out; }
}
+9 -2
View File
@@ -114,10 +114,17 @@ function passwordOk(candidate) {
}
function sessionCookie(req, remember = false) {
const bits = [`${SESSION_COOKIE}=${sessionToken(remember)}`, "Path=/", "HttpOnly", "SameSite=Strict"];
// Lax, not Strict: launching the installed app or a link from another app is
// a top-level navigation, and a Strict cookie is withheld on that first
// request, which made a remembered session look forgotten. Lax still keeps
// the cookie off cross-site subresource and POST requests.
const bits = [`${SESSION_COOKIE}=${sessionToken(remember)}`, "Path=/", "HttpOnly", "SameSite=Lax"];
// Remember me persists the cookie; otherwise it is a browser-session cookie
// (and the signed token itself expires after 12 hours).
if (remember) bits.push(`Max-Age=${SESSION_LONG_SECONDS}`);
if (remember) {
const expires = new Date(Date.now() + SESSION_LONG_SECONDS * 1000).toUTCString();
bits.push(`Max-Age=${SESSION_LONG_SECONDS}`, `Expires=${expires}`);
}
// Tailscale terminates TLS and usually forwards the scheme; when it does, the
// cookie is Secure. A direct plain-http LAN visit still works without it.
const forwarded = String(req.headers["x-forwarded-proto"] ?? "").split(",")[0].trim();
+26 -5
View File
@@ -408,8 +408,23 @@ body {
padding: 0 var(--space-xs);
font-size: 11px;
}
.dock-row { display: flex; align-items: stretch; gap: 2px; min-width: 0; }
.dock-tabs { display: flex; flex: 1 1 auto; min-width: 0; gap: 2px; }
/* One equal cell per destination, then one for Search. Subgrid keeps the
tablist a real element (and a real ARIA tablist) while its tabs line up with
the search cell instead of Search taking a whole flex share of its own. */
.dock-row {
display: grid;
grid-template-columns: repeat(var(--dock-count, 1), minmax(0, 1fr)) minmax(0, 1fr);
align-items: stretch;
gap: 2px;
min-width: 0;
}
.dock-tabs {
display: grid;
grid-template-columns: subgrid;
grid-column: 1 / span var(--dock-count, 1);
min-width: 0;
gap: 2px;
}
.dock-item {
position: relative;
@@ -456,18 +471,20 @@ body {
}
.dock-badge[hidden] { display: none; }
.dock-search {
flex: 0 0 56px;
min-width: 0;
min-height: 48px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2px;
padding: 4px 2px;
border: 0;
border-radius: var(--radius-control);
background: transparent;
color: var(--color-muted);
font-size: 11px;
line-height: 14px;
}
.dock-search .icon { width: var(--icon-list); height: var(--icon-list); }
.dock-search[aria-expanded="true"] { background: var(--tint-selected); color: var(--color-text); }
@@ -610,8 +627,12 @@ body {
/* A phone always shows the destination bar; pane collapse is a wide affordance. */
@media (max-width: 599px) {
/* The small viewport is the one that is actually visible while a phone's
browser toolbar is showing. A dynamic-viewport bottom bar can sit under the
toolbar until it hides, leaving only the status row on screen. */
body,
.app-root { height: 100svh; }
#listCollapse { display: none; }
.dock-tabs { flex: 1 1 auto; }
.dock-item,
.dock-search { flex: 1 1 0; width: auto; min-width: 0; }
.dock-search { width: auto; min-width: 0; }
}
+60 -10
View File
@@ -27,7 +27,6 @@ import { SERVER_URL_STORAGE_KEY, readServerUrl, readWorkspace, writeServerUrl }
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";
@@ -179,8 +178,8 @@ const state = {
pipelineGraphExpanded: readGraphExpanded(),
// Gallery or list for run artifacts; a per-operator choice (artifactViewPrefs.js).
artifactView: readArtifactView(),
// Starred chat sessions (chatStars.js): local, always sorted first.
chatStars: readChatStars(),
// Starred chat sessions: filled from chat_sessions (server-shared).
chatStars: new Set(),
// The collapsed rail/list choices (layoutPrefs.js), restored per device.
...readLayoutPrefs(),
// Whether the CLOSED chats group is expanded (the chevron beside its name).
@@ -466,6 +465,7 @@ const railDestinations = h(
),
);
const dockTabs = DESTINATIONS.filter((destination) => destination.key !== "settings");
const dockDestinations = h(
"div",
{
@@ -474,9 +474,7 @@ const dockDestinations = h(
role: "tablist",
"aria-label": "Destinations",
},
...DESTINATIONS.filter((destination) => destination.key !== "settings").map((destination) =>
destinationTab(destination, "dock"),
),
...dockTabs.map((destination) => destinationTab(destination, "dock")),
);
const railSearch = h(
@@ -605,7 +603,9 @@ const dock = h(
h("div", { class: "dock-status-row" }, dockStatus, dockSettings),
// The destinations come first and Search sits on the right; every item takes
// an equal share of the bar on a phone.
h("div", { class: "dock-row" }, dockDestinations, dockSearch),
// One equal share per destination; Search is one more share of the same row,
// so the whole bar divides evenly however many destinations exist.
h("div", { class: "dock-row", style: `--dock-count: ${dockTabs.length}` }, dockDestinations, dockSearch),
);
// The attention sheet lives in its own layer so it can overlay any view without
// being torn down by a content re-render; renderAttentionSheet rebuilds it.
@@ -2431,6 +2431,35 @@ client.addEventListener("state", (event) => {
// transcript (C5) folds the frame itself, and the composer's own bookkeeping
// clears the queued notice and releases the Stop control. A frame for any other
// type is ignored.
/**
* A question raised by an agent chat is as urgent as a failing run: if the page
* is not showing that conversation, raise the browser notification the operator
* already enabled for run alerts. Clicking it opens the chat with the question.
*/
function notifyChatQuestion(frame) {
const form = frame?.form;
if (!form?.id) return;
if (typeof globalThis.Notification !== "function") return;
if (globalThis.isSecureContext !== true || globalThis.Notification.permission !== "granted") return;
if (state.view === "chat" && state.chatActiveId === frame.session_id) return;
const session = state.chatSessions.find((row) => row.id === frame.session_id);
const title = String(session?.title ?? "Chat").trim() || "Chat";
try {
const notification = new Notification(`${title} needs your answer`, {
body: String(form.title ?? "The agent asked a question."),
tag: `chat-question:${form.id}`,
});
notification.onclick = () => {
window.focus();
state.view = "chat";
render();
openChatSession(frame.session_id);
};
} catch {
// The in-page question card remains available.
}
}
client.addEventListener("frame", (event) => {
const message = event.detail;
if (!message) return;
@@ -2465,7 +2494,17 @@ client.addEventListener("frame", (event) => {
}
if (message.type !== Protocol.CHAT_EVENT) return;
const frame = message[ChatKeys.EVENT];
if (frame) onChatEvent(frame);
if (frame) {
if (
frame.kind === "form" &&
frame.form?.kind === "question" &&
frame.form.resolved !== true &&
frame.form.cancelled !== true
) {
notifyChatQuestion(frame);
}
onChatEvent(frame);
}
onChatFrame(message);
});
@@ -2560,5 +2599,16 @@ window.addEventListener("resize", () => {
}, 120);
});
// A previously configured endpoint re-opens on load (see bootServerUrl).
if (bootServerUrl) openConfiguredEndpoint({ surfaceError: false });
// A previously configured endpoint re-opens on load (see bootServerUrl). When
// nothing is stored, the page's own origin is the supported default proxy: use
// it instead of leaving a freshly signed-in device on a "Not configured" screen
// and making the operator find the same URL in Settings.
if (bootServerUrl) {
openConfiguredEndpoint({ surfaceError: false });
} else {
const sameOrigin = defaultServerUrl();
if (validateServerUrl(sameOrigin).valid) {
state.url = sameOrigin;
openConfiguredEndpoint({ surfaceError: false });
}
}
+16 -2
View File
@@ -94,7 +94,7 @@ export function attentionBadgeLabel(count) {
* An entry the operator explicitly dismissed never returns. A run status that
* asks nobody is dropped, so the surface can only ever hold actionable work.
*/
export function attentionEntries(runs, dismissed) {
export function attentionEntries(runs, dismissed, { since = 0 } = {}) {
const dismissedKeys =
dismissed instanceof Set ? dismissed : new Set(Array.isArray(dismissed) ? dismissed : []);
return (runs ?? [])
@@ -105,13 +105,16 @@ export function attentionEntries(runs, dismissed) {
if (dismissedKeys.has(key)) return null;
const title = String(run.title ?? "").trim();
const finished = String(run.finished_at ?? "");
const recency = finished.trim() !== "" ? finished : String(run.created_at ?? "");
const at = Date.parse(recency);
if (since > 0 && Number.isFinite(at) && at < since) return null;
return {
runId: run.id,
pipeline: String(run.name ?? ""),
label: title !== "" ? title : String(run.name ?? ""),
kind,
detail: attentionDetail(kind, run),
recency: finished.trim() !== "" ? finished : String(run.created_at ?? ""),
recency,
key,
};
})
@@ -124,6 +127,17 @@ export function attentionEntries(runs, dismissed) {
);
}
/**
* The start of the operator's local day in epoch ms. "Needs you" is a to-do list
* for what changed now; yesterday's failures are history, not a badge that
* follows every device and browser session for ever.
*/
export function startOfLocalDay(now = Date.now()) {
const date = new Date(now);
date.setHours(0, 0, 0, 0);
return date.getTime();
}
/**
* Captures the entries shown when the sheet opens. Bulk dismissal uses this
* snapshot so entries that arrive while the sheet is open are not removed. A
+31
View File
@@ -1133,6 +1133,7 @@ export const EVENT_STEP = "step";
export const EVENT_USAGE = "usage";
export const EVENT_USER = "user";
export const EVENT_SHELL = "shell";
export const EVENT_FORM = "form";
/** ChatStep.Status values. `ended` is the one status that settles a turn. */
export const STEP_ENDED = "ended";
@@ -1324,6 +1325,9 @@ export function newChatThread(sessionId = "") {
// derive from the two (see `approvalCard`).
permission: null,
permissionAnswer: "",
// The agent's pending structured question/form (OpenCode form.created). The
// card is derived from this frame; answers are local until submitted.
form: null,
// The reason a refused `chat_reply` left on the thread's error line, kept
// apart from any other error so a later accepted answer clears only this one.
permissionError: "",
@@ -1487,6 +1491,31 @@ export function threadPhase(thread, nowMillis) {
return turnPhase(threadRunningTools(thread.messages));
}
/**
* Folds one form frame into a conversation. A new form replaces the previous
* one; a resolved/cancelled update clears it; an update for a different id is
* ignored rather than reviving a dismissed card. The form is kept as data so the
* question card and every other client derive the same state.
*/
export function applyChatForm(thread, form) {
const current = thread ?? newChatThread(str(form?.session_id));
const id = str(form?.id);
if (id === "") return current;
const existing = current.form ?? null;
if (form?.cancelled === true) {
if (str(existing?.id) !== id) return current;
return { ...current, form: null };
}
if (form?.resolved === true) {
if (str(existing?.id) !== id) return current;
return { ...current, form: { ...existing, ...form, resolved: true } };
}
if (str(existing?.id) === id) {
return { ...current, form: { ...existing, ...form } };
}
return { ...current, form };
}
/**
* Applies one pushed `chat_event` frame to a conversation and returns the next
* thread. Any frame clears `queued` (the turn moved on); `user` echoes another
@@ -1515,6 +1544,8 @@ export function applyChatEvent(thread, frame, now = Date.now()) {
// that outlives the turn keeps showing after the turn's own indicator is gone.
case EVENT_SHELL:
return { ...current, shells: mergeShellFrame(current.shells, frame?.shell) };
case EVENT_FORM:
return applyChatForm(current, frame?.form);
// `usage` is recognised but not folded; it still cleared `queued` above.
case EVENT_USAGE:
default:
+3
View File
@@ -60,6 +60,7 @@ export const Protocol = Object.freeze({
CHAT_MESSAGES: "chat_messages",
CHAT_CLOSE: "chat_close",
CHAT_REOPEN: "chat_reopen",
CHAT_STAR: "chat_star",
// The shared live stream (C5). `chat_subscribe` attaches this connection to one
// session's stream (body: the session id); the server then pushes `chat_event`
// frames without a matching request id, so every client watching a session sees
@@ -67,6 +68,7 @@ export const Protocol = Object.freeze({
// detaches a subscription when the connection closes.
CHAT_SUBSCRIBE: "chat_subscribe",
CHAT_EVENT: "chat_event",
CHAT_ANSWER: "chat_answer",
// The composer's own commands (C8/C9). `chat_prompt` carries its body in
// `chat_prompt` (`{session_id,text,files?,operation_id}`) and its reply echoes
// `chat_queued` when the prompt waits behind an in-flight turn; `chat_interrupt`
@@ -111,6 +113,7 @@ export const ChatKeys = Object.freeze({
// unsolicited pushed frame on the shared stream).
SUBSCRIBE: "chat_subscribe",
EVENT: "chat_event",
ANSWER: "chat_answer",
// The composer's payloads (C8/C9). `chat_interrupt` deliberately has no key of
// its own: its body is the same `chat_query` the other session-scoped commands
// carry (internal/protocol/chat.go ChatQuery, Chat.kt interruptRequest), so a
+24
View File
@@ -347,6 +347,30 @@ export class PipelinesRepository {
return { session: response[ChatKeys.SESSION] ?? null, close: response[ChatKeys.CLOSE] ?? null };
}
/**
* Records the shared star on the server (chat_star), so every browser and
* device lists the same Starred group. Returns the updated session row.
*/
async starChat(sessionId, starred) {
const response = await this.#client.call({
type: Protocol.CHAT_STAR,
[ChatKeys.QUERY]: { session_id: sessionId, starred: Boolean(starred) },
});
return response[ChatKeys.SESSION] ?? null;
}
/**
* Answers one OpenCode form (the question tool's form). Answers is keyed by
* the form field key; the server forwards it to the paused tool call and the
* resolved form arrives on the normal chat_event stream.
*/
async answerChatForm(sessionId, formId, answers) {
return this.#client.call({
type: Protocol.CHAT_ANSWER,
[ChatKeys.ANSWER]: { session_id: sessionId, form_id: formId, answers },
});
}
/** Clears the closed state again, so a finished chat can be resumed. */
async reopenChat(sessionId) {
const response = await this.#client.call({
+4 -3
View File
@@ -12,6 +12,7 @@ import {
attentionDismissalSnapshot,
attentionEntries,
attentionRowDescription,
startOfLocalDay,
decodeAttentionDismissals,
encodeAttentionDismissals,
} from "../attention.js";
@@ -100,7 +101,7 @@ function renderAttentionBell() {
/** The number of entries the attention surface currently holds. */
function attentionCount() {
return attentionEntries(state.runs, state.attentionDismissed).length;
return attentionEntries(state.runs, state.attentionDismissed, { since: startOfLocalDay() }).length;
}
/**
@@ -154,7 +155,7 @@ function renderAttentionSheet() {
modal.close("attention-sheet");
return;
}
const entries = attentionEntries(state.runs, state.attentionDismissed);
const entries = attentionEntries(state.runs, state.attentionDismissed, { since: startOfLocalDay() });
const overlay = h("div", {
class: "attention-sheet",
role: "dialog",
@@ -259,7 +260,7 @@ function renderAttentionRow(entry, labelCounts = null) {
function openAttentionSheet() {
state.attentionSheetOpen = true;
state.attentionSnapshot = attentionDismissalSnapshot(
attentionEntries(state.runs, state.attentionDismissed),
attentionEntries(state.runs, state.attentionDismissed, { since: startOfLocalDay() }),
);
render();
}
+199 -12
View File
@@ -4,7 +4,7 @@
// in chat.js and markdown.js; this module owns the DOM and the chat wire wiring.
import { h } from "../dom.js";
import { writeChatStars } from "../chatStars.js";
import { readChatStars, writeChatStars } from "../chatStars.js";
import { describeError } from "../format.js";
import { SHELL_OUTPUT_LIMIT, newChatOperationId } from "../repository.js";
import { codeBlockLabel, parseInline, parseMarkdown } from "../markdown.js";
@@ -371,6 +371,23 @@ async function loadChatSessions(force = false) {
renderContent();
try {
const listed = await repo.chatSessions();
// One-time migration from the old local-only stars: upload this device's
// saved set, then let the server's shared set be authoritative everywhere.
const localStars = readChatStars();
if (localStars.size) {
for (const id of localStars) {
const session = listed.find((entry) => entry.id === id);
if (!session || session.starred) continue;
try {
const updated = await repo.starChat(id, true);
if (updated) Object.assign(session, updated);
} catch {
// Keep going: a missing session or a transient failure must not block
// the rest of the list.
}
}
writeChatStars(new Set());
}
// Keep this page's own verification chats, which the server intentionally
// never returns, at the head of the in-memory list (memory-only; see
// chatEphemeralIds). Everything else is the server's list, in its order.
@@ -379,6 +396,7 @@ async function loadChatSessions(force = false) {
state.chatEphemeralIds.has(session.id) && !listed.some((entry) => entry.id === session.id),
);
state.chatSessions = [...held, ...listed];
syncChatStarsFromSessions();
state.chatLoaded = true;
rt.touchView?.("chat");
// Fold this device's seen state in: the active chat has been read, and every
@@ -670,6 +688,26 @@ async function answerPermission(sessionId, requestId, decision) {
}
}
/**
* Answer the agent's pending question. The answer map is keyed by the form
* field's own key and mirrors OpenCode's form.reply body; the resolved form
* arrives on the stream and clears the card for every watching client.
*/
async function answerChatQuestion(sessionId, form, answers) {
if (!form?.id) return;
try {
await repo.answerChatForm(sessionId, form.id, answers);
const current = state.chatThreads.get(sessionId);
if (current?.form && current.form.id === form.id) {
setThread(sessionId, { form: { ...current.form, resolved: true } });
}
renderContent();
} catch (error) {
state.actionError = describeError(error);
renderContent();
}
}
/**
* The reconnect repair (C5): re-attach the open chat's stream and replace its
* conversation with the newest history page wholesale. Everything the gap could
@@ -884,10 +922,17 @@ async function reopenChatSession(id) {
}
/** Apply the echoed session (or the local closed flag) to the held row. */
function syncChatStarsFromSessions(sessions = state.chatSessions) {
state.chatStars = new Set(
(sessions ?? []).filter((session) => session.starred === true).map((session) => session.id),
);
}
function applyChatSessionUpdate(id, updated, closed) {
state.chatSessions = state.chatSessions.map((session) =>
session.id === id ? { ...session, ...(updated ?? {}), closed } : session,
);
syncChatStarsFromSessions();
}
// ---------------------------------------------------------------------------
@@ -1596,13 +1641,24 @@ function chatEmpty(message) {
return h("div", { class: "empty" }, h("span", { class: "muted", text: message }));
}
/** Toggle one session's local star, then repaint the list in its new order. */
function toggleChatStar(id) {
const next = new Set(state.chatStars ?? []);
if (next.has(id)) next.delete(id);
else next.add(id);
state.chatStars = next;
writeChatStars(next);
/** Toggle one session's shared star on the server, then repaint its group. */
async function toggleChatStar(id) {
const wasStarred = state.chatStars?.has?.(id) === true;
state.chatSessions = state.chatSessions.map((session) =>
session.id === id ? { ...session, starred: !wasStarred } : session,
);
syncChatStarsFromSessions();
renderContent();
try {
const updated = await repo.starChat(id, !wasStarred);
if (updated) applyChatSessionUpdate(id, updated, updated.closed === true);
} catch (error) {
state.chatSessions = state.chatSessions.map((session) =>
session.id === id ? { ...session, starred: wasStarred } : session,
);
syncChatStarsFromSessions();
state.actionError = describeError(error);
}
renderContent();
}
@@ -1891,7 +1947,11 @@ function renderChatConversation() {
// answer. While it is actionable the chat pane offers a jump control and the
// running indicator stands down (a turn blocked on a decision is not generating).
const approval = approvalCard(thread?.permission, thread?.permissionAnswer);
const awaiting = approval?.actionable === true;
const form =
thread?.form && thread.form.resolved !== true && thread.form.cancelled !== true
? thread.form
: null;
const awaiting = approval?.actionable === true || form != null;
const bar = h("div", { class: "chat-bar" });
const titles = h("div", { class: "chat-bar-titles" });
@@ -1942,11 +2002,11 @@ function renderChatConversation() {
// blocked on a decision is not generating, so neither the spinner nor its clock
// shows. The composer's Stop control stays governed by thread.running.
const running = thread?.running === true && !awaiting;
if (rows.length === 0 && notices.length === 0 && !running && !approval) {
if (rows.length === 0 && notices.length === 0 && !running && !approval && !form) {
pane.append(h("div", { class: "chat-transcript-empty muted", text: CONVERSATION_EMPTY }));
} else {
pane.append(
renderChatTranscript(state.chatActiveId, rows, { notices, running, now: Date.now(), approval }),
renderChatTranscript(state.chatActiveId, rows, { notices, running, now: Date.now(), approval, form }),
);
}
if (thread?.error && thread?.loaded) {
@@ -2187,7 +2247,7 @@ function renderBackgroundTaskDetail(thread, shell) {
function renderChatTranscript(
sessionId,
rows,
{ notices = [], running = false, now = Date.now(), approval = null } = {},
{ notices = [], running = false, now = Date.now(), approval = null, form = null } = {},
) {
const wrap = h("div", { class: "chat-transcript-wrap" });
const transcript = h("div", {
@@ -2219,6 +2279,7 @@ function renderChatTranscript(
// after the running indicator when it is shown — so the pane's jump control
// and a fresh card both land at the end.
if (approval) transcript.append(renderChatApproval(sessionId, approval));
if (form) transcript.append(renderChatQuestion(sessionId, form));
wrap.append(transcript);
wrap.append(
h("button", {
@@ -2303,6 +2364,132 @@ function renderChatApproval(sessionId, card) {
return node;
}
/**
* The agent's structured question (OpenCode form with kind=question). Each form
* field is rendered with its options (single-select buttons or multi-select
* toggles) and, when the field is free-form or allows Other, a text input.
* Answers stay local until Send answer; the tool call is paused until then.
*/
function renderChatQuestion(sessionId, form) {
const node = h("div", {
class: "chat-question",
id: "chatQuestion",
"data-form-id": form.id,
});
const head = h("div", { class: "chat-question-head" });
head.append(h("div", { class: "chat-question-title", text: form.title || "Question" }));
head.append(
h("div", { class: "chat-question-status muted", text: "The agent is waiting for your answer." }),
);
node.append(head);
const answers = {};
const parts = [];
for (const field of form.fields ?? []) {
const key = String(field.key ?? "");
if (key === "") continue;
const options = Array.isArray(field.options) ? field.options : [];
const multi = field.type === "multiselect";
const part = h("div", { class: "chat-question-field" });
part.append(
h("div", { class: "chat-question-label", text: field.title || field.description || key }),
);
if (field.description && field.description !== field.title) {
part.append(h("div", { class: "chat-question-desc muted", text: field.description }));
}
if (options.length) {
const rows = h("div", { class: "chat-question-options" });
const buttons = [];
const chosen = () => (multi ? (Array.isArray(answers[key]) ? answers[key] : []) : [answers[key]].filter(Boolean));
const paint = () => {
const selected = new Set(chosen());
for (const button of buttons) {
const on = selected.has(button.dataset.value);
button.classList.toggle("selected", on);
button.setAttribute("aria-pressed", on ? "true" : "false");
}
};
for (const option of options) {
const value = String(option.value ?? option.label ?? "");
if (value === "") continue;
const button = h(
"button",
{
class: "chat-question-option",
type: "button",
"data-value": value,
"aria-pressed": "false",
text: option.label || value,
},
option.description
? h("span", { class: "chat-question-option-desc", text: option.description })
: null,
);
button.addEventListener("click", () => {
if (multi) {
const next = new Set(chosen());
if (next.has(value)) next.delete(value);
else next.add(value);
answers[key] = [...next];
} else {
answers[key] = value;
}
paint();
});
buttons.push(button);
rows.append(button);
}
part.append(rows);
}
if (field.custom === true || options.length === 0) {
const input = h("input", {
class: "chat-question-input",
type: "text",
placeholder: options.length ? "Type another answer" : "Your answer",
autocomplete: "off",
});
input.addEventListener("input", () => {
const value = input.value.trim();
if (value === "") delete answers[key];
else answers[key] = value;
});
part.append(input);
}
parts.push(part);
}
node.append(...parts);
const error = h("div", { class: "chat-question-error", role: "alert", hidden: true });
node.append(error);
const controls = h("div", { class: "chat-question-controls" });
const submit = h("button", {
class: "primary chat-question-submit",
type: "button",
text: "Send answer",
});
let sent = false;
submit.addEventListener("click", () => {
if (sent) return;
const missing = (form.fields ?? []).some((field) => {
if (!field.required) return false;
const value = answers[field.key];
return Array.isArray(value) ? value.length === 0 : !value;
});
if (missing) {
error.hidden = false;
error.textContent = "Answer the required questions before sending.";
return;
}
sent = true;
submit.disabled = true;
submit.textContent = "Sending…";
answerChatQuestion(sessionId, form, answers);
});
controls.append(submit);
node.append(controls);
return node;
}
/**
* The app's amber outlined Shield (`Icons.Outlined.Shield`): an inline SVG stroked
* with `currentColor` so the palette's warn hue actually tints it, unlike the
+73 -2
View File
@@ -20,10 +20,11 @@ import {
runBadge,
runBadgeMetaLine,
sortPipelines,
stageCountText,
summaryFields,
versionRow,
} from "../pipelines.js";
import { PIPELINE_GRAPH_EMPTY, mount as mountGraph } from "../graph.js";
import { PIPELINE_GRAPH_EMPTY, layoutGraph, mount as mountGraph } from "../graph.js";
import { statusIcon } from "../statusIcon.js";
import { writeGraphExpanded } from "../graphPrefs.js";
@@ -236,6 +237,69 @@ function fillPipelineRows(rowsEl) {
rowsEl.replaceChildren(...nodes);
}
// A list row's graph is a shape cue, not a reading surface: tiny nodes and
// straight routes, no labels or chips. The detail Graph tab is the real one.
const MINI_GRAPH_METRICS = Object.freeze({
nodeWidth: 26,
nodeHeight: 12,
hGap: 12,
pad: 2,
laneSpacing: 8,
terminalGap: 8,
trackStep: 6,
portSpacing: 4,
labelCharWidth: 0,
labelPadding: 0,
labelHeight: 0,
labelGap: 0,
});
const SVG_NS = "http://www.w3.org/2000/svg";
/** The pipeline's stages and their stage-to-stage routes, without terminals. */
function miniGraphShape(graph) {
const stages = graph?.stages ?? [];
const keys = new Set(stages.map((stage) => stage.key));
return {
stages: stages.map((stage) => ({
...stage,
edges: Object.fromEntries(
Object.entries(stage.edges ?? {}).filter(([, target]) => keys.has(target)),
),
})),
};
}
function renderPipelineMiniGraph(pipeline) {
const shape = pipeline.shape ?? pipeline.graph;
if (!shape?.stages?.length) return null;
const layout = layoutGraph(miniGraphShape(shape), MINI_GRAPH_METRICS);
if (!layout.nodes.length || !layout.width || !layout.height) return null;
const svg = document.createElementNS(SVG_NS, "svg");
svg.setAttribute("class", "pipeline-mini-graph");
svg.setAttribute("viewBox", `0 0 ${Math.ceil(layout.width)} ${Math.ceil(layout.height)}`);
svg.setAttribute("preserveAspectRatio", "xMidYMid meet");
svg.setAttribute("aria-hidden", "true");
svg.setAttribute("focusable", "false");
for (const edge of layout.edges) {
if (edge.points.length < 2) continue;
const line = document.createElementNS(SVG_NS, "polyline");
line.setAttribute("class", "pipeline-mini-edge");
line.setAttribute("points", edge.points.map((point) => `${point.x},${point.y}`).join(" "));
svg.append(line);
}
for (const node of layout.nodes) {
const rect = document.createElementNS(SVG_NS, "rect");
rect.setAttribute("class", "pipeline-mini-node");
rect.setAttribute("x", String(node.x));
rect.setAttribute("y", String(node.y));
rect.setAttribute("width", String(node.width));
rect.setAttribute("height", String(node.height));
rect.setAttribute("rx", "3");
svg.append(rect);
}
return h("span", { class: "pipeline-mini", "aria-hidden": "true" }, svg);
}
function renderPipelineRow(pipeline, latestRuns, runsKnown, now) {
const children = [
h(
@@ -244,8 +308,15 @@ function renderPipelineRow(pipeline, latestRuns, runsKnown, now) {
pipelineGlyph(),
h("span", { class: "row-title", text: pipeline.name || `pipeline ${pipeline.id}` }),
),
h("span", { class: "row-meta", text: pipelineSubtitle(pipeline) }),
];
const mini = renderPipelineMiniGraph(pipeline);
if (mini) children.push(mini);
children.push(
h("span", {
class: "row-meta",
text: stageCountText(pipeline.stages ?? pipeline.shape?.stages?.length ?? 0),
}),
);
const updated = pipelineUpdatedLine(pipeline);
if (updated) children.push(h("span", { class: "row-meta", text: updated }));
if (runsKnown) {
+22
View File
@@ -13,6 +13,7 @@ import {
attentionDismissAll,
attentionDismissalSnapshot,
attentionEntries,
startOfLocalDay,
attentionKey,
attentionKindOf,
attentionRowDescription,
@@ -108,6 +109,27 @@ test("row description is exactly {pipeline} · {detail}", () => {
assert.equal(attentionRowDescription(entry), "Plan and land · failed hard");
});
test("the surface is today's work: older failures are history", () => {
const entries = [
run({ id: 1, status: "failed", finished_at: "2026-10-19T21:33:27Z" }),
run({ id: 2, status: "failed", finished_at: "2026-10-20T10:00:00Z" }),
];
const since = Date.parse("2026-10-20T00:00:00Z");
assert.deepEqual(
attentionEntries(entries, new Set(), { since }).map((entry) => entry.runId),
[2],
);
assert.equal(attentionEntries(entries, new Set()).length, 2);
});
test("startOfLocalDay is local midnight", () => {
const now = new Date(2026, 9, 20, 15, 4, 5).getTime();
const start = startOfLocalDay(now);
assert.equal(new Date(start).getHours(), 0);
assert.equal(new Date(start).getMinutes(), 0);
assert.ok(start < now);
});
test("badge label is bare Notifications when empty, else the count", () => {
assert.equal(attentionBadgeLabel(0), "Notifications");
assert.equal(attentionBadgeLabel(-3), "Notifications");
+19
View File
@@ -69,6 +69,7 @@ import {
TURN_PHASE_WAITING,
appendChatNotice,
applyChatEvent,
applyChatForm,
applyChatOverrides,
applyChatPermission,
approvalCard,
@@ -1939,3 +1940,21 @@ test("the C13 wording matches the Android sources verbatim", () => {
assert.equal(sessionActivityBadge(sessionActivity(false, false), true), "Open");
assert.equal(sessionActivityBadge(sessionActivity(false, false), false), "Idle");
});
test("applyChatForm keeps one pending question and clears it on resolve", () => {
const form = { id: "f1", session_id: "s1", kind: "question", title: "Pick", fields: [] };
let thread = newChatThread("s1");
thread = applyChatEvent(thread, { kind: "form", session_id: "s1", form }, 1);
assert.equal(thread.form?.id, "f1");
assert.equal(thread.form?.title, "Pick");
// A different form replaces the card; the old id cannot revive.
thread = applyChatForm(thread, { id: "f2", session_id: "s1", title: "Next" });
assert.equal(thread.form?.id, "f2");
thread = applyChatForm(thread, { id: "f1", session_id: "s1", resolved: true });
assert.equal(thread.form?.id, "f2");
thread = applyChatForm(thread, { id: "f2", session_id: "s1", resolved: true });
assert.equal(thread.form?.id, "f2");
assert.equal(thread.form?.resolved, true);
thread = applyChatForm(thread, { id: "f2", session_id: "s1", cancelled: true });
assert.equal(thread.form, null);
});
+139 -248
View File
@@ -2627,261 +2627,169 @@ try {
};
})()`);
const attentionCount = Number(bell.dataCount ?? 0);
if (!(attentionCount > 0)) {
throw new Error(`no attention entries on the live server: ${JSON.stringify(bell)}`);
}
if (bell.label !== `Notifications, ${attentionCount} needing attention`) {
const expectedLabel =
attentionCount > 0 ? `Notifications, ${attentionCount} needing attention` : "Notifications";
if (bell.label !== expectedLabel) {
throw new Error(`the bell's accessible name is wrong: ${bell.label}`);
}
if (!bell.hasBadge || bell.count !== String(attentionCount)) {
if (attentionCount > 0 && (!bell.hasBadge || bell.count !== String(attentionCount))) {
throw new Error(`the badge is wrong: ${JSON.stringify(bell)}`);
}
if (attentionCount === 0 && bell.hasBadge) {
throw new Error(`a zero-count bell still has a badge: ${JSON.stringify(bell)}`);
}
if (await page.evaluate(`!!document.querySelector(".attention-sheet")`)) {
throw new Error("the sheet was already open before the bell was clicked");
}
console.log(` bell: aria-label="${bell.label}", badge=${bell.count}`);
console.log(
attentionCount > 0
? ` bell: aria-label="${bell.label}", badge=${bell.count}`
: " bell: no current attention entries; asserting the zero state",
);
shots.push(await page.screenshot(`${out}/35-attention-bell.png`));
step("checking the bell's monochrome SVG glyph and the badge's layout isolation");
const countProbe = await attentionBellProbe();
assertAttentionBellGlyph(countProbe, attentionCount, "wide bell with a count");
const wideShift = assertAttentionBellBadgeShift(
await attentionBellBadgeShift(),
"wide bell with a count",
);
console.log(
` glyph: <${countProbe.tagName} viewBox="${countProbe.viewBox}"> with ${countProbe.pathCount} ` +
`unfilled currentColor paths at ${countProbe.width}×${countProbe.height}; ` +
`badge "${countProbe.badge.text}" (${countProbe.badge.position})`,
);
console.log(
` no-shift with the badge hidden: bell ${wideShift.bellDelta}px, ` +
`Runs title ${wideShift.titleDelta}px`,
);
assertAttentionBellGlyph(countProbe, attentionCount, "wide bell");
step("checking the bell at 420x900");
await page.resize(420, 900);
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === false`), {
what: "the narrow layout at 420px",
});
await settle(200);
const narrowProbe = await attentionBellProbe();
assertAttentionBellGlyph(narrowProbe, attentionCount, "narrow bell with a count");
const narrowShift = assertAttentionBellBadgeShift(
await attentionBellBadgeShift(),
"narrow bell with a count",
);
shots.push(await page.screenshot(`${out}/35a-attention-bell-narrow-420x900.png`));
console.log(
` narrow: ${narrowProbe.width}×${narrowProbe.height} glyph, badge ` +
`"${narrowProbe.badge.text}" (${narrowProbe.badge.position}); no-shift bell ` +
`${narrowShift.bellDelta}px, Runs title ${narrowShift.titleDelta}px`,
);
await page.resize(1440, 900);
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === true`), {
what: "the wide layout back at 1440px",
});
await settle(200);
if (attentionCount > 0) {
step("checking the bell's monochrome SVG glyph and the badge's layout isolation");
const wideShift = assertAttentionBellBadgeShift(
await attentionBellBadgeShift(),
"wide bell with a count",
);
console.log(
` glyph: <${countProbe.tagName} viewBox="${countProbe.viewBox}"> with ${countProbe.pathCount} ` +
`unfilled currentColor paths at ${countProbe.width}×${countProbe.height}; ` +
`badge "${countProbe.badge.text}" (${countProbe.badge.position})`,
);
console.log(
` no-shift with the badge hidden: bell ${wideShift.bellDelta}px, ` +
`Runs title ${wideShift.titleDelta}px`,
);
step("opening the Needs you sheet");
await page.click("#attentionBell");
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
const sheet = await page.evaluate(`(() => {
const rows = [...document.querySelectorAll(".attention-sheet .attention-row")];
return {
step("checking the bell at 420x900");
await page.resize(420, 900);
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === false`), {
what: "the narrow layout at 420px",
});
await settle(200);
const narrowProbe = await attentionBellProbe();
assertAttentionBellGlyph(narrowProbe, attentionCount, "narrow bell with a count");
assertAttentionBellBadgeShift(await attentionBellBadgeShift(), "narrow bell with a count");
shots.push(await page.screenshot(`${out}/35a-attention-bell-narrow-420x900.png`));
await page.resize(1440, 900);
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === true`), {
what: "the wide layout back at 1440px",
});
await settle(200);
step("opening the Needs you sheet");
await page.click("#attentionBell");
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
const sheet = await page.evaluate(`(() => ({
title: document.querySelector(".attention-sheet-title")?.textContent ?? "",
clearAll: document.querySelector(".attention-clear")?.textContent ?? null,
empty: document.querySelector(".attention-empty")?.textContent ?? null,
focused: document.activeElement?.className ?? "",
rows: rows.map((row) => {
const open = row.querySelector(".attention-row-open");
const dismiss = row.querySelector(".attention-dismiss");
return {
runId: Number(open?.dataset.runId),
kind: open?.dataset.kind ?? "",
label: open?.querySelector(".attention-label")?.textContent ?? "",
desc: open?.querySelector(".attention-desc")?.textContent ?? "",
icon: open?.querySelector(".attention-icon")?.textContent ?? "",
dismissName: dismiss?.getAttribute("aria-label") ?? "",
};
}),
};
})()`);
if (sheet.title !== "Needs you") throw new Error(`the sheet title is wrong: ${sheet.title}`);
if (sheet.empty !== null) throw new Error(`a non-empty sheet showed the empty copy: ${sheet.empty}`);
if (sheet.clearAll !== "Clear all") throw new Error(`Clear all is missing: ${sheet.clearAll}`);
if (sheet.rows.length !== attentionCount) {
throw new Error(`the sheet drew ${sheet.rows.length} rows for a badge of ${attentionCount}`);
}
if (!sheet.focused.includes("attention-sheet-close")) {
throw new Error(`focus did not move into the sheet on open: ${sheet.focused}`);
}
const kindRanks = { decision: 0, failed: 1 };
let lastKindRank = -1;
for (const row of sheet.rows) {
if (!row.icon) throw new Error(`row ${row.runId} has no status icon`);
if (!row.label) throw new Error(`row ${row.runId} has no primary label`);
if (!row.desc.includes(" · ")) throw new Error(`row ${row.runId} description is wrong: ${row.desc}`);
// The dismiss control is named for the row it clears (L7 M6), e.g.
// `Dismiss Web: live decision confirm (R11)`; the run id appears only for a
// repeated label, so assert the shared prefix rather than the old bare word.
if (!row.dismissName.startsWith("Dismiss ")) {
throw new Error(`row ${row.runId}'s trailing control is not named Dismiss: ${row.dismissName}`);
rows: [...document.querySelectorAll(".attention-sheet .attention-row")].map((row) => ({
runId: Number(row.querySelector(".attention-row-open")?.dataset.runId),
kind: row.querySelector(".attention-row-open")?.dataset.kind ?? "",
label: row.querySelector(".attention-label")?.textContent ?? "",
desc: row.querySelector(".attention-desc")?.textContent ?? "",
dismissName: row.querySelector(".attention-dismiss")?.getAttribute("aria-label") ?? "",
})),
}))()`);
if (sheet.title !== "Needs you") throw new Error(`the sheet title is wrong: ${sheet.title}`);
if (sheet.empty !== null) throw new Error(`a non-empty sheet showed the empty copy: ${sheet.empty}`);
if (sheet.clearAll !== "Clear all") throw new Error(`Clear all is missing: ${sheet.clearAll}`);
if (sheet.rows.length !== attentionCount) {
throw new Error(`the sheet drew ${sheet.rows.length} rows for a badge of ${attentionCount}`);
}
const rank = kindRanks[row.kind];
if (rank == null) throw new Error(`row ${row.runId} has an unknown kind ${row.kind}`);
if (rank < lastKindRank) throw new Error(`the rows are out of kind order at run ${row.runId}`);
lastKindRank = rank;
}
const firstRow = sheet.rows[0];
const kindName = (kind) => (kind === "decision" ? "Decision" : "Failed");
console.log(
` sheet: ${sheet.rows.length} row(s); first ${firstRow.runId} (${firstRow.kind}) ` +
`"${firstRow.label}" — ${firstRow.desc}`,
);
if (!sheet.rows.some((row) => row.kind === "decision")) {
console.log(
" -- no `waiting` run exists on the live server; the sheet used real failed runs " +
"and the decision path (open without dismissing) is covered by unit tests",
);
}
shots.push(await page.screenshot(`${out}/36-attention-sheet.png`));
if (!sheet.focused.includes("attention-sheet-close")) {
throw new Error(`focus did not move into the sheet on open: ${sheet.focused}`);
}
for (const row of sheet.rows) {
if (!row.label || !row.desc.includes(" · ")) {
throw new Error(`row ${row.runId} is missing its label or description: ${JSON.stringify(row)}`);
}
if (!row.dismissName.startsWith("Dismiss ")) {
throw new Error(`row ${row.runId}'s trailing control is not named Dismiss: ${row.dismissName}`);
}
}
console.log(` sheet: ${sheet.rows.length} row(s); first ${sheet.rows[0].runId} (${sheet.rows[0].kind})`);
shots.push(await page.screenshot(`${out}/36-attention-sheet.png`));
step("dismissing one entry individually");
await page.evaluate(`document.querySelector(".attention-sheet .attention-row .attention-dismiss").click()`);
await eventually(
async () =>
(await page.evaluate(`document.querySelectorAll(".attention-sheet .attention-row").length`)) ===
attentionCount - 1,
{ what: "the individual dismissal to land" },
);
const afterDismiss = await page.evaluate(`(() => ({
rows: document.querySelectorAll(".attention-sheet .attention-row").length,
badge: document.querySelector("#attentionBell .attention-badge")?.dataset.count ?? null,
svg: !!document.querySelector("#attentionBell > svg.attention-bell-icon"),
pathCount: document.querySelectorAll("#attentionBell > svg.attention-bell-icon path").length,
stored: localStorage.getItem("pipelines.web.attention.v1"),
}))()`);
if (afterDismiss.rows !== attentionCount - 1) {
throw new Error(`the sheet still shows ${afterDismiss.rows} rows after one dismissal`);
}
if (Number(afterDismiss.badge) !== attentionCount - 1) {
throw new Error(`the badge did not follow the dismissal: ${afterDismiss.badge}`);
}
if (!afterDismiss.svg || afterDismiss.pathCount !== countProbe.pathCount) {
throw new Error(
`the in-place badge refresh rebuilt the glyph: ${JSON.stringify(afterDismiss)}`,
);
}
if (!String(afterDismiss.stored).includes(`${firstRow.runId}:${kindName(firstRow.kind)}`)) {
throw new Error(`the dismissed identity was not persisted: ${afterDismiss.stored}`);
}
console.log(
` dismissed ${firstRow.runId}:${kindName(firstRow.kind)}; rows ${attentionCount} -> ` +
`${afterDismiss.rows}, stored ${afterDismiss.stored}`,
);
shots.push(await page.screenshot(`${out}/37-attention-dismissed.png`));
step("opening a Failed row: it opens the run and persists its dismissal");
const rowToOpen = await page.evaluate(`(() => {
const open = document.querySelector(".attention-sheet .attention-row .attention-row-open");
if (!open) return null;
return { runId: Number(open.dataset.runId), kind: open.dataset.kind };
})()`);
if (!rowToOpen) {
// The history may hold a single attention entry (for example a fresh database
// where only the current run has failed); the dismissal above then emptied it.
console.log(" -- no remaining attention row to open; the row-activated path is unit-tested");
} else if (rowToOpen.kind !== "failed") {
console.log(` -- the remaining row is ${rowToOpen.kind}, not Failed; skipped the open check`);
} else {
await page.evaluate(`document.querySelector(".attention-sheet .attention-row .attention-row-open").click()`);
step("dismissing one entry individually");
await page.evaluate(`document.querySelector(".attention-sheet .attention-row .attention-dismiss").click()`);
await eventually(
async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)),
{ what: "the sheet to close on row activation" },
async () => (await page.evaluate(`document.querySelectorAll(".attention-sheet .attention-row").length`)) === attentionCount - 1,
{ what: "the individual dismissal to land" },
);
await page.waitForSelector("#detailTitle", { timeout: 25000 });
const openedIdentity = await page.evaluate(
`document.querySelector(".run-identity")?.textContent ?? ""`,
);
if (!openedIdentity.startsWith(`run ${rowToOpen.runId} ·`)) {
throw new Error(`row ${rowToOpen.runId} did not open its run: ${openedIdentity}`);
const afterDismiss = await page.evaluate(`(() => ({
rows: document.querySelectorAll(".attention-sheet .attention-row").length,
badge: document.querySelector("#attentionBell .attention-badge")?.dataset.count ?? null,
stored: localStorage.getItem("pipelines.web.attention.v1"),
}))()`);
if (afterDismiss.rows !== attentionCount - 1 || Number(afterDismiss.badge) !== attentionCount - 1) {
throw new Error(`the dismissal did not update the sheet/badge: ${JSON.stringify(afterDismiss)}`);
}
const storedAfterOpen = await page.evaluate(`localStorage.getItem("pipelines.web.attention.v1")`);
if (!String(storedAfterOpen).includes(`${rowToOpen.runId}:Failed`)) {
throw new Error(`opening a Failed row did not persist its dismissal: ${storedAfterOpen}`);
}
console.log(` opened run ${rowToOpen.runId}; ${rowToOpen.runId}:Failed now persisted`);
}
console.log(` dismissed one; rows ${attentionCount} -> ${afterDismiss.rows}`);
shots.push(await page.screenshot(`${out}/37-attention-dismissed.png`));
step("reopening the sheet and clearing all");
// A skipped row-open can leave the sheet up; close it so the bell reopens it.
if (await page.evaluate(`!!document.querySelector(".attention-sheet")`)) {
await page.evaluate(
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
);
await eventually(
async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)),
{ what: "the attention sheet to close before reopening" },
);
}
await page.click("#attentionBell");
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
const beforeClear = await page.evaluate(
`document.querySelectorAll(".attention-sheet .attention-row").length`,
);
if (beforeClear > attentionCount) {
throw new Error(`the sheet grew: ${beforeClear} rows from ${attentionCount} entries`);
}
if (beforeClear > 0) {
await page.evaluate(`document.querySelector(".attention-sheet .attention-clear").click()`);
step("reopening the sheet and clearing all");
if (await page.evaluate(`!!document.querySelector(".attention-sheet")`)) {
await page.evaluate(`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`);
await eventually(async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)), {
what: "the attention sheet to close before reopening",
});
}
await page.click("#attentionBell");
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
const beforeClear = await page.evaluate(`document.querySelectorAll(".attention-sheet .attention-row").length`);
if (beforeClear > 0) {
await page.evaluate(`document.querySelector(".attention-sheet .attention-clear").click()`);
await eventually(
async () => (await page.evaluate(`document.querySelector(".attention-empty")?.textContent ?? ""`)) === "Nothing needs you right now.",
{ what: "the empty attention state after Clear all" },
);
if (await page.evaluate(`!!document.querySelector("#attentionBell .attention-badge")`)) {
throw new Error("the badge is still visible after Clear all");
}
}
console.log(" Clear all left the empty attention state and no badge");
shots.push(await page.screenshot(`${out}/38-attention-cleared.png`));
step("closing the sheet with Escape returns focus to the bell");
await page.evaluate(`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`);
await eventually(async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)), {
what: "Escape to close the attention sheet",
});
if ((await page.evaluate(`document.activeElement?.id ?? ""`)) !== "attentionBell") {
throw new Error("Escape did not return focus to the bell");
}
} else {
console.log(" -- the sheet was already emptied by the dismissals; asserting the empty state");
step("opening an empty Needs you sheet");
await page.click("#attentionBell");
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
const empty = await page.evaluate(`(() => ({
title: document.querySelector(".attention-sheet-title")?.textContent ?? "",
empty: document.querySelector(".attention-empty")?.textContent ?? "",
rows: document.querySelectorAll(".attention-sheet .attention-row").length,
clear: !!document.querySelector(".attention-clear"),
focused: document.activeElement?.className ?? "",
}))()`);
if (empty.title !== "Needs you") throw new Error(`the sheet title is wrong: ${empty.title}`);
if (empty.empty !== "Nothing needs you right now.") throw new Error(`the empty copy is wrong: ${empty.empty}`);
if (empty.rows !== 0 || empty.clear) throw new Error(`an empty sheet drew rows or Clear all: ${JSON.stringify(empty)}`);
if (!empty.focused.includes("attention-sheet-close")) throw new Error("focus did not move into the empty sheet");
await page.evaluate(`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`);
await eventually(async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)), {
what: "Escape to close the empty attention sheet",
});
console.log(" empty sheet: Nothing needs you right now.; no rows, no Clear all");
}
await eventually(
async () =>
(await page.evaluate(`document.querySelector(".attention-empty")?.textContent ?? ""`)) ===
"Nothing needs you right now.",
{ what: "the empty attention state after Clear all" },
);
const cleared = await page.evaluate(`(() => ({
empty: document.querySelector(".attention-empty")?.textContent ?? "",
rows: document.querySelectorAll(".attention-sheet .attention-row").length,
clearAll: !!document.querySelector(".attention-clear"),
badge: !!document.querySelector("#attentionBell .attention-badge"),
label: document.querySelector("#attentionBell").getAttribute("aria-label"),
badges: document.querySelectorAll(".attention-badge").length,
}))()`);
if (cleared.empty !== "Nothing needs you right now.") {
throw new Error(`the empty copy is wrong: ${cleared.empty}`);
}
if (cleared.rows !== 0) throw new Error(`the cleared sheet still shows ${cleared.rows} rows`);
if (cleared.clearAll) throw new Error("Clear all is still offered on the empty sheet");
if (cleared.badge || cleared.badges !== 0) throw new Error("the badge is still visible after Clear all");
if (cleared.label !== "Notifications") {
throw new Error(`the emptied bell is named wrong: ${cleared.label}`);
}
console.log(` after Clear all: "${cleared.empty}", no Clear all, bell aria-label="${cleared.label}"`);
shots.push(await page.screenshot(`${out}/38-attention-cleared.png`));
step("closing the sheet with Escape returns focus to the bell");
await page.evaluate(
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
);
await eventually(
async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)),
{ what: "Escape to close the attention sheet" },
);
const focusAfterEscape = await page.evaluate(`document.activeElement?.id ?? ""`);
if (focusAfterEscape !== "attentionBell") {
throw new Error(`Escape did not return focus to the bell: ${focusAfterEscape}`);
}
console.log(" Escape closed the sheet and focus returned to #attentionBell");
step("capturing the zero-state bell at 1440x900 and 420x900");
// A Failed row opened a run detail; Back to list makes the Runs heading the
// visible evidence (its control is hidden on the wide layout but is the same
// handler showList uses, and the narrow capture needs the list pane active).
await returnToRunsList();
await page.evaluate(`document.activeElement?.blur?.()`);
await settle(150);
@@ -2889,10 +2797,7 @@ try {
assertAttentionBellGlyph(zeroProbe, 0, "wide bell at zero");
assertSameAttentionGlyph(zeroProbe, countProbe, "wide bell at zero");
shots.push(await page.screenshot(`${out}/38a-attention-bell-zero-1440x900.png`));
console.log(
` zero: no badge, aria-label="${zeroProbe.label}", blank text, ` +
`${zeroProbe.pathCount} unchanged paths at ${zeroProbe.width}×${zeroProbe.height}`,
);
console.log(` zero: no badge, aria-label="${zeroProbe.label}", ${zeroProbe.pathCount} unchanged paths`);
await page.resize(420, 900);
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === false`), {
@@ -2903,27 +2808,13 @@ try {
assertAttentionBellGlyph(zeroNarrowProbe, 0, "narrow bell at zero");
assertSameAttentionGlyph(zeroNarrowProbe, countProbe, "narrow bell at zero");
shots.push(await page.screenshot(`${out}/38b-attention-bell-zero-420x900.png`));
console.log(
` zero narrow: no badge, aria-label="${zeroNarrowProbe.label}", ` +
`${zeroNarrowProbe.width}×${zeroNarrowProbe.height} glyph`,
);
console.log(` zero narrow: no badge, aria-label="${zeroNarrowProbe.label}"`);
await page.resize(1440, 900);
await eventually(() => page.evaluate(`matchMedia("(min-width: 600px)").matches === true`), {
what: "the wide layout back at 1440px",
});
await settle(200);
step("closing the sheet with a backdrop click");
await page.click("#attentionBell");
await page.waitForSelector(".attention-sheet", { timeout: 15000 });
await page.evaluate(`document.querySelector(".attention-sheet").click()`);
await eventually(
async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)),
{ what: "the backdrop click to close the attention sheet" },
);
console.log(" backdrop click closed the sheet");
step(`scrolling the list to the older day group (${fullDateHeader})`);
const scrolledTo = await page.evaluate(`(() => {
const scroll = document.querySelector(".run-scroll");