web/PARITY: restore C11's done row lost in a later merge

This commit is contained in:
2026-10-19 12:57:52 +01:00
parent 9231236f83
commit 94c802a147
+1 -1
View File
@@ -98,7 +98,7 @@ the pipeline list already carries — rather than a pluralised verb.
| 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 `<textarea>` (placeholder `Message the agent… or / for commands`) where Enter submits and Shift+Enter inserts a newline (the submit routing is the pure `composerSubmit`), an `Attach file` control opening a multi-file picker, a removable chip per attachment (an image thumbnail else a file glyph, the display name, then the error text or `humanBytes(size)`, and a remove control named `Remove {name}`), and one primary control: Stop (`aria-label`/title `Stop`, error tint) while a turn runs, else Send (`aria-label` `Send`, disabled unless a non-blank draft with no failed attachment — or a slash draft). The 25 MiB guard reads `"{display}" is too large (25.0 MiB limit).` and an unreadable file `"{display}" could not be read.`; the web file picker cannot produce an unreadable file, so only the limit branch is captured and both are unit-tested (`test/chat.test.mjs`). Send trims the draft, clears the draft and the attachments at once, calls `chatPrompt` with `{session_id,text,operation_id,native_message_id}` (+ `files` only when present) and reads the reply's `chat_queued` into the notice `Queued — it will send when the current turn finishes.`; a rejected prompt restores the draft and the attachments (each flagged with the server's own message) and shows the shared `Action failed` dialog. The queued flag clears on any incoming frame (the client fans unsolicited envelopes out as a `frame` event; the composer folds it). The draft is kept per chat in memory **and** mirrored into `localStorage` (`pipelines.web.chatDraft.v1`) — the web analogue of per-device persistence — while attachments stay memory-only. Captured 2026-10-19 against a **freshly created** session (never the operator's own): `captures/56-chat-composer-draft.png`, `captures/60-chat-attachment-chips.png`, `captures/61-chat-attachment-removed.png`, `captures/63-chat-composer-stop.png` (a real prompt to the throwaway session turned Send into Stop), `captures/63b-chat-stop-interrupt.png` (the Stop control was **clicked**: it sent `chat_interrupt` and the page showed `Stopping the running turn…`, with no `Action failed` — the control is wired to `chat_interrupt`, never to the inert submit path) and `captures/64-chat-throwaway-closed.png` (after `/close`, the closed row plus the conversation pane left for the list). The throwaway session was created with `chat_create`, really prompted, really interrupted and closed with `chat_close`; the operator's session `ses_eae413f50ffeLQDExlg8cYnscN` was never prompted |
| C9 | Slash commands | client-side | done — the palette appears above the composer only while the trimmed draft starts with `/` and has no whitespace, filtered case-insensitively by name prefix, each row showing `/name` and the summary and the highlighted row marked `aria-selected`; Up/Down move the highlight and Enter runs it, a tap runs a row directly, and running a command always consumes the draft and never reaches the prompt path. The five commands and their summaries are `CHAT_COMMANDS` (`/new`, `/close`, `/rename <title>`, `/stop`, `/help`), unit-tested verbatim, with `chatCommandHelp()` the `usage — summary` lines. Effects: `/new` sends `chat_create` directly (C2's item) and opens the created session, `/close` reuses the C3 `Close chat?` confirm, `/rename` is the local rename pending C13, `/stop` interrupts (`chat_interrupt`) and `/help` shows the command list. Error wording is the Android source verbatim: the unknown command reads `“{token}” is not a command, so nothing was sent to the agent. Send it as a message, or cancel.` with the draft offered back and `Send as message` / `Cancel`; an extra argument on an argument-less command reads `{usage} does not take an argument.`; `/rename` with no title reads `Usage: /rename <title> — renames this session on this device.`; `/stop` with nothing running reads `No turn is running in this chat.`. A notice renders as a full-width line after the turns (not a bubble) with the label `Command` / `Command failed` and a terminal glyph, error-coloured when failed. Captured 2026-10-19: `captures/57-chat-command-palette.png`, `captures/58-chat-command-palette-selected.png` (ArrowDown moved the highlight), `captures/59-chat-command-unknown.png` (the failed notice and its offer, dismissed with Cancel), `captures/62-chat-new-session.png` (`/new`'s created session and its `Command` notice) |
| C10 | Permission/approval cards (allow once/always/reject) | `chat_permission`, `chat_reply` | done — captured 2026-10-19: `captures/65-chat-approval-pending.png` (the pending card as the transcript's last item: the amber outlined shield + `Approve bash`, `Waiting for your response`, the request's six monospace resource lines, the amber `RISK REVIEW` panel, the `Allow once` / `Always allow` / `Reject` controls, and the top bar's `Waiting for your approval` control, with `#chatRunning` stood down), `captures/66-chat-approval-answered.png` (`Allowed once` / `Waiting for the agent to continue…`, controls and top-bar control gone), `captures/67-chat-approval-resolved.png` (a server resolution: `Always allowed` with its note `Another client already allowed this.`, no controls, no risk panel) and `captures/68-chat-approval-rejected.png` (a blank-action request answered `Reject`: `Rejected` / `Waiting for the agent to continue…`, the risk panel kept with the fallback sentence, no controls). The pure model is `src/chat.js` (`approvalCard`/`applyChatPermission`/`permissionRiskText`/`decisionLabel`): while pending `Approve {action}` (blank action → `Approve tool call`), after answering the decision label (`Allowed once` / `Always allowed` / `Rejected`, an unknown decision → `Resolved`) and `Waiting for the agent to continue…`, and once the server reports `resolved`/a decision that label (else `Already resolved`) with its `message` as the status (else `Another client already answered this request.`); the amber `RISK REVIEW` box shows only while pending or after a reject. Resources drop blanks and cap at six visible lines: `approvalResourceText` caps the joined text at six lines with an ellipsis on the last kept line, and the rendered text is a padding-free `-webkit-line-clamp: 6` block inside a padded frame, so a long resource that wraps is elided at the content edge and no seventh line paints into the frame's padding — matching Android's `maxLines = 6, Ellipsis` (the smoke asserts six clipped lines, a hidden overflow and the block ending at the frame's content edge, with seven lines unclamped). `Allow once` is rendered as the browser's filled primary control, matching the app's filled `Button` versus its two `TextButton`s; the head and risk-panel shields are inline SVG stroked with `currentColor` so the warn hue actually tints them (a colour emoji cannot be tinted). A server resolution always outranks a local answer, a new request replaces the settled card and clears the answer, and the same request keeps it. `PipelinesRepository.chatReply` sends exactly `{type:'chat_reply',chat_reply:{session_id,request_id,decision,client}}` (`message` only when non-blank) and refuses blank ids or a decision outside once/always/reject; answering settles the card optimistically, and a refused send reopens the same request and reports the server's reason on the thread's error line (ignored if a different request has replaced the card), so an unaccepted decision is never shown as accepted. The card is fed by `chat_permission` frames through `client.js`'s unsolicited-frame path, folded only for sessions this client has open. **Replayed, not real**: no live pending approval was available, so the captures were driven by synthetic `chat_permission` frames replayed through the page's own socket handler against the live session; the page's real `chat_reply` path was exercised but the smoke's shim suppressed every reply for the synthetic request ids (suppressed 3, one of them answered with a server error to prove the reopen path, forwarded 0), so **no approval decision was sent to the operator's server**. Unit-tested in `test/chat.test.mjs` and the reply shape in `test/repository.test.mjs`; the DOM assertions and log lines are produced by `test/ui-smoke.mjs` |
| C11 | Background tasks bar: running shells only, capped + scrollable, bounded output page | `chat_shells`, `chat_shell_output` | todo |
| C11 | Background tasks bar: running shells only, capped + scrollable, bounded output page | `chat_shells`, `chat_shell_output` | done — captured 2026-10-19 into a live session: `captures/65-chat-background-tasks.png` (the bar with five running tasks — heading `Background tasks`, count `5 running`, three visible rows and a scrolling list), `captures/66-chat-background-task-detail.png` (a selected task's detail: `Command` + the command, `Task identity` + the id in monospace, `Status: running`, then `Output` + the monospace text and `Refresh`), `captures/67-chat-background-task-empty.png` (`No output yet.`), `captures/68-chat-background-task-unavailable.png` (`Output unavailable for this task.`), `captures/69-chat-background-task-truncated.png` (`Output is bounded to 64 KiB.` plus `Refresh`), `captures/70-chat-background-task-loading.png` (the spinner while the page loads) and `captures/71-chat-background-tasks-exited.png` (the bar gone after the last exit). The bar is shown only while at least one shell is running and disappears with the last exit; only running shells are listed (an exited shell is never a task). Its visible rows are capped at 3 (`BACKGROUND_TASK_VISIBLE_ROWS`) and the list scrolls beyond that instead of growing; each row is a play glyph + `Running` + `shellCommandSummary(command)` (trimmed, whitespace-collapsed, elided past 72; blank → `background process`) + `Details` only while selected, and tapping a row toggles its detail pane. Refresh always rereads the page from cursor 0 with `limit` 65536 (`SHELL_OUTPUT_LIMIT`, the server's 64 KiB bound) and never appends, so the client's output cannot grow unbounded — the smoke's own Refresh click issues exactly such a second read and the smoke asserts its `{cursor:0,limit:65536}` bounds. `chat_shells` is fetched when the conversation opens (`chat_query` body `{session_id}`) and again on every stream reconnect, and `chat_shell_output` sends `chat_shell_output_query` (`{session_id,shell_id,cursor,limit}`); both the request shapes and the pure model (`runningBackgroundShells`, `shellCommandSummary`, `mergeShellFrame`, `shellsLoaded`, `shellOutputState`, every wording constant) are unit-tested (`test/chat.test.mjs`, `test/repository.test.mjs`). A `shell` frame folds its shell into the retained set, merges a blank command from the previous frame, and never marks the thread running — a background process outlives the turn (a step ending does not clear it; only the reconnect drops and re-learns it). Every server string is set with `textContent`; shell output is never parsed as markup. **Replayed vs real, stated plainly**: only the `shell` frames (injected synthetic `chat_event` frames) and the `chat_shell_output` pages (answered by a socket reply hook) are synthetic, because the live server had no running shell to read safely; the `chat_shells` list, the `chat_subscribe` ack and every `chat_history` reply came from the real server, and the smoke asserts the real `chat_shells` fetch on open and after a reconnect. The one drop that hit a bounded read mid-section was recovered by the smoke's own bounded retry through the page's controls |
| C12 | Human-decision notices inside chat + dismiss | `chat_event` | done — the local command-notice surface is captured and dismissible per notice. Captured 2026-10-19: `captures/72-chat-command-notice.png` (a full-width `Command` line after the turns, never a message bubble: the shared terminal glyph `>_`, the `/help` command list and its own `Dismiss`), `captures/73-chat-command-failed-offer.png` (an unknown command: `Command failed` in the error tint, the exact Android sentence and the `Send as message` / `Cancel` pair) and `captures/74-chat-command-dismissed.png` (the `/help` notice dismissed; the failed offer line and its controls remain — exactly one notice removed). A notice is a local `ChatCommandNotice`, never a `ChatMessage`: it lives in that conversation's `state.chatThreads` entry, survives switching away and back while the page is open, and never enters the prompt path — the smoke's recorded sends show **no** `chat_prompt` for `/help` or an unknown command. `Send as message` takes the offered draft through the ordinary `postChatPrompt` path, removing the notice **before** sending, so a stale second tap sends nothing (the smoke verifies both on a throwaway session). The pure model lives in `src/chat.js` (`makeChatNotice`, `appendChatNotice`, `dismissChatNotice`, `takeChatNoticeOffer`, `chatNoticeLabel`) and is unit-tested (`test/chat.test.mjs`): append, dismiss one, take the offer, a stale/offerless offer returning null and leaving the list untouched, per-conversation scoping, and the failed label/tint flag. **Wire finding, not an invented source**: `chat_event` kinds are exactly `user`, `text`, `reasoning`, `tool`, `shell`, `step` and `usage` (`internal/protocol/chat.go` `ChatEvent*`), and `chat_permission` is the only approval frame — there is **no** in-chat run-decision notice on the wire. Run-level human decisions live on R11's run-detail decision sheet (`decide_run`) and C10's approval cards (`chat_permission` / `chat_reply`), exactly as the app does it. **Stated browser divergence**: Android's `ChatCommandNoticeItem` shows actions only when `offer != null`, so it cannot dismiss a `/help` or `/new` line; the browser adds a `Dismiss` control (accessible name `Dismiss command notice`) on offerless notices to meet "each is individually dismissible", keeping the app's `Send as message` / `Cancel` pair verbatim on offer notices. |
| C13 | Local rename/hide, seen state, persistence to `localStorage` | client-side | todo |
| C14 | Scroll behaviour: follow newest, "jump to newest", restored position | client-side | done — captured 2026-10-19: `captures/45-chat-transcript-newest.png` (the conversation opens at its newest content instantly — the only live session has no saved position, so it lands at the end rather than at the top of a turn taller than the viewport) and `captures/46-chat-transcript-top.png` (after a **real wheel gesture** on the transcript — the app's own listener, not a programmatic scroll, which by the implementation's own rule cannot change intent — `Jump to latest` is offered; the smoke asserts the control and performs the gesture, `ui-smoke` log line "after a real wheel gesture (scrollTop 0) 'Jump to latest' is offered at the top"). A thread with a saved position is restored to it (a saved top, index 0, is a real position and is never treated as "new"); while within the 32 px bottom threshold the view follows, and only the operator's own wheel/drag changes that intent (a programmatic placement or follow cannot); `Jump to latest` is offered only when not following and something is below the fold; the position is saved per session in `localStorage` (`pipelines.web.chatScroll.v1`). A re-render (opening/dismissing a dialog, a refresh, or the loading frame of a paging fetch) captures the live position first and puts the operator back exactly where they were — the smoke asserts the transcript stays put across the `Close chat?` dialog (`ui-smoke` log line "the transcript stayed put across the dialog (top 7141 -> 7141)"); the paging anchor is held until the frame that actually carries the older page, so a real prepend stays on the previously visible message. No auto-load on scroll. The pure decisions are unit-tested (`chatBottomDistancePx`, `chatFollowsAt`, `chatShowJumpToLatest`, `chatOpensAtNewest`, `chatFirstScroll`) in `test/chat.test.mjs`, and the live measurement uses `chatBottomDistancePx` itself |