diff --git a/web/PARITY.md b/web/PARITY.md index 111eff4a..21073a63 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -165,6 +165,7 @@ to it, but the server never lists it and a reload drops it. | B2 | Pipeline list mini graph | `list_pipelines` (`shape`) | done — each summary now carries the current version's parsed graph as `shape`; the browser draws a label-free miniature from the real `layoutGraph` with terminal-free stage routes. The row shows the name, the shape and only `{N stages}`; the cryptic `id {n} · v{n} · …` line is gone. Verified at 390×844 against the live server: 9 rows, 9 miniatures, and the detail still owns the full Graph tab. Additive field; older clients ignore it. | | B3 | Equal phone dock cells | — | done — the narrow dock is a four-cell grid (one cell per destination plus Search) with a subgrid for the tablist, so every control has the same width and height. At 390×844 the measured widths are 92/92/92/92 and the row is 48px high. The phone shell uses `100svh` so a browser toolbar cannot hide the tab row while leaving only the Connected/Settings status row visible. | | B4 | Full-height pipeline Source | — | done — the Source block no longer caps itself at `60vh`; it is as tall as its content and the detail pane owns the scroll. Verified at 390×844: a 4386px definition sits in the full pane (656px viewport) and scrolls. | +| B8 | Composer keeps focus and the running line stays stable | — | done — a live frame re-renders the transcript, so the composer now captures and restores its focus, value and selection (verified in a real browser: a synthetic `chat_event` arrived while the caret sat at 8–14 and the input stayed focused with the same value/selection). The running indicator is one ellipsised line that updates in place for the longest-running tool instead of adding/removing a line per call; measured height stayed 52px across tool start/finish until the step ended. Pipeline-list miniatures are right-aligned at the row's trailing edge. | | B7 | Chat detail is a real history entry with a compact Back | `/chat/:id` | done — opening a session pushes `/chat/:id`, so Android's back gesture/browser Back returns to the chat list instead of the previous destination. The conversation header now owns a 32px back control matching the create pane (the full-width "Back to list" row is gone for chat; it remains on the other detail panes). Verified at 390×844: the header control reads `Back to chats`, the URL changes to `/chat/ses_…`, pressing it returns to `/chat` with the list restored, and `history.back()` from a reopened chat does the same. | | B6 | Agent questions are answerable in the browser | `chat_event` (`form`), `chat_answer` | done — OpenCode's question tool pauses inside a `form.created` event; the broker now maps `form.created` / `form.replied` / `form.cancelled` to a `form` chat_event, the browser renders a question card with the form's options and free-text fields, and `chat_answer` posts the field-keyed answer to `/api/session/{id}/form/{id}/reply`. A question for a backgrounded chat also raises the existing browser notification. Verified end to end with a real model turn: the card appeared with a `Demo colour` field, selecting Red and pressing `Send answer` cleared it and the same turn completed with "You chose Red for the demo."; the OpenCode form normalizer is unit-tested. | | B5 | Sign-in reaches the app, and stays signed in | — | done — a successful `POST /login` redirects to the requested path; a fresh browser with no saved endpoint now connects to its own origin instead of stopping on Settings/"Not configured". The session cookie is `SameSite=Lax` (a Strict cookie was withheld when the installed app or another app opened the page) and carries both `Max-Age` and `Expires` for Remember me. Verified in headless Chrome: login with `next=/pipelines` reached the connected list, and a closed/reopened page stayed signed in with no local endpoint. **iOS Safari/PWA itself was not directly exercised**, so the toolbar/cookie fixes are targeted at that report rather than claimed as device-verified. | diff --git a/web/chat.css b/web/chat.css index c9335161..49b39a63 100644 --- a/web/chat.css +++ b/web/chat.css @@ -897,3 +897,13 @@ @media (max-width: 599px) { .chat-back { display: inline-flex; } } + +/* The running detail is one ellipsised line for the whole turn; changing tools + must not change the transcript's height or bounce the text. */ +.chat-running-tool { min-height: 18px; } +.chat-running-tool-text { + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} diff --git a/web/lists.css b/web/lists.css index cdd898b2..001dbeb8 100644 --- a/web/lists.css +++ b/web/lists.css @@ -372,10 +372,10 @@ /* The list-row shape cue: the pipeline's route at a glance, without labels. */ .pipeline-mini { display: block; - width: 100%; - max-width: 260px; + width: min(210px, 56%); height: 22px; - margin: 3px 0 1px; + /* A shape cue at the row's trailing edge, not a full-width block. */ + margin: 3px 0 1px auto; color: var(--color-muted); } .pipeline-mini-graph { display: block; width: 100%; height: 100%; overflow: visible; } diff --git a/web/src/views/chat.js b/web/src/views/chat.js index 7b4da043..0a829384 100644 --- a/web/src/views/chat.js +++ b/web/src/views/chat.js @@ -331,7 +331,45 @@ function transcriptDistance(el) { * re-render replaces it, so `afterChatRender` can put the operator back exactly * where they were. A no-op when no transcript is mounted. */ +let pendingComposerFocus = null; + +/** + * Remember the composer's focus and selection before a re-render replaces the + * textarea. Live frames arrive continuously, so without this every tool/text + * frame would steal focus and the operator could not type a queued message. + */ +function captureChatFocus() { + const input = document.getElementById("chatInput"); + if (!input || document.activeElement !== input) { + pendingComposerFocus = null; + return; + } + pendingComposerFocus = { + sessionId: state.chatActiveId ?? "", + start: input.selectionStart, + end: input.selectionEnd, + direction: input.selectionDirection, + }; +} + +/** Put the caret back after the transcript is rebuilt, without scrolling. */ +function restoreChatFocus() { + const pending = pendingComposerFocus; + pendingComposerFocus = null; + if (!pending) return; + if (state.chatActiveId !== pending.sessionId) return; + const input = document.getElementById("chatInput"); + if (!input) return; + input.focus({ preventScroll: true }); + try { + input.setSelectionRange(pending.start, pending.end, pending.direction); + } catch { + // A non-text input or an unsupported selection range is harmless. + } +} + function captureChatPosition() { + captureChatFocus(); const el = document.getElementById("chatTranscript"); if (!el || !el.dataset.session) return; state.chatPending = { @@ -2570,17 +2608,38 @@ function renderChatRunningIndicator(thread, now) { }), ); wrap.append(head); - for (const part of threadRunningTools(thread.messages)) { - wrap.append(renderChatRunningTool(thread, part, now)); + // One stable detail line for the whole turn. Rendering one line per in-flight + // tool made the transcript grow and shrink for every call, which bounced the + // text (and the composer) while a turn streamed. The line updates in place to + // the longest-running call; the tool chip in the turn still lists every call. + const running = threadRunningTools(thread.messages); + const chosen = + running.find((part) => toolLongRunning(threadToolElapsedMillis(thread, part, now))) ?? + running[0] ?? + null; + if (chosen) { + wrap.append(renderChatRunningTool(thread, chosen, now)); + } else { + wrap.append( + h( + "div", + { class: "chat-running-tool" }, + h("span", { class: "chat-running-tool-text", text: "Preparing the next step…" }), + ), + ); } return wrap; } -function renderChatRunningTool(thread, part, now) { - const line = h("div", { class: "chat-running-tool", "data-part-id": String(part?.id ?? "") }); +function runningToolText(part) { const name = toolLabel(part); const detail = toolDetail(part); - line.append(h("span", { class: "chat-running-tool-text", text: detail == null ? name : `${name} ${detail}` })); + return detail == null ? name : `${name} ${detail}`; +} + +function renderChatRunningTool(thread, part, now) { + const line = h("div", { class: "chat-running-tool", "data-part-id": String(part?.id ?? "") }); + line.append(h("span", { class: "chat-running-tool-text", text: runningToolText(part) })); line.append( h("span", { class: "chat-running-tool-elapsed muted", @@ -3418,6 +3477,7 @@ function afterChatRender() { }); updateChatJump(el); + restoreChatFocus(); } /** Offer "Jump to latest" only when not following and something is below the fold. */ @@ -3472,14 +3532,20 @@ function updateChatIndicator(now) { if (label) label.textContent = turnPhaseLabel(threadPhase(thread, now) ?? TURN_PHASE_WAITING); const elapsed = el.querySelector(".chat-running-elapsed"); if (elapsed) elapsed.textContent = `\u00b7 ${formatDuration(Math.trunc(threadElapsedMillis(thread, now) / 1000))}`; - for (const part of threadRunningTools(thread.messages)) { - const line = el.querySelector(`.chat-running-tool[data-part-id="${String(part?.id ?? "")}"]`); - if (!line) continue; - const age = threadToolElapsedMillis(thread, part, now); + const running = threadRunningTools(thread.messages); + const chosen = + running.find((part) => toolLongRunning(threadToolElapsedMillis(thread, part, now))) ?? + running[0] ?? + null; + const line = el.querySelector(".chat-running-tool"); + if (line) { + const text = line.querySelector(".chat-running-tool-text"); + if (text && chosen) text.textContent = runningToolText(chosen); + const age = chosen ? threadToolElapsedMillis(thread, chosen, now) : 0; const toolElapsed = line.querySelector(".chat-running-tool-elapsed"); - if (toolElapsed) toolElapsed.textContent = formatToolDuration(age); + if (toolElapsed) toolElapsed.textContent = chosen ? formatToolDuration(age) : ""; const mark = line.querySelector(".chat-tool-long"); - if (toolLongRunning(age) && !mark) { + if (chosen && toolLongRunning(age) && !mark) { line.classList.add("chat-running-tool-long"); line.append(h("span", { class: "chat-tool-long", text: "\u00b7 long" })); }