diff --git a/web/PARITY.md b/web/PARITY.md index 3e451d71..43cc890d 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -40,7 +40,7 @@ Status legend: `todo` · `partial` (some of it works) · `done` (working + captu | R7 | Timeline | `get_run` | done — one compact row per visit (`{stage} · visit {n}`, stage-outcome chip, paperclip when artifacts recorded, duration, description = first non-blank diagnostic line else `→ {target}`); empty state "No visits recorded.". Captured 2026-10-19: `captures/23-run-430-timeline.png`, `captures/26-run-428-timeline-empty.png` | | R8 | Artifacts gallery + full-screen viewer (images inline, others download/open) | `GET /artifacts/…` | done (captured 2026-10-19: `captures/04-run-430-artifacts.png`, `captures/05-artifact-viewer.png`) | | R9 | Session export link (read-only `session.html`) | `GET /artifacts/…` | done (captured 2026-10-19: `captures/06-session-export-link.png`) | -| R10 | Live run updates: subscribe/unsubscribe + event fold | `subscribe`, `unsubscribe`, `run_event` | done — one app-wide watch owned by the connection, never by a screen: becoming connected best-effort `unsubscribe`s the previous watch, sends `{type:'subscribe',workspace:''}` send-only (no `run_ids`; `{type:'unsubscribe'}` drops it), then takes one authoritative resync (`list_runs`, plus one `get_run` when a run detail is open); a socket drop clears the watch and no screen change ever unsubscribes. `src/runEvents.js` is the pure fold ported from `ui/RunEvents.kt` (in-place list update preserving order, insert-at-head from the frame's pipeline identity, `needsResync` without identity, detail merge with explicit `resource_wait` set/clear, one step matched by `sequence` and inserted in sequence order, the monotonic run/step ladders and the full-sync decision) and is unit-tested in `test/runEvents.test.mjs`; the send-only path (`src/client.js#sendOnly`), the exact watch frames (`src/repository.js`) and the `run_event`/unsolicited-frame dispatch are unit-tested in `test/client.test.mjs` and `test/repository.test.mjs`. The 1 s run-detail poll is removed — pushed frames drive the detail and a settled/terminal frame triggers one coalesced `get_run` (at most one in flight per kind plus one queued follow-up, retried at 500 ms × attempt at most 3 times before the badge drops to `reconnecting`); the only surviving intervals are render-only clocks. The badge is the explicit stream state (`live` / `reconnecting` / `not live`, LiveBadge.kt words), independent of whether a run is executing, on the Runs list and the run detail. Captured 2026-10-19 against the live server with a **real pushed run** started by the smoke in a throwaway workspace: `captures/75-run-live-list.png` (the new run's row inserted from its own frame, badge `live`), `captures/76-run-live-detail.png` (the open detail folded to its terminal word from pushes, badge `live`), plus the reachable badge states `captures/28-connected-banner.png` (live), `captures/29-disconnected-banner.png` (not live while idle; reconnecting while the socket retries) and `captures/30-reconnect-recovered.png` (live again). `test/ui-smoke.mjs` asserts the reconnect wire order (unsubscribe → subscribe blank-workspace → list_runs) and that at least one genuine `run_event` frame for the started run arrived. The R10 step itself passes on every run; the full smoke can still fail later in unrelated, pre-existing steps on the shared live server (observed after the main merge: a flaky L1 stale page-level error on one run and a C5 chat fold `expected at least one folded agent turn, got 0` on another; the focused `--notify` run is `UI SMOKE PASS`), which is not an R10 defect. | +| R10 | Live run updates: subscribe/unsubscribe + event fold | `subscribe`, `unsubscribe`, `run_event` | done — one app-wide watch owned by the connection, never by a screen: becoming connected best-effort `unsubscribe`s the previous watch, sends `{type:'subscribe',workspace:''}` send-only (no `run_ids`; `{type:'unsubscribe'}` drops it), then takes one authoritative resync (`list_runs`, plus one `get_run` when a run detail is open); a socket drop clears the watch and no screen change ever unsubscribes. `src/runEvents.js` is the pure fold ported from `ui/RunEvents.kt` (in-place list update preserving order, insert-at-head from the frame's pipeline identity, `needsResync` without identity, detail merge with explicit `resource_wait` set/clear, one step matched by `sequence` and inserted in sequence order, the monotonic run/step ladders and the full-sync decision) and is unit-tested in `test/runEvents.test.mjs`; the send-only path (`src/client.js#sendOnly`), the exact watch frames (`src/repository.js`) and the `run_event`/unsolicited-frame dispatch are unit-tested in `test/client.test.mjs` and `test/repository.test.mjs`. The 1 s run-detail poll is removed — pushed frames drive the detail and a settled/terminal frame triggers one coalesced `get_run` (at most one in flight per kind plus one queued follow-up, retried at 500 ms × attempt at most 3 times before the badge drops to `reconnecting`); the only surviving intervals are render-only clocks. The badge is the explicit stream state (`live` / `reconnecting` / `not live`, LiveBadge.kt words), independent of whether a run is executing, on the Runs list and the run detail. Captured 2026-10-19 against the live server with a **real pushed run** started by the smoke in a throwaway workspace: `captures/75-run-live-list.png` (the new run's row inserted from its own frame, badge `live`), `captures/76-run-live-detail.png` (the open detail folded to `running` from pushes, badge `live`) and `captures/77-run-live-terminal.png` (the pushed terminal fold to `canceled`, no poll), plus the reachable badge states `captures/28-connected-banner.png` (live), `captures/29-disconnected-banner.png` (not live while idle; reconnecting while the socket retries) and `captures/30-reconnect-recovered.png` (live again). `test/ui-smoke.mjs` asserts the reconnect wire order (unsubscribe → subscribe blank-workspace → list_runs) and that at least one genuine `run_event` frame for the started run arrived. The R10 step itself passes on every run; the full smoke can still fail later in unrelated, pre-existing steps on the shared live server (observed after the main merge: a flaky L1 stale page-level error on one run, a C5 chat fold `expected at least one folded agent turn, got 0` on another, and a C8 composer assertion while the operator's live chat session was streaming, so the composer correctly showed Stop; the focused `--notify` run is `UI SMOKE PASS`), which is not an R10 defect. | | R11 | Human decision sheet: prompt, options, feedback | `decide_run` | partial — the pure model (`src/actions.js`: `pendingDecision`, `lastWaitingStep`, `waitingPrompt`/`waitingOptions`, `humanOptions`, `decisionTargetLabel`, `DecisionDraft`) and the card + sheet are implemented with the Android copy verbatim: card title `Waiting for your decision`, meta `{stage} · run {id} · {runLabel}`, action `Decide`; sheet title `Decide {stage}`, meta `run {id} · {runLabel}`, the recorded instructions verbatim when non-blank, one selectable row per option in author order showing the option and `→ {target}` only when the declared edge resolves, the `Feedback (optional)` field, and `Cancel` / `Confirm decision` (reading `Sending…` while in flight). Selecting a row sends nothing and Confirm is disabled until a non-blank option is chosen; a refusal keeps the sheet open with the server's exact reason and re-reads the run. The request shape is unit-tested (`decide_run` = `{type, run_id, option, stage?, feedback?}`, stage/feedback omitted when blank, feedback trimmed). **No browser capture yet**: the live server had no `waiting` run when `ui-smoke.mjs` ran (only executing/failed/finished runs), so this row stays `partial`; `test/ui-smoke.mjs` now captures the card, the sheet and the selected state automatically (`captures/41-run--decision-card.png`, `captures/42-run--decision-sheet.png`, `captures/43-run--decision-selected.png`) the moment a waiting run exists | | R12 | Cancel run | `cancel_run` | done — `src/actions.js` `canCancel` offers a `Cancel run` action only while the run is `executing`; the confirm dialog is the Android copy verbatim (title `Cancel run {id}?`, `This asks the server to stop the active run.`, confirm `Cancel run`, dismiss `Keep`), and the request is exactly `{type:'cancel_run',run_id}` followed by a silent `get_run` refresh (unit-tested in `test/repository.test.mjs`). Captured `captures/40-run-459-cancel-confirm.png` on the executing run present at capture time. **Shown, not executed**: the only candidate was another live pipeline's executing run, so the dialog was shown and dismissed with `Keep` — no `cancel_run` was sent (a real cancel is only safe against a run started in a scratch workspace, which this stage did not do) | | R13 | Retry failed stage (resume) / restart from start | `retry_run` | done — `canRetry` is true only for a loaded, non-executing, `failed` run; the Retry confirm is the Android copy verbatim (title `Retry run {id}?`, `Only failed runs can be retried. The server starts a new run from the same input.`, confirm `Retry`, dismiss `Keep`) and the default send carries only `run_id` + a fresh `request_key` (**no** `retry_mode`, so the server's `resume` default applies exactly like the Android client's mode-less call; unit-tested). Captured `captures/35-run-440-run-actions.png` (failed run 440 offers Retry and no Cancel) and `captures/36-run-440-retry-confirm.png`. **Divergence from the Android UI, stated here**: Android exposes resume only while the protocol has both modes, so the browser adds a clearly-labelled secondary `Restart from start` confirm that states it `replays the whole pipeline from the start instead of resuming the failed stage` and sends `retry_mode:"restart"` (`captures/37-run-440-restart-confirm.png`). Both dialogs were shown and dismissed with `Keep`; no run was started | @@ -88,15 +88,15 @@ the pipeline list already carries — rather than a pluralised verb. ## Chat | # | Feature | Protocol | Status | | --- | --- | --- | --- | -| C1 | Session list (operator sessions, closed grouped as history) | `chat_sessions` | done — captured 2026-10-19: `captures/44-chat-sessions.png` (the live server's one operator session: "New chat", the `Operator` kind chip, the meta line `Idle · /Users/alan/repos/pipelines` and a `Close chat…` row action) and `captures/50-chat-no-match.png` (the narrowed-to-nothing state `No chats match "zzz-no-such-chat".` with its `Clear search` action). A row is the title (`sessionTitle`: the server title, else the id's first 18 characters, else `Untitled chat`), the kind chip derived from the server tag (`operator` → `Operator`, any other tag verbatim, a blank tag no chip), a `Closed` chip only when closed, the activity badge word (`Streaming` / `New` / `Open`, `Open` only while its conversation is open), and meta = work label · directory · model with blanks omitted (`Running` / `Running {tool}` / `Running {N} tools` while a turn is in flight, else `Busy · read-only`, else `Idle`). Active sessions are grouped by directory only when there is more than one group (header = the directory or `No directory`); closed sessions sit below under a `Closed` header, each reopenable. The search field is labelled `Search chats` and narrows by title or directory, case-insensitively, never re-sorting; the empties are `Loading chats…`, `No chat sessions on this server yet.` with a `New chat` action placeholder (wired by C2) and `No chats match "{query}".` with `Clear search`. The `Loading chats…` and `No chat sessions on this server yet.`/`New chat` states are implemented but not captured: the live server always lists its one operator session, so neither state is reachable against it | -| C2 | Create a chat (directory picker) | `chat_directories`, `chat_create` | todo | +| C1 | Session list (operator sessions, closed grouped as history) | `chat_sessions` | done — captured 2026-10-19: `captures/44-chat-sessions.png` (the live server's one operator session: "New chat", the `Operator` kind chip, the meta line `Idle · /Users/alan/repos/pipelines` and a `Close chat…` row action) and `captures/50-chat-no-match.png` (the narrowed-to-nothing state `No chats match "zzz-no-such-chat".` with its `Clear search` action). A row is the title (`sessionTitle`: the server title, else the id's first 18 characters, else `Untitled chat`), the kind chip derived from the server tag (`operator` → `Operator`, any other tag verbatim, a blank tag no chip), a `Closed` chip only when closed, the activity badge word (`Streaming` / `New` / `Open`, `Open` only while its conversation is open), and meta = work label · directory · model with blanks omitted (`Running` / `Running {tool}` / `Running {N} tools` while a turn is in flight, else `Busy · read-only`, else `Idle`). Active sessions are grouped by directory only when there is more than one group (header = the directory or `No directory`); closed sessions sit below under a `Closed` header, each reopenable. The search field is labelled `Search chats` and narrows by title or directory, case-insensitively, never re-sorting; the empties are `Loading chats…`, `No chat sessions on this server yet.` with a `New chat` action (C2) and `No chats match "{query}".` with `Clear search`. The `Loading chats…` and `No chat sessions on this server yet.`/`New chat` states are implemented but not captured: the live server always lists its one operator session, so neither state is reachable against it | +| C2 | Create a chat (directory picker) | `chat_directories`, `chat_create` | done — captured 2026-10-19: `captures/75-chat-create-picker.png` (the list's `New chat` action opens `Start a chat`; back `Cancel new chat`, prompt `Where should this chat live?`, home `Home (~)` first and selected with `/Users/alan` beneath it, two recents labelled by their full paths, the model note, and the footer `Start in ~` / `Cancel` / `New chat`), `captures/76-chat-created-list.png` (the one real session `ses_eabc47a91ffe31C6zNX4ieXN6e`, titled `New chat`, created with exactly `{title:"New chat",directory:"~",operation_id:"…"}`, at the head of the list and active with its empty history) and `captures/77-chat-created-closed.png` (the same session closed through the `Close chat…` → `chat_close` confirm, now carrying the `Closed` chip as history). Blank directory entries are dropped, an empty reply still yields home, `~` is sent for home and the absolute path for a recent, and the create is guarded against double submission; a refusal stays in the open pane with the server's own text. The operator's own `ses_eae413f50ffeLQDExlg8cYnscN` was not selected, closed, reopened or prompted by this item. The smoke created exactly one real session and closed it; nothing was deleted | | C3 | Open / close / reopen a session | `chat_close`, `chat_reopen` | done — captured 2026-10-19: `captures/49-chat-close-confirm.png`. Selecting a row opens the conversation (see C4); an open row offers `Close chat…` and a closed row offers `Reopen`. The confirm is the Android copy verbatim: title `Close chat?`, the body naming the session title (`Closes "{title}" and marks it closed on every device. A turn that is running is stopped first. Nothing is deleted — the chat and its history are kept, and you can reopen it from the list.`), confirm `Close chat`, dismiss `Cancel`; only the confirm sends `chat_close` (and `Reopen` sends `chat_reopen`), then the list is refreshed from the server. The `Close chat…` action is offered on every open row, so its confirm is rendered from the pane's overlays **whether or not a conversation is open** — the smoke exercises the row-level path with no session selected (`ui-smoke` asserts the confirm appears and dismisses it), not only the path after opening the row. **Shown, not executed**: the live server has exactly one session — `ses_eae413f50ffeLQDExlg8cYnscN`, the operator's own — so the dialog was shown, captured and dismissed with `Cancel`; **no `chat_close` was sent** and that session was not closed or reopened by this stage | | C4 | History with paging / "load older" | `chat_messages` | done — captured 2026-10-19: `captures/45-chat-transcript-newest.png` (the opened `ses_eae413f50ffeLQDExlg8cYnscN` transcript with the `Load older messages` control beside the conversation's identity while the server reports `has_more`) and `captures/48-chat-load-older-empty.png` (after pressing it: the live session's own opaque cursor returned an empty older page, so `has_more` went false and the control disappeared — the honest result of the server's cursor, distinct from 45). The request is exactly `{type:"chat_messages",chat_query:{session_id,limit:200,cursor}}`; the newest page is read with an empty cursor and an older page with the server's own opaque `next_cursor` passed back verbatim (never interpreted), and the reply is `chat_history.{messages,next_cursor,has_more}` with an older server's bare `chat_messages` falling back to `hasMore:false`. `mergeHistoryPage` prepends an older page, dedupes by id (order-preserving, the page's copy winning) and replaces `nextCursor`/`hasMore`; the prepend itself is unit-tested (`test/chat.test.mjs`) because the live server returned no older rows. Nothing auto-loads on scroll and there is no end-of-history row | | C5 | Live transcript: user/assistant text, one reply = one turn | `chat_subscribe`, `chat_event` | done — captured 2026-10-19: `captures/56-chat-live-turn.png` (the answer text growing inside the existing single agent bubble while the reasoning step count grows), `captures/57-chat-running.png` (the running indicator: spinner + `Running a tool…` + `· 1s` + the `shell npm run build` line), `captures/58-chat-long-call.png` (a 61 s-old call tinted ` · long`), `captures/59-chat-settled.png` (the tools completed and the step ended: no indicator, the same one agent bubble). Opening a conversation attaches its shared live stream with exactly `{type:'chat_subscribe',chat_subscribe:{session_id}}` (the `chat_subscribe` field, **not** `chat_query`; internal/protocol/message.go, chat_stream.go) and folds every pushed `chat_event` into the open thread; the session is never read-only and any number of clients may watch it. `client.js` surfaces an envelope with no matching pending id as a DOM-free `frame` event (a matched reply is still resolved by id and not broadcast) and `src/app.js` folds only `chat_event` frames for a session this client has open. There is **no** `chat_unsubscribe` on the wire: the server detaches a subscription when the connection closes (chat_hub.detachClient / websocket.go), so on a socket drop the page clears its subscription set and settles every running thread, and on reconnect re-subscribes the open chat and replaces its conversation with the newest history page wholesale (`historyResync`, no stale held turn) — captured by the smoke's own reconnect. The pure fold lives in `src/chat.js` (`applyChatEvent` and helpers) and is unit-tested: a `user` frame needs a non-blank message id and text, is ignored when the id already exists and keeps the sender's `client` label (the server never echoes this client's own prompt); `text`/`reasoning` deltas append to the part their kind started (`deltaPartId`, so the two kinds can never share a part) and a live turn that spans several assistant message ids stays one `transcriptRows` agent bubble; `tool` frames merge field by field (a non-empty incoming field wins, `state.status/input/content/metadata/error` each retained when omitted, `executed` sticky, `time` retained), so a later frame never blanks what an earlier one taught; `step` runs the turn unless the status is `ended`; a `shell` frame is C11's and never marks the turn running; `usage` is not folded; any frame clears `queued`. The live badge uses the same words as the run badge — `live` while subscribed on a connected socket, `reconnecting` while the socket is coming back, `not live` when idle/refused (`chatStreamState`, unit-tested; the smoke logs all three). The running indicator (under the transcript, after the last agent turn) is a spinner plus the phase headline (`Thinking…` / `Running a tool…` / `Waiting…`) and ` · {elapsed}`, then one line per running tool with its own elapsed; a call at or past 60 s is tinted and marked ` · long`. **Replayed vs real, stated plainly**: the live server had no turn to prompt (its only session is the operator's, and this stage does not write to it), so `ui-smoke.mjs` subscribes through the real server and every history reply is real, then replays exact `chat_event` frames through the socket's own `onmessage` (a WebSocket recorder shim installed before the page's scripts via `Page.addScriptToEvaluateOnNewDocument`); the smoke log names the replayed frames and asserts the subscribe ack and history came from the real server | | C6 | Reasoning block + tool calls with name/input for the whole lifecycle | `chat_event` | done — the assistant turn draws, in order, its one collapsible reasoning block and its one tool-call chip (then the answer). Reasoning labels match the app: `Thinking…` / `Reasoning` for a single step and `Thinking · {N} steps` / `Reasoning · {N} steps` for several, with ` · {duration}` appended when the parts' timing gives a settled span (earliest start → latest completed), through chevrons named `Show reasoning` / `Hide reasoning`. The chip reads `1 tool called` / `{N} tools called`, announces `… expand for details`, wears the shared spinner while a call is in flight and an error tint once one failed, and opens a fixed overlay panel under the chip (flipped above / clamped into the viewport when there is no room) with the same count, a `Close tool calls` control and an internally scrolling, independently-expandable row per call: the name (else `tool`), the first of `description`/`command`/`filePath`/`file_path`/`path`/`pattern`/`query`/`url` collapsed and elided to 72 characters, the `+N -M` edit stat when present, the `formatToolDuration` value (`340ms`/`1.2s`/`2m 3s`), and `Expand {name}`/`Collapse {name}`; a failed row is marked `Failed tool call`. An expanded row shows INPUT (pretty-printed JSON, or the raw partial string), the LCS edit diff (at most 200 rendered lines with the remaining `… {N} more changed line(s) not shown`), then ERROR (the server's `error.message`, else the output) or OUTPUT (`(no output)` when settled and empty, nothing while in flight). Lifecycle words `streaming`/`running` are in flight and `completed`/`error` settled; a settled call never spins or wears the ` · long` mark. Because the panel is a fixed overlay, opening or closing it never re-flows the transcript nor moves its scroll (C14). Captured 2026-10-19 against `ses_eae413f50ffeLQDExlg8cYnscN` (one folded turn, 80 reasoning steps, 122 tool calls): `captures/51-chat-reasoning-collapsed.png`, `captures/52-chat-reasoning-expanded.png`, `captures/53-chat-tool-chip.png`, `captures/54-chat-tool-panel.png` (an opened `read` row showing INPUT + OUTPUT) and `captures/55-chat-edit-diff-sample.png`. The live history carries no failed or edit-family call, so that capture renders a labelled page-rendered sample — a `shell` row marked `Failed tool call` with INPUT + ERROR and an `edit` row with a `+2 -1` diff — through the page's own row builder; the transcript stayed put across open/close (top 43065 → 43065). **Live arrival over `chat_event` is C5**: the renderer is built from the same part shapes (`ChatPart{type,name,state{status,input,content,error},time}`) and takes a `streaming` flag plus a live elapsed source so C5 can drive in-flight calls; the chip's in-flight spinner, the ` · long` 60s mark, the panel flip-above and an edit-family call are not reachable against the live server, so they are unit-tested (`test/chat.test.mjs`) rather than claimed as captured | | C7 | Markdown rendering + code blocks | — | done — captured 2026-10-19: `captures/45-chat-transcript-newest.png` (opened at the newest content: bold, bullet lists, a `|` table with its `---` delimiter row and inline code spans from the live assistant answer), `captures/47b-chat-markdown-code.png` (a rendered fenced code block — label `js`, the pre body `const answer = 42;` — drawn in the live browser by the page's own `renderMarkdown`, the same function that renders the answer) and `captures/47-chat-reasoning-code.png`. The subset is exactly `Markdown.kt`: paragraphs, `#`–`######` headings, fenced code (```/~~~, the language label else `code`), block quotes, bullet/ordered lists, `|` tables with a `---` delimiter row, thematic rules, inline code, bold, italic (underscore only at word boundaries, so `snake_case` stays plain), `[label](url)` links and bare http(s) autolinks; HTML entities are decoded first in one pass, and HTML, reference links, strikethrough and nested lists render as plain text and are never dropped. **Code-block caveat, stated plainly**: the live assistant answer carries **no** fenced block — its four fences live in the reasoning transcript, which the app draws as plain text, not as markdown (`captures/47-chat-reasoning-code.png` shows one such fence as muted plain text; that is C6 material, not the markdown path). So the rendered `
` code block is captured from a labelled sample through the page's real renderer (`47b`), and the same path plus its `code`-else-language label is unit-tested in `test/markdown.test.mjs`. Only `http(s)` link targets become clickable — the transcript is untrusted model output, so a `javascript:`/`data:` target renders as its label, never as a live link |
 | C8 | Composer: send, stop, attachments, draft | `chat_prompt`, `chat_interrupt` | done — the composer at the foot of an open conversation: a growing 1–6-row `