diff --git a/web/PARITY.md b/web/PARITY.md index 3274dbb8..20e2d809 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -155,7 +155,7 @@ to it, but the server never lists it and a reload drops it. | L4 | Responsive switch by viewport width (no hardcoded device) | `WindowSize.kt` analogue | todo | | L5 | Notifications for failed/waiting runs (browser Notification API; HTTPS/localhost only) | derived from `subscribe` / `run_event` | **partial** — the browser notification path is implemented and captured in Settings, but **no real OS notification was observed**, so the row is not `done`. The exact reason: headless Chrome cannot reliably show or capture an OS notification; the smoke stubs and records the `Notification` constructor, while the transition decisions run through the page's real socket `onmessage`/`frame` path. Pure logic lives in `src/notify.js` and mirrors `notify/RunAlerts.kt` + `ui/Attention.kt`: only a run becoming `failed` (headline `A run failed`) or `waiting` (headline `A run needs your decision`) notifies; `queued`, `running`, `succeeded`, `canceled`, `interrupted` and unknown statuses never do. Body is the attention label (trimmed title else pipeline) then ` · {pipeline}`, with no separator when the pipeline is blank or equal; identity/tag is the attention key `{runId}:{kind}` so one run+kind notifies once, duplicate frames repeat nothing, a key is forgotten when the run leaves that qualifying state, and a genuinely new transition may notify again. First-seen `failed`/`waiting` from the initial `list_runs` or the `subscribe` snapshot raises nothing (the snapshot is bracketed as a seed); a disconnect drops the baseline but keeps the page session's dedupe set and reseeds before resubscribing, so a gap never notifies. A key present in the attention surface's `dismissed` set (`state.attentionDismissed`) is suppressed. Settings now shows the Android rationale verbatim (`Pipelines can notify you when a run is waiting for your decision or has failed. Without it, those runs still appear in the in-app Needs you surface.`) and honest copy for unsupported, insecure context, default, granted and denied; only `default` on a supported secure page offers the explicit `Enable notifications` control, which is the only call to `Notification.requestPermission()` (never on load). Only `{asked:true|false}` is stored under `pipelines.web.notify.v1`; malformed storage decodes to never-asked and the wording never claims consent. Clicking a notification focuses the page and opens Runs with the run selected through the **existing** navigation; **L6's `/runs/:id` URL route is still `todo`**, so no URL route is invented. `subscribeRuns`/`unsubscribeRuns` send exactly `{type:'subscribe',workspace:''}` and `{type:'unsubscribe'}` (no `run_ids`, no polling timer) and are sent only after the page is connected. Unit-tested in `test/notify.test.mjs` (qualification, wording/body, per-run dedupe, seed/snapshot suppression, dismissed keys, permission copy, asked storage) and `test/repository.test.mjs` (both request shapes + the not-connected guard). Captured 2026-10-19: `captures/L5-notifications-settings.png` (default state, control offered, 0 requests on load), `captures/L5-notifications-granted.png` (after the one explicit grant) and `captures/L5-notifications-denied.png` (honest denied copy, no control). The same checks live in `test/ui-smoke.mjs` behind `--notify` (a focused mode that runs exactly this evidence); that run finished `UI SMOKE PASS` and logged: queued→failed and running→waiting each raised exactly one recorded notification, duplicates/terminal/unknown statuses/first-seen/dismissed raised none, and the click opened the run. **Not observed:** the OS notification itself. On 2026-10-19 the default full live suite reached and passed this block with the same logged assertions, then failed later in an unrelated C13 hit-test (`the last row's menu item is not clickable`, its centre at y=919.5 in a 900 px viewport after the list's re-render reset the scroll); the L5 captures and assertions above come from the focused `--notify` run, which finished `UI SMOKE PASS`. | | L6 | Deep links to a run (`pipelines://run/…` analogue → URL route) | — | done — the page's destinations are real URLs through a pure, total route model in `src/routes.js`: `/pipelines`, `/runs`, `/chat`, `/settings` and `/templates`; `/pipelines/:id` and `/pipelines/:id/:version` (version 0 or absent = latest); `/pipelines/:id[/:version]/stage/:key`; `/runs/:id` with `?action=decide`; `/runs/:id/stage/:key[?visit=N]`; `/settings/templates` and `/settings/templates/:key` parse as aliases of `/templates` and `/templates/:key`. `visit` is a zero-based index into that stage's visits, dropped when invalid while the stage route stays; a malformed or unknown path (a bad percent escape, a zero/negative run id, a non-numeric version or path, or a trailing extra segment on either stage branch, e.g. `/runs/440/stage/planner/extra`) resolves to the Pipelines list and never throws, and search/query state is never a route. The serialiser percent-encodes path segments, omits version 0 and an absent visit, and round-trips under `parse(serialize(…))`; an id, version or key the parser would reject is never emitted — it falls back to the nearest canonical route (an invalid id to the list, an invalid version to latest) so the address bar can never carry a path the parser would discard. `serve.mjs` serves `index.html` for any page route (a first segment naming a destination, so a stage key that ends in an extension — `plan.js`, `plan.v2` — still deep-links) or any non-asset GET, with a root `` so the shell's relative asset URLs resolve under a deep path, while an asset-looking path outside a page prefix such as `/nope.js` stays 404. Navigation moves the URL with `pushState` only on a real change (top-level tabs, pipeline/run/template selection, Settings' Browse templates, opening/closing either stage pane; a user click on a pipeline graph node pushes `/pipelines/:id/:version/stage/:key` through the shared graph's `onSelectionChange` (a synthetic click is never used); a deep-linked stage instead opens at mount through the graph's `selectedKey` option without notifying), and one `popstate` listener parses and applies Back/Forward without a reload; in-detail tabs (Summary/Graph/Source, run tabs) and search stay in-place. A deep link is parsed at boot, kept pending until the first successful connection, and then loaded list-first (later reconnects never replay it; any move made while still disconnected replaces the pending boot link, so the URL and the first connected view agree). An unknown or malformed boot path renders the Pipelines list and `replaceState`s the address bar to the canonical `/pipelines` so the URL and the view agree. A later reconnect refreshes the lists and re-applies the route: the URL and a detail already in hand survive the drop, while a detail that is not in hand (never loaded, or cleared while disconnected) is fetched again. Only a genuine server refusal — never a timeout or a socket drop — discards the deep link. A run link's `?action=decide` opens the existing decision sheet once, only when the run is genuinely waiting, then `replaceState`s to the action-free `/runs/:id`. A valid but out-of-range `?visit=N` is clamped to the stage's last visit and the entry is corrected, so the address bar and the pane agree; a pipeline-stage path naming a key the loaded graph does not declare falls back to `/pipelines/:id[/:version]` rather than leaving a pane-less stage URL, while a key the mounted graph can select — including its `#success`/`#failure` terminals — re-opens the same definition pane (the graph writes those URLs itself, so the loader accepts them). A run-stage path naming a stage that is neither visited nor a node of the run graph falls back to the plain run detail. A deep link to an executing run installs its 1 Hz refresh; leaving Runs for any other destination stops it, and a reply discarded for a view that no longer shows Runs stops it too, so no get_run loop survives the move (asserted in the smoke when an executing run is live). A deep-linked stage pane is revealed clear of the sticky top bar (its head and the Close control stay visible), which the smoke asserts. A run the server does not have falls back honestly to `/runs` — the real list, the server's own refusal in the banner and no stale pane or throw (the same for a missing pipeline → `/pipelines`). A run or run-stage route also loads the pipeline list when it has not been seen, so the nav badge stays honest (`Pipelines (29)` at capture time, never a false `Pipelines (0)`) — asserted in the smoke. Captured 2026-10-19: `captures/L6-deeplink-run-440.png` (a hard navigation to `/runs/440` opening run 440's detail), `captures/L6-deeplink-pipeline-24.png` (a hard navigation to `/pipelines/24` opening `Plan and land`), `captures/L6-deeplink-pipeline-24-stage.png` (a hard navigation to `/pipelines/24/stage/planner` opening the Graph tab and the stage's definition pane in view), `captures/L6-deeplink-pipeline-24-terminal.png` (a hard navigation to `/pipelines/24/stage/%23failure` re-opening the Failure terminal pane — the live graph's first terminal at capture time — with its URL unchanged), `captures/L6-history-back.png` (an in-page Pipelines→Runs→run-detail sequence, then `history.back()` restoring the Runs list, with a window marker proving no reload), `captures/L6-missing-run.png` (`/runs/900000000` landing on `/runs` with the real list — 407 rows at capture time — and the banner `run not found`) and `captures/L6-missing-pipeline.png` (`/pipelines/900000000` landing on `/pipelines` with the real pipeline rows and the server's refusal banner). Parsing, serialisation, version/visit semantics and round-tripping are unit-tested in `test/routes.test.mjs`. **The live server had no waiting run, so the `?action=decide` path was not exercised live**; `test/ui-smoke.mjs` captures the sheet automatically the moment a waiting run exists | -| L7 | Accessibility: focus order, labels, keyboard operation | — | todo | +| L7 | Accessibility: focus order, labels, keyboard operation | — | todo — **M5/M6/M7/M9 are fixed in the view modules** (artifact tiles are named `Open {artifact}`, keyboard-operable buttons with Copy link/Share as siblings; a chat row's session button is native and its `Chat actions for {title}` control is a sibling, with the id appended only for repeated titles; attention dismiss controls are named `Dismiss {run label}` with the run id only for repeated labels; timeline rows show a 2px accent focus ring at offset -2px). **Still open:** M1/M2 (dialog focus entry/trap/return and background inertness), M3 (tab roles and arrow keys), M4 (skip link plus list→detail focus order), M8 (one `h1` per route and list `h2`s), and the should-fix items (S1–S12) — the shell/dialog item owns those files. The whole row stays `todo` until they are fixed and a review stage captures the result | ## Deliberately out of scope - **Operator-only transport** — `inspect_resource`, `reconcile_resource`, diff --git a/web/chat.css b/web/chat.css index 226718d6..45aa74b1 100644 --- a/web/chat.css +++ b/web/chat.css @@ -91,7 +91,25 @@ align-items: start; cursor: pointer; } -.chat-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } +/* M6: the session title/meta area is the button; the row is a plain container + and the Chat actions menu is a sibling of this button. */ +.chat-session-button { + grid-column: 1; + grid-row: 1 / span 2; + display: grid; + gap: 2px; + width: 100%; + min-width: 0; + margin: 0; + padding: 0; + border: 0; + background: none; + color: inherit; + font: inherit; + text-align: left; + cursor: pointer; +} +.chat-session-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } .chat-row .row-head { grid-column: 1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .chat-row .row-title { min-width: 0; } .chat-row .row-meta { grid-column: 1; } diff --git a/web/run-detail.css b/web/run-detail.css index d6d24236..ad7daa16 100644 --- a/web/run-detail.css +++ b/web/run-detail.css @@ -45,7 +45,31 @@ cursor: pointer; } .timeline-row:last-child { border-bottom: 0; } -.timeline-row:hover, .timeline-row:focus-visible { background: var(--surface-2); outline: none; } +.timeline-row:hover { background: var(--surface-2); } +.timeline-row:focus-visible { + background: var(--surface-2); + outline: 2px solid var(--accent); + outline-offset: -2px; +} + +/* Artifact tiles (M5): the tile itself is a native button and Copy link/Share + are sibling controls. The grid is shared with the shell item, so the button + reset stays scoped here rather than editing base.css. */ +.artifact-tile-wrap { position: relative; display: flex; } +.artifact-tile-wrap > .artifact-tile { + flex: 1 1 auto; + width: 100%; + margin: 0; + font: inherit; + color: inherit; + appearance: none; + cursor: pointer; +} +.artifact-tile-wrap > .artifact-tile:focus-visible { + outline: 2px solid var(--accent); + outline-offset: -2px; +} +.artifact-tile-wrap .artifact-actions { z-index: 1; } .timeline-glyph { flex: none; width: 18px; text-align: center; font-size: 14px; line-height: 1.4; } .timeline-main { flex: 1; min-width: 0; display: grid; gap: 2px; } .timeline-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } diff --git a/web/src/views/attention.js b/web/src/views/attention.js index 054b51e2..286e3108 100644 --- a/web/src/views/attention.js +++ b/web/src/views/attention.js @@ -145,6 +145,12 @@ function renderAttentionSheet() { ); const body = h("div", { class: "attention-sheet-body" }); + // One count for the whole open sheet: only repeated labels need the run id + // appended, so dismissing stays unambiguous without noisy names elsewhere. + const labelCounts = new Map(); + for (const entry of entries) { + labelCounts.set(entry.label, (labelCounts.get(entry.label) ?? 0) + 1); + } if (entries.length === 0) { body.append(h("p", { class: "attention-empty", text: "Nothing needs you right now." })); } else { @@ -156,7 +162,7 @@ function renderAttentionSheet() { onclick: clearAttentionSheet, }), ); - for (const entry of entries) body.append(renderAttentionRow(entry)); + for (const entry of entries) body.append(renderAttentionRow(entry, labelCounts)); } const sheet = h("div", { class: "attention-sheet-panel", tabindex: "-1" }, head, body); @@ -165,8 +171,12 @@ function renderAttentionSheet() { } /** One attention row: status icon, the two text lines, and a trailing Dismiss. */ -function renderAttentionRow(entry) { +function renderAttentionRow(entry, labelCounts = null) { const glyphState = entry.kind === AttentionKind.Decision ? "waiting" : "failed"; + const repeated = (labelCounts?.get(entry.label) ?? 0) > 1; + const dismissLabel = repeated + ? `Dismiss ${entry.label} (run ${entry.runId})` + : `Dismiss ${entry.label}`; const open = h( "button", { @@ -191,8 +201,8 @@ function renderAttentionRow(entry) { const dismiss = h("button", { class: "attention-dismiss", type: "button", - "aria-label": "Dismiss", - title: "Dismiss", + "aria-label": dismissLabel, + title: dismissLabel, onclick: (event) => { // The trailing control must never activate the row it sits in. event.stopPropagation(); diff --git a/web/src/views/chat.js b/web/src/views/chat.js index 62158253..8469b683 100644 --- a/web/src/views/chat.js +++ b/web/src/views/chat.js @@ -1498,24 +1498,39 @@ function fillChatRows(rows) { const active = filtered.filter((session) => !session.closed); const closed = filtered.filter((session) => session.closed); + // Titles are often repeated ("New chat"); compute the duplicates once so the + // per-row actions name can include the session id only when it is needed. + const duplicateTitles = duplicateChatTitles(filtered); const groups = groupSessionsByDirectory(active); if (groups.length > 1) { for (const group of groups) { rows.append(h("div", { class: "chat-group-header", text: directoryLabel(group.directory) })); - for (const session of group.sessions) rows.append(renderChatRow(session)); + for (const session of group.sessions) rows.append(renderChatRow(session, duplicateTitles)); } } else { - for (const session of active) rows.append(renderChatRow(session)); + for (const session of active) rows.append(renderChatRow(session, duplicateTitles)); } if (closed.length > 0) { rows.append(h("div", { class: "chat-group-header", text: CLOSED_SECTION_LABEL })); - for (const session of closed) rows.append(renderChatRow(session)); + for (const session of closed) rows.append(renderChatRow(session, duplicateTitles)); } if (state.chatError) { rows.append(h("div", { class: "chat-error muted", text: state.chatError })); } } +/** The titles shared by more than one rendered session, for unique action names. */ +function duplicateChatTitles(sessions) { + const counts = new Map(); + for (const session of sessions) { + const title = sessionTitle(session); + counts.set(title, (counts.get(title) ?? 0) + 1); + } + return new Set( + [...counts.entries()].filter(([, count]) => count > 1).map(([title]) => title), + ); +} + function chatEmpty(message) { return h("div", { class: "empty" }, h("span", { class: "muted", text: message })); } @@ -1525,7 +1540,7 @@ function chatEmpty(message) { * activity badge word, the work-label meta line and the close/reopen action. * Every server string is set with textContent. */ -function renderChatRow(session) { +function renderChatRow(session, duplicateTitles = new Set()) { const open = state.chatActiveId === session.id; const thread = state.chatThreads.get(session.id) ?? null; const unseen = @@ -1537,23 +1552,28 @@ function renderChatRow(session) { }); const activity = sessionActivity(thread?.running === true, unseen); const badge = sessionActivityBadge(activity, open); + // The row is a plain container (M6): the session title/meta area is the native + // button and the Chat actions control is its sibling, not a child. const row = h("div", { class: `row chat-row${open ? " selected" : ""}`, - role: "button", - tabindex: "0", "data-session": session.id, - onclick: () => openChatSession(session.id), - onkeydown: (event) => { - // Only the row itself opens on Enter/Space; the Chat actions menu handles - // its own keyboard activation (and must not double-fire). - if (event.target !== event.currentTarget) return; - if (event.key === "Enter" || event.key === " ") { - event.preventDefault(); - openChatSession(session.id); - } + }); + // Keep background and programmatic clicks opening the session, but never + // double-fire when a real control (session button or actions) was clicked. + row.addEventListener("click", (event) => { + const target = event.target; + if (target instanceof Element && target.closest("button, a")) return; + openChatSession(session.id); + }); + const sessionButton = h("button", { + class: "chat-session-button", + type: "button", + onclick: (event) => { + event.stopPropagation(); + openChatSession(session.id); }, }); - const head = h("div", { class: "row-head" }); + const head = h("span", { class: "row-head" }); head.append(h("span", { class: "row-title chat-row-title", text: sessionTitle(session) })); const chip = sessionChipLabel(session); if (chip) head.append(h("span", { class: "chip chat-kind-chip", text: chip })); @@ -1566,14 +1586,14 @@ function renderChatRow(session) { ), ); } - row.append(head); - row.append( + sessionButton.append(head); + sessionButton.append( h("span", { class: "row-meta chat-row-meta", text: sessionMeta(session, sessionWorkLabel(session.busy === true, thread)), }), ); - row.append(renderChatActionsMenu(session)); + row.append(sessionButton, renderChatActionsMenu(session, duplicateTitles)); return row; } @@ -1695,18 +1715,22 @@ function renderChatCreate() { * Close chat… (open) or Reopen (closed), then Hide on this device. Closing is the * shared, server-side finish; hiding only affects this device and says so. */ -function renderChatActionsMenu(session) { +function renderChatActionsMenu(session, duplicateTitles = new Set()) { const wrap = h("div", { class: "chat-row-actions chat-menu-wrap" }); const expanded = state.chatMenu === session.id; + const title = sessionTitle(session); + const actionLabel = duplicateTitles.has(title) + ? `${CHAT_ACTIONS_LABEL} for ${title} (${session.id})` + : `${CHAT_ACTIONS_LABEL} for ${title}`; wrap.append( h("button", { class: "ghost chat-menu-button", type: "button", text: "⋯", - "aria-label": CHAT_ACTIONS_LABEL, + "aria-label": actionLabel, "aria-haspopup": "menu", "aria-expanded": expanded ? "true" : "false", - title: CHAT_ACTIONS_LABEL, + title: actionLabel, onclick: (event) => { event.stopPropagation(); openChatMenu(session.id); diff --git a/web/src/views/runDetail.js b/web/src/views/runDetail.js index c6bdfcf0..2e387fd6 100644 --- a/web/src/views/runDetail.js +++ b/web/src/views/runDetail.js @@ -850,7 +850,14 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) { const kind = artifactKind(artifact.content_type, artifact.name); const media = kind === ArtifactKind.Image || kind === ArtifactKind.Video; const name = artifact.name || "(unnamed artifact)"; - const tile = h("div", { class: "artifact-tile clickable" }); + // The tile is the native control (M5): Enter/Space activate it for free, and + // the Copy link / Share buttons are siblings in the wrapper, never children. + const wrap = h("div", { class: "artifact-tile-wrap" }); + const tile = h("button", { + class: "artifact-tile clickable", + type: "button", + "aria-label": `Open ${name}`, + }); const openViewer = () => { const at = viewerIndexOf.get(artifact.url); if (at != null) openArtifactViewer(viewable, at); @@ -864,7 +871,13 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) { tile.append(img); tile.addEventListener("click", openViewer); } else if (kind === ArtifactKind.Video) { - tile.append(h("div", { class: "artifact-poster" }, h("span", { class: "artifact-play", text: "▶" }))); + tile.append( + h( + "div", + { class: "artifact-poster" }, + h("span", { class: "artifact-play", "aria-hidden": "true", text: "▶" }), + ), + ); tile.append(h("div", { class: "artifact-name", text: name })); tile.addEventListener("click", openViewer); } else { @@ -875,8 +888,8 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) { ); tile.addEventListener("click", openTab); } - tile.append(renderTileActions(resolved, media)); - return tile; + wrap.append(tile, renderTileActions(resolved, media)); + return wrap; } /** The compact per-tile actions: copy-link (non-media tiles) and share. */