web: one chat activity line, clearer groups and paste attachments
Replace the reasoning, tool and bottom thinking rows with one stable activity line and refresh Stop on the step frame. Make directory and Closed bands share an elevated square surface, centred text and a collapse toggle. Read pasted files into the composer attachment path and show sent files in user bubbles.
This commit is contained in:
@@ -168,6 +168,10 @@ to it, but the server never lists it and a reload drops it.
|
||||
| B14 | Run a pipeline from the web | `run_pipeline` | done — the pipeline detail has a Run action that opens a dialog with the prompt, an absolute server working-directory field with recent-directory suggestions, and a per-run notification choice (pipeline default / notify / silent). The request carries `pipeline_id`, the pinned version, a fresh request key, `workspace`, `input.prompt` and `notify_mode` only when overriding. A live probe started a real run from the dialog with `notify_mode=off` and the server stored that mode; the run was canceled. |
|
||||
| B15 | Per-run notification override | `notify_mode` | done — `pipelines run --notify auto\|on\|off` (and the same option on retry) records the override with the run. Off suppresses both stage policies and run-level waiting/failed alerts; auto follows the definition; on keeps run-level attention. The mode is stored in `pipeline_runs`, reloaded after a restart, and inherited by a retry unless overridden. |
|
||||
| B16 | One live status line for tools | — | done — the current tool call now shares the `N tools called` line; the separate bottom per-tool line is gone and the lower indicator appears only while no tool is running. The live reasoning label's duration ticks every second without waiting for a frame. Chat frames for a background session no longer repaint a Runs/Pipelines screen: verified a synthetic stream while opening run 12's detail left the run screen interactive with no per-frame replacements. |
|
||||
| B17 | Clear list chrome and chat recency | — | done — list pages no longer repeat the destination title/subtitle from the rail/dock, and the manual Refresh controls are gone; the visible list refreshes once when the page regains focus, preserving its scroll position and leaving open menus, dialogs and text fields alone. Chat rows replace the meaningless `Idle`/`Open` status with the server's latest-update recency (`just now`, `15 min ago`, `2 days ago`), keep `Streaming`/`New`/`Closed`, and give each directory a full-width elevated band with centred text that expands/collapses exactly like Closed (square corners, not a rounded chip). `New chat` is now a filled primary control beside the search field. Runs and Pipelines use the same title-free list header. Verified at 390×844 and 1440×900 in a real browser, with no console errors; the web unit suite is 633 tests. |
|
||||
| B18 | Chat attachments in the message and paste | `chat_prompt.attachments` | done — composer files are read into base64 and sent with the prompt (1 MiB total, under the 2 MiB websocket frame), the server writes them to private temporary files and passes `file://` references to OpenCode's prompt `files`, and both the live user turn and reloaded history render a named file chip inside the message. Pasting an image/file into the textarea attaches it with the same picker path; a pasted image without a filename gets a generated name. The optimistic user bubble shows the file immediately, and OpenCode history maps the top-level user `files` envelope (never its base64 data) into the same part. |
|
||||
| B19 | One live chat activity line and immediate Stop | — | done — every in-flight turn now has one square activity row carrying the spinner, `Thinking`/`Reasoning · N steps`, the tool-call chip with its current call, and the elapsed time; the separate reasoning, tool and bottom "thinking" lines are gone. The row stays in place when the turn settles (spinner off), and the elapsed ticks locally each second. The composer's Stop is refreshed on the step frame itself, so it appears for turns started by another client and stays through tool calls. A subscribe that joins a live turn replays a `step started` marker. Cancel now marks the run and its live step canceled immediately before interrupting the runner, so a context-unaware stage cannot leave a "running" row after Stop. |
|
||||
| B20 | Cancel a running run immediately | `cancel_run` | done — `runner.cancel` persists `canceled` on the run and its live step before calling the runner's cancel function; late stage returns cannot overwrite it (`FinishRun` only updates queued/running, and a failed step persistence is reported as canceled, not a failure). This also covers orphaned running rows with no active goroutine and waiting runs. Verified by store tests and the run that had been stuck at run 13 is now interrupted/canceled rather than running. |
|
||||
| B13 | Codex chat backend | `chat_backends`, `chat_create.backend` | done — OpenCode stays the default. `chat_backends` lists `codex` when the Codex App Server control socket is present; New chat shows a harness choice, the selected backend is stored on the operator-session row and echoed on every session. The Codex adapter connects to the existing App Server over its Unix WebSocket, maps `thread/start`, `turn/start`, `thread/read`, item/tool events, `item/tool/requestUserInput` to the existing question card, and carries the native user-message id so optimistic and history turns reconcile. Verified live: created a Codex chat from the browser, sent a prompt, saw the streamed answer, read it back through `chat_messages`, and saw the Codex chip and title in the list. Claude is not advertised yet: its OAuth session is expired and the SDK/CLI sidecar is still to be built. |
|
||||
| B12 | One detail header, optimistic sends, thinking above the bubble | — | done — every non-chat detail (pipeline, run, template) now extracts its own `#detailTitle` into a shared `.detail-head` with the same 44px chevron Back control; on phones the button and title are vertically centred, and on wide screens the back control is hidden while the title stays in the header. Chat/create already use the same control. Sending now appends the operator's optimistic user turn immediately (using the native message id OpenCode persists), so the running placeholder cannot appear before their message. While a turn runs, Send stays present beside Stop; a follow-up is queued. The reasoning/thinking block moved outside and above the answer bubble, like the tool summary below it. |
|
||||
| B11 | Enter composes; live shell bars stay in place | — | done — Enter now inserts a newline (a real CDP Enter produced `first\n` and no prompt), while Ctrl/Cmd+Enter sends; a slash draft still runs its command on Enter. The chat star reserves a 26px corner in the row head, so it no longer covers Streaming/New/Idle. Background-shell frames patch the tasks bar in place instead of full-rendering the pane, keeping the composer mounted. The shell cache was bumped to v2 so an installed PWA picks up these client changes. |
|
||||
|
||||
@@ -21,6 +21,20 @@ body {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* Keep a heading available to landmarks and focus restoration without printing
|
||||
a second copy of the destination name the rail/dock already shows. */
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
|
||||
+120
-18
@@ -12,7 +12,34 @@
|
||||
open, mirroring `.list.runs`' filter-menu treatment. */
|
||||
.chat-list.menu-open { overflow: visible; }
|
||||
.chat-search { flex: 1 1 auto; min-width: 0; }
|
||||
.chat-toolbar .chat-new { white-space: nowrap; }
|
||||
.chat-toolbar {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
.chat-toolbar .chat-search { min-height: 38px; }
|
||||
.chat-new {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 7px;
|
||||
flex: none;
|
||||
min-height: 38px;
|
||||
padding: 0 13px;
|
||||
border: 1px solid var(--color-accent);
|
||||
background: var(--color-accent);
|
||||
color: var(--color-on-accent);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chat-new:hover,
|
||||
.chat-new:focus-visible {
|
||||
background: var(--color-accent-strong);
|
||||
border-color: var(--color-accent-strong);
|
||||
color: var(--color-on-accent);
|
||||
}
|
||||
.chat-new-glyph { font-size: 18px; line-height: 1; font-weight: 500; }
|
||||
.chat-new-label { font-size: 13px; }
|
||||
|
||||
/* C2: the create pane — the directory picker, the model note and the footer that
|
||||
names the value chat_create will send. */
|
||||
@@ -68,33 +95,57 @@
|
||||
.chat-create-cancel:disabled { opacity: 0.55; }
|
||||
.chat-create-spinner { width: 14px; height: 14px; border-width: 2px; }
|
||||
|
||||
.chat-group-header {
|
||||
padding: 8px 12px 4px;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
/* The CLOSED group's own expand/collapse control; the chevron sits at its end. */
|
||||
/* A directory or Closed section is a full-width band, not a small label over
|
||||
the rows: a distinct surface, centred text and (for both) one expand toggle.
|
||||
The band is square so it reads as a divider rather than a floating chip. */
|
||||
.chat-group-header,
|
||||
.chat-group-toggle {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding: 8px 12px 4px;
|
||||
min-height: 34px;
|
||||
margin: 0;
|
||||
padding: 8px 42px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
border-top: 1px solid var(--border);
|
||||
border-radius: 0;
|
||||
background: var(--color-elevated);
|
||||
color: var(--muted);
|
||||
font: inherit;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.04em;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
}
|
||||
.chat-group-toggle { cursor: pointer; }
|
||||
.chat-group-toggle:hover { background: var(--color-elevated-2); color: var(--color-text); }
|
||||
.chat-group-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
||||
.chat-group-title {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chat-group-directory .chat-group-title {
|
||||
color: var(--color-text);
|
||||
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
||||
font-size: 11.5px;
|
||||
letter-spacing: 0;
|
||||
text-transform: none;
|
||||
}
|
||||
.chat-group-starred .chat-group-title { color: var(--accent); }
|
||||
.chat-group-toggle .chevron {
|
||||
position: absolute;
|
||||
right: 14px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
text-transform: none;
|
||||
}
|
||||
.chat-group-toggle:hover { color: var(--color-text); }
|
||||
.chat-group-toggle .chevron { font-size: 12px; text-transform: none; }
|
||||
|
||||
.chat-row {
|
||||
position: relative;
|
||||
display: grid;
|
||||
@@ -137,6 +188,11 @@
|
||||
}
|
||||
.chat-row .row-title { min-width: 0; }
|
||||
.chat-row .row-meta { grid-column: 1; }
|
||||
.chat-row .chat-row-meta {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chat-row-model { font-size: 11px; }
|
||||
/* Star (top-right) and the more menu (bottom-right) sit over the row's own
|
||||
corners on hover/focus, so they never become an extra row or reserve width. */
|
||||
@@ -323,6 +379,26 @@
|
||||
}
|
||||
.chat-client { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
|
||||
.chat-user-text { white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
.chat-user-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
|
||||
.chat-user-file {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
|
||||
border-radius: var(--radius-control);
|
||||
background: color-mix(in srgb, var(--accent) 8%, transparent);
|
||||
font-size: 12px;
|
||||
}
|
||||
.chat-user-file-glyph { flex: none; font-size: 13px; line-height: 1; }
|
||||
.chat-user-file-name {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chat-turn-agent { flex-direction: column; align-items: flex-start; }
|
||||
/* The tool summary is a quiet line next to the message, not a chip inside it. */
|
||||
.chat-tools { margin: 2px 0 10px; }
|
||||
@@ -343,10 +419,29 @@
|
||||
padding: 0 2px;
|
||||
border-bottom: 0;
|
||||
}
|
||||
.chat-activity-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
min-height: 22px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chat-activity-spinner { width: 12px; height: 12px; border-width: 2px; flex: none; }
|
||||
.chat-activity-phase,
|
||||
.chat-activity-elapsed {
|
||||
color: var(--muted);
|
||||
font-size: 11.5px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.chat-activity-elapsed { flex: none; }
|
||||
.chat-activity-sep { color: var(--muted); flex: none; }
|
||||
.chat-activity-head > .chat-tool-chip { min-width: 0; overflow: hidden; }
|
||||
.chat-reasoning-toggle {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
flex: none;
|
||||
padding: 2px 0;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
@@ -923,6 +1018,13 @@
|
||||
|
||||
/* ---- Phone comfort ------------------------------------------------------ */
|
||||
@media (max-width: 599px) {
|
||||
.chat-toolbar { padding: 10px 12px; }
|
||||
.chat-toolbar .chat-search { min-height: 44px; font-size: 15px; }
|
||||
.chat-new { min-height: 44px; padding: 0 14px; }
|
||||
.chat-new-label { font-size: 14px; }
|
||||
.chat-group-header,
|
||||
.chat-group-toggle { min-height: 40px; padding: 10px 42px; font-size: 12px; }
|
||||
.chat-group-directory .chat-group-title { font-size: 12px; }
|
||||
.chat-row { min-height: 96px; }
|
||||
.chat-row .row-head { padding-right: 50px; }
|
||||
.chat-star {
|
||||
|
||||
@@ -189,6 +189,14 @@
|
||||
|
||||
.pane-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 12px 0; }
|
||||
.pane-head .pane-title { margin: 0; font-size: 16px; }
|
||||
/* The destination is already named by the rail/dock; the list header is now an
|
||||
action strip, not a second title block. */
|
||||
.pane-head-compact {
|
||||
min-height: 44px;
|
||||
padding: 6px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.pane-head-compact .pane-head-actions { margin-left: auto; }
|
||||
|
||||
.gallery { padding-bottom: 8px; }
|
||||
.cards { display: grid; gap: var(--space-xs); padding: var(--space-s); align-content: start; }
|
||||
|
||||
+63
-66
@@ -187,6 +187,7 @@ const state = {
|
||||
...readLayoutPrefs(),
|
||||
// Whether the CLOSED chats group is expanded (the chevron beside its name).
|
||||
chatClosedOpen: false,
|
||||
chatCollapsedDirs: new Set(),
|
||||
// The last time each destination's data arrived (manual refresh or a socket
|
||||
// push); the list's Refresh button shows it on hover.
|
||||
lastUpdated: {},
|
||||
@@ -927,13 +928,15 @@ function renderSectionMounts() {
|
||||
* The list pane's heading. On the list-only route the destination is the h1; on
|
||||
* a detail route the detail title is the route h1 and this becomes the list's h2.
|
||||
*/
|
||||
function paneHeading(title, { detailOpen, subtitle = "", actions = [] } = {}) {
|
||||
function paneHeading(title, { detailOpen, actions = [] } = {}) {
|
||||
const tag = detailOpen ? "h2" : "h1";
|
||||
const head = h(
|
||||
"div",
|
||||
{ class: "pane-head" },
|
||||
h("div", { class: "pane-head-text" }, h(tag, { class: "pane-title", id: "listTitle", text: title }), subtitle ? h("h2", { class: "pane-subtitle", text: subtitle }) : null),
|
||||
);
|
||||
// The destination rail/dock already names the screen. Keep the heading in the
|
||||
// accessibility tree for landmarks and focus restoration, but do not print it
|
||||
// twice above the list. A narrow header exists only when it carries an action
|
||||
// (the Runs attention bell); otherwise the list starts with its own toolbar.
|
||||
const heading = h(tag, { class: "pane-title sr-only", id: "listTitle", tabindex: "-1", text: title });
|
||||
if (!isWideLayout() && actions.length === 0) return heading;
|
||||
const head = h("div", { class: "pane-head pane-head-compact" }, heading);
|
||||
head.append(h("div", { class: "pane-head-actions" }, ...actions, listCollapseButton()));
|
||||
return head;
|
||||
}
|
||||
@@ -965,19 +968,6 @@ function applyLayoutState() {
|
||||
writeLayoutPrefs(state);
|
||||
}
|
||||
|
||||
function listSubtitle(view) {
|
||||
switch (view) {
|
||||
case "runs":
|
||||
return "Run history";
|
||||
case "chat":
|
||||
return "Chat sessions";
|
||||
case "templates":
|
||||
return "Available templates";
|
||||
default:
|
||||
return "All pipelines";
|
||||
}
|
||||
}
|
||||
|
||||
function backButton(view) {
|
||||
return h(
|
||||
"button",
|
||||
@@ -1164,11 +1154,7 @@ function renderContent() {
|
||||
h(
|
||||
"section",
|
||||
{ class: "list-pane", "aria-label": "Pipelines list" },
|
||||
paneHeading("Pipelines", {
|
||||
detailOpen,
|
||||
subtitle: listSubtitle(view),
|
||||
actions: [refreshButton()],
|
||||
}),
|
||||
paneHeading("Pipelines", { detailOpen }),
|
||||
renderPipelineList(),
|
||||
),
|
||||
detailPaneFor(view, renderPipelineDetail(), { detailOpen, tabs: model.tabs }),
|
||||
@@ -1178,11 +1164,7 @@ function renderContent() {
|
||||
h(
|
||||
"section",
|
||||
{ class: "list-pane", "aria-label": "Runs list" },
|
||||
paneHeading("Runs", {
|
||||
detailOpen,
|
||||
subtitle: listSubtitle(view),
|
||||
actions: [renderAttentionBell(), refreshButton()],
|
||||
}),
|
||||
paneHeading("Runs", { detailOpen }),
|
||||
renderRunList(),
|
||||
),
|
||||
detailPaneFor(view, renderRunDetail(), { detailOpen, tabs: model.tabs }),
|
||||
@@ -1192,11 +1174,7 @@ function renderContent() {
|
||||
h(
|
||||
"section",
|
||||
{ class: "list-pane", "aria-label": "Templates list" },
|
||||
paneHeading("Templates", {
|
||||
detailOpen,
|
||||
subtitle: listSubtitle(view),
|
||||
actions: [h("button", { class: "ghost", type: "button", text: "Refresh templates", onclick: () => loadTemplates(true) })],
|
||||
}),
|
||||
paneHeading("Templates", { detailOpen }),
|
||||
renderTemplateGallery(),
|
||||
),
|
||||
detailPaneFor(view, renderTemplateDetail(), { detailOpen, tabs: model.tabs }),
|
||||
@@ -1206,11 +1184,7 @@ function renderContent() {
|
||||
h(
|
||||
"section",
|
||||
{ class: "list-pane", "aria-label": "Chat list" },
|
||||
paneHeading("Chat", {
|
||||
detailOpen,
|
||||
subtitle: listSubtitle(view),
|
||||
actions: [refreshButton()],
|
||||
}),
|
||||
paneHeading("Chat", { detailOpen }),
|
||||
renderChatList(),
|
||||
),
|
||||
);
|
||||
@@ -1297,34 +1271,9 @@ function renderContent() {
|
||||
}
|
||||
}
|
||||
|
||||
/** The last-updated words for a view, local time, or the not-yet-loaded note. */
|
||||
function lastUpdatedTitle(view) {
|
||||
const at = Number(state.lastUpdated?.[view] ?? 0);
|
||||
if (!(at > 0)) return "Not refreshed yet";
|
||||
return `Last updated ${new Date(at).toLocaleTimeString([], {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
})}`;
|
||||
}
|
||||
|
||||
/** Record that a view's data just arrived, and refresh the hover title in place. */
|
||||
/** Record that a view's data just arrived. */
|
||||
function touchView(view = state.view) {
|
||||
state.lastUpdated = { ...(state.lastUpdated ?? {}), [view]: Date.now() };
|
||||
if (view !== state.view) return;
|
||||
const button = document.querySelector('.list-pane [data-refresh="true"]');
|
||||
if (button) button.title = lastUpdatedTitle(view);
|
||||
}
|
||||
|
||||
function refreshButton() {
|
||||
return h("button", {
|
||||
class: "ghost",
|
||||
type: "button",
|
||||
text: "Refresh",
|
||||
title: lastUpdatedTitle(state.view),
|
||||
"data-refresh": "true",
|
||||
onclick: () => loadCurrentView(true),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1825,6 +1774,51 @@ async function loadCurrentView(force = false, { runsFresh = false } = {}) {
|
||||
// The live run stream (R10)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Whether the current destination is showing a detail rather than its list. */
|
||||
function detailIsOpen(view = state.view) {
|
||||
switch (view) {
|
||||
case "pipelines":
|
||||
return state.selectedPipelineId != null;
|
||||
case "runs":
|
||||
return state.selectedRunId != null;
|
||||
case "chat":
|
||||
return state.chatActiveId != null || state.chatCreate != null;
|
||||
case "templates":
|
||||
return state.selectedTemplateKey != null;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returning to the page refreshes the visible list once, in place. The manual
|
||||
* Refresh controls are gone; live streams cover work in progress and a list that
|
||||
* changed elsewhere is picked up on focus instead of waiting for a reload.
|
||||
* Menus, dialogs and text fields are left alone so a return never closes what the
|
||||
* operator was using.
|
||||
*/
|
||||
let foregroundRefreshTimer = null;
|
||||
|
||||
function refreshVisibleListOnForeground() {
|
||||
if (typeof document === "undefined" || document.visibilityState !== "visible") return;
|
||||
if (state.connection.kind !== "connected" || state.loading) return;
|
||||
if (state.view === "settings" || detailIsOpen()) return;
|
||||
if (state.searchOpen || state.runStart || state.chatCreate) return;
|
||||
if (state.chatMenu != null || state.openMenu || state.pipelineMenu) return;
|
||||
const active = document.activeElement;
|
||||
if (active instanceof Element && active.matches("input, textarea, select")) return;
|
||||
if (foregroundRefreshTimer) return;
|
||||
foregroundRefreshTimer = setTimeout(async () => {
|
||||
foregroundRefreshTimer = null;
|
||||
if (state.connection.kind !== "connected" || state.loading || detailIsOpen()) return;
|
||||
const before = document.querySelector(".list-pane .list-scroll");
|
||||
const top = before?.scrollTop ?? 0;
|
||||
await loadCurrentView(true);
|
||||
const after = document.querySelector(".list-pane .list-scroll");
|
||||
if (after && top > 0) after.scrollTop = top;
|
||||
}, 300);
|
||||
}
|
||||
|
||||
/** Render whatever a run-state change touched, without re-reading anything. */
|
||||
function renderRunState() {
|
||||
if (state.view === "runs" || state.view === "pipelines") renderContent();
|
||||
@@ -2582,8 +2576,11 @@ document.addEventListener("click", (event) => {
|
||||
// browser reports it is back online, and the client drives its socket back
|
||||
// without waiting out the backoff. DOM-only, and idempotent.
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (document.visibilityState === "visible") onForegroundActive();
|
||||
if (document.visibilityState !== "visible") return;
|
||||
onForegroundActive();
|
||||
refreshVisibleListOnForeground();
|
||||
});
|
||||
window.addEventListener("focus", refreshVisibleListOnForeground);
|
||||
window.addEventListener("online", onForegroundActive);
|
||||
|
||||
// Prefill from a previous session only; the user still confirms with Connect.
|
||||
|
||||
+27
-1
@@ -61,6 +61,7 @@ export const ROLE_ASSISTANT = "assistant";
|
||||
export const PART_TEXT = "text";
|
||||
export const PART_REASONING = "reasoning";
|
||||
export const PART_TOOL = "tool";
|
||||
export const PART_FILE = "file";
|
||||
|
||||
/** ChatSession.Tag values, and the one display label derived from them. */
|
||||
export const TAG_OPERATOR = "operator";
|
||||
@@ -551,6 +552,28 @@ export function sessionActivity(running, unseen) {
|
||||
return "idle";
|
||||
}
|
||||
|
||||
/**
|
||||
* How long ago the session last changed, in the list's own words: `just now`,
|
||||
* `2 min ago`, `3 hr ago`, `2 days ago`, then a short date for older chats. The
|
||||
* server's `updated_at` is milliseconds, matching the seen watermark.
|
||||
*/
|
||||
export function relativeSessionTime(updatedAt, now = Date.now()) {
|
||||
const then = millis(updatedAt);
|
||||
if (then <= 0) return "";
|
||||
const elapsed = Math.max(0, Number(now) - then);
|
||||
const seconds = Math.floor(elapsed / 1000);
|
||||
if (seconds < 45) return "just now";
|
||||
const minutes = Math.max(1, Math.floor(seconds / 60));
|
||||
if (minutes < 60) return `${minutes} min ago`;
|
||||
const hours = Math.floor(minutes / 60);
|
||||
if (hours < 24) return `${hours} hr ago`;
|
||||
const days = Math.floor(hours / 24);
|
||||
if (days < 7) return days === 1 ? "1 day ago" : `${days} days ago`;
|
||||
return new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short" }).format(
|
||||
new Date(then),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The activity badge word, or null when the row shows none. An idle session
|
||||
* shows `Open` only while its conversation is open; a streaming or unseen one
|
||||
@@ -1578,13 +1601,16 @@ function applyRemoteUser(thread, frame) {
|
||||
return thread;
|
||||
}
|
||||
if (messages.some((message) => message?.id === messageId)) return thread;
|
||||
const files = (frame?.attachments ?? []).filter(
|
||||
(part) => part?.type === PART_FILE && (str(part?.name) !== "" || str(part?.uri) !== ""),
|
||||
);
|
||||
const message = {
|
||||
id: messageId,
|
||||
session_id: str(frame?.session_id),
|
||||
role: ROLE_USER,
|
||||
client: str(frame?.client),
|
||||
operation_id: operationId,
|
||||
parts: [{ type: PART_TEXT, text }],
|
||||
parts: [{ type: PART_TEXT, text }, ...files],
|
||||
};
|
||||
return { ...thread, messages: [...messages, message] };
|
||||
}
|
||||
|
||||
+263
-173
@@ -81,7 +81,6 @@ import {
|
||||
approvalCard,
|
||||
attachmentDisplayName,
|
||||
attachmentError,
|
||||
attachmentFiles,
|
||||
backgroundTasksRunningLabel,
|
||||
chatBottomDistancePx,
|
||||
chatCommandEffect,
|
||||
@@ -126,6 +125,7 @@ import {
|
||||
queuedAfterFrame,
|
||||
readChatSeen,
|
||||
reasoningLabel,
|
||||
relativeSessionTime,
|
||||
renameChatOverride,
|
||||
restoreChatOverride,
|
||||
resumedThread,
|
||||
@@ -144,10 +144,8 @@ import {
|
||||
shellOutputState,
|
||||
shellsLoaded,
|
||||
takeChatNoticeOffer as takeChatNoticeOfferModel,
|
||||
formatToolDuration,
|
||||
threadElapsedMillis,
|
||||
threadPhase,
|
||||
threadRunningTools,
|
||||
threadToolElapsedMillis,
|
||||
TURN_PHASE_WAITING,
|
||||
toolCallCount,
|
||||
@@ -764,8 +762,17 @@ function onChatEvent(frame) {
|
||||
// read the newest history once so the user message (and anything else the page
|
||||
// missed) appears without a manual refresh.
|
||||
const knownTurn = messageId !== "" && (thread.messages ?? []).some((m) => m?.id === messageId);
|
||||
state.chatThreads.set(sessionId, applyChatEvent(thread, frame, Date.now()));
|
||||
const wasRunning = thread.running === true;
|
||||
const wasQueued = thread.queued === true;
|
||||
const next = applyChatEvent(thread, frame, Date.now());
|
||||
state.chatThreads.set(sessionId, next);
|
||||
if (state.view === "chat" && sessionId === state.chatActiveId) {
|
||||
// The composer's Stop lives outside the transcript. A step frame changes
|
||||
// running here, so update the mounted primary control now; the transcript-only
|
||||
// repaint below leaves the composer in place.
|
||||
if (next.running !== wasRunning || next.queued !== wasQueued) {
|
||||
refreshChatComposerState(sessionId);
|
||||
}
|
||||
scheduleChatRender("transcript");
|
||||
}
|
||||
if (!knownTurn) scheduleHistorySync(sessionId, messageId);
|
||||
@@ -1598,14 +1605,21 @@ async function sendChatPrompt(sessionId, session) {
|
||||
// Show the operator's own turn at once, with the id OpenCode will persist.
|
||||
// Waiting for the first assistant frame made the running placeholder appear
|
||||
// before the message the operator just sent.
|
||||
const fileParts = attachments
|
||||
.filter((attachment) => attachment?.error == null)
|
||||
.map((attachment) => ({
|
||||
type: "file",
|
||||
name: String(attachment.name ?? ""),
|
||||
uri: String(attachment.uri ?? attachment.name ?? ""),
|
||||
mime: String(attachment.mime ?? ""),
|
||||
}));
|
||||
const optimistic = {
|
||||
id: messageId || `local-${operationId}`,
|
||||
session_id: sessionId,
|
||||
role: "user",
|
||||
operation_id: operationId,
|
||||
parts: [{ type: "text", text }],
|
||||
parts: [{ type: "text", text }, ...fileParts],
|
||||
};
|
||||
releaseAttachments(attachments);
|
||||
setThread(sessionId, {
|
||||
draft: "",
|
||||
attachments: [],
|
||||
@@ -1632,7 +1646,11 @@ async function postChatPrompt(sessionId, text, attachments, { operationId, optim
|
||||
setThread(sessionId, { running: true });
|
||||
renderContent();
|
||||
try {
|
||||
const queued = await repo.chatPrompt(sessionId, body, attachmentFiles(attachments), operationId);
|
||||
const payloads = await chatAttachmentPayloads(attachments);
|
||||
// The optimistic message and the wire copy are built; the File objects and
|
||||
// their preview URLs are no longer needed.
|
||||
releaseAttachments(attachments);
|
||||
const queued = await repo.chatPrompt(sessionId, body, [], operationId, payloads);
|
||||
const thread = state.chatThreads.get(sessionId);
|
||||
if (!thread) return;
|
||||
// Prompting a closed session reopens it on the server; clear the local mark
|
||||
@@ -1671,21 +1689,84 @@ function sendChatCommandOffer(sessionId, noticeId) {
|
||||
postChatPrompt(sessionId, offer, []);
|
||||
}
|
||||
|
||||
// The websocket frame that carries a prompt is bounded at 2 MiB, and base64
|
||||
// expands bytes by a third. This keeps ordinary screenshots and text files
|
||||
// usable without risking a frame the server refuses. The server enforces the
|
||||
// same budget again.
|
||||
const MAX_CHAT_ATTACHMENT_BYTES = 1 << 20;
|
||||
|
||||
/** Encode an ArrayBuffer as standard base64 without a huge spread call. */
|
||||
function base64FromBuffer(buffer) {
|
||||
const bytes = new Uint8Array(buffer);
|
||||
let binary = "";
|
||||
const chunk = 0x8000;
|
||||
for (let offset = 0; offset < bytes.length; offset += chunk) {
|
||||
binary += String.fromCharCode(...bytes.subarray(offset, offset + chunk));
|
||||
}
|
||||
return btoa(binary);
|
||||
}
|
||||
|
||||
/** Read the pending files into the wire attachment shape, or explain why not. */
|
||||
async function chatAttachmentPayloads(attachments) {
|
||||
const valid = (attachments ?? []).filter((attachment) => attachment?.error == null);
|
||||
if (valid.length === 0) return [];
|
||||
let total = 0;
|
||||
const payloads = [];
|
||||
for (const attachment of valid) {
|
||||
if (!attachment?.file || typeof attachment.file.arrayBuffer !== "function") {
|
||||
throw new Error(`"${attachmentDisplayName(attachment?.name, attachment?.uri)}" could not be read.`);
|
||||
}
|
||||
const buffer = await attachment.file.arrayBuffer();
|
||||
total += buffer.byteLength;
|
||||
if (total > MAX_CHAT_ATTACHMENT_BYTES) {
|
||||
throw new Error("Attachments are too large for web chat (1 MiB total).");
|
||||
}
|
||||
payloads.push({
|
||||
name: String(attachment.name ?? "").trim() || "attachment",
|
||||
mime: String(attachment.mime ?? "").trim() || "application/octet-stream",
|
||||
data: base64FromBuffer(buffer),
|
||||
});
|
||||
}
|
||||
return payloads;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the files the operator picked into composer attachments. Only the
|
||||
* metadata is read here (nothing is transmitted until the message is sent): the
|
||||
* browser has no `content://` reference, so the file's own name is carried as the
|
||||
* best-effort reference string. A file over the limit is returned with its error
|
||||
* set rather than dropped.
|
||||
* Resolve the files the operator picked or pasted into composer attachments.
|
||||
* Only the metadata is read here (nothing is transmitted until the message is
|
||||
* sent); a file over the limit is returned with its error set rather than
|
||||
* dropped.
|
||||
*/
|
||||
function pastedAttachmentName(mime, sequence) {
|
||||
const subtype = String(mime ?? "").split("/").pop()?.toLowerCase() ?? "";
|
||||
const extension = subtype === "jpeg" ? "jpg" : subtype.replace(/[^a-z0-9]/g, "") || "bin";
|
||||
return `pasted-${sequence}.${extension}`;
|
||||
}
|
||||
|
||||
/** Attach files pasted into the composer (an image or copied file). */
|
||||
function onComposerPaste(event, sessionId, session) {
|
||||
const data = event.clipboardData;
|
||||
if (!data) return;
|
||||
const files = [];
|
||||
for (const item of data.items ?? []) {
|
||||
if (item?.kind !== "file") continue;
|
||||
const file = item.getAsFile?.();
|
||||
if (file) files.push(file);
|
||||
}
|
||||
if (files.length === 0) return;
|
||||
// A pasted image has no editable text; keep the composer's own text untouched
|
||||
// and attach the clipboard file as the next message's attachment.
|
||||
event.preventDefault();
|
||||
onChatFilesPicked(sessionId, session, files);
|
||||
}
|
||||
|
||||
function onChatFilesPicked(sessionId, session, fileList) {
|
||||
const thread = state.chatThreads.get(sessionId);
|
||||
if (!thread) return;
|
||||
const picked = [];
|
||||
for (const file of fileList ?? []) {
|
||||
chatAttachmentSeq += 1;
|
||||
const name = String(file?.name ?? "");
|
||||
const mime = String(file?.type ?? "");
|
||||
const name = String(file?.name ?? "").trim() || pastedAttachmentName(mime, chatAttachmentSeq);
|
||||
const size = Number(file?.size) || 0;
|
||||
picked.push({
|
||||
id: `att-${chatAttachmentSeq}`,
|
||||
@@ -1724,6 +1805,22 @@ function removeChatAttachment(sessionId, attachmentId) {
|
||||
renderContent();
|
||||
}
|
||||
|
||||
/** The one New chat control: a real primary action, not a quiet text link. */
|
||||
function chatNewButton() {
|
||||
return h(
|
||||
"button",
|
||||
{
|
||||
class: "chat-new",
|
||||
type: "button",
|
||||
title: CHAT_NEW_ACTION,
|
||||
"aria-label": CHAT_NEW_ACTION,
|
||||
onclick: startNewChat,
|
||||
},
|
||||
h("span", { class: "chat-new-glyph", "aria-hidden": "true", text: "+" }),
|
||||
h("span", { class: "chat-new-label", text: CHAT_NEW_ACTION }),
|
||||
);
|
||||
}
|
||||
|
||||
function renderChatList() {
|
||||
// The open menu must not be clipped by the list's rounded-corner overflow; the
|
||||
// class is present only while a menu is open, so the normal list stays clipped.
|
||||
@@ -1746,12 +1843,7 @@ function renderChatList() {
|
||||
}),
|
||||
// C2: the create path stays one tap away while the list is narrowed, the same
|
||||
// trailing action the app keeps beside its search control.
|
||||
h("button", {
|
||||
class: "ghost chat-new",
|
||||
type: "button",
|
||||
text: CHAT_NEW_ACTION,
|
||||
onclick: startNewChat,
|
||||
}),
|
||||
chatNewButton(),
|
||||
);
|
||||
list.append(toolbar);
|
||||
const rows = h("div", { id: "chatRows", class: "chat-rows list-scroll" });
|
||||
@@ -1795,14 +1887,7 @@ function fillChatRows(rows) {
|
||||
}
|
||||
if (filtered.length === 0) {
|
||||
const empty = chatEmpty(CHAT_EMPTY);
|
||||
empty.append(
|
||||
h("button", {
|
||||
class: "ghost chat-new",
|
||||
type: "button",
|
||||
text: CHAT_NEW_ACTION,
|
||||
onclick: startNewChat,
|
||||
}),
|
||||
);
|
||||
empty.append(chatNewButton());
|
||||
rows.append(empty);
|
||||
return;
|
||||
}
|
||||
@@ -1818,14 +1903,40 @@ function fillChatRows(rows) {
|
||||
// per-row actions name can include the session id only when it is needed.
|
||||
const duplicateTitles = duplicateChatTitles(filtered);
|
||||
if (starred.length > 0) {
|
||||
rows.append(h("div", { class: "chat-group-header", text: "Starred" }));
|
||||
rows.append(
|
||||
h(
|
||||
"div",
|
||||
{ class: "chat-group-header chat-group-starred" },
|
||||
h("span", { class: "chat-group-title", text: "Starred" }),
|
||||
),
|
||||
);
|
||||
for (const session of starred) rows.append(renderChatRow(session, duplicateTitles));
|
||||
}
|
||||
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, duplicateTitles));
|
||||
const label = directoryLabel(group.directory);
|
||||
const key = String(group.directory ?? "");
|
||||
const collapsed = state.chatCollapsedDirs?.has?.(key) === true;
|
||||
const toggle = h("button", {
|
||||
class: "chat-group-header chat-group-toggle chat-group-directory",
|
||||
type: "button",
|
||||
title: label,
|
||||
"aria-expanded": collapsed ? "false" : "true",
|
||||
"aria-label": `${collapsed ? "Expand" : "Collapse"} ${label}`,
|
||||
onclick: () => {
|
||||
if (!state.chatCollapsedDirs) state.chatCollapsedDirs = new Set();
|
||||
if (collapsed) state.chatCollapsedDirs.delete(key);
|
||||
else state.chatCollapsedDirs.add(key);
|
||||
renderContent();
|
||||
},
|
||||
});
|
||||
toggle.append(h("span", { class: "chat-group-title", text: label }));
|
||||
toggle.append(h("span", { class: "chevron", text: collapsed ? "\u25b8" : "\u25be" }));
|
||||
rows.append(toggle);
|
||||
if (!collapsed) {
|
||||
for (const session of group.sessions) rows.append(renderChatRow(session, duplicateTitles));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const session of active) rows.append(renderChatRow(session, duplicateTitles));
|
||||
@@ -1909,7 +2020,10 @@ function renderChatRow(session, duplicateTitles = new Set()) {
|
||||
opened: state.chatThreads.has(session.id),
|
||||
});
|
||||
const activity = sessionActivity(thread?.running === true, unseen);
|
||||
const badge = sessionActivityBadge(activity, open);
|
||||
// `Idle` and `Open` said nothing about a chat; the row's recency does. Keep a
|
||||
// badge only when the session is genuinely doing something or has news.
|
||||
const badge = activity === "idle" ? "" : sessionActivityBadge(activity, open);
|
||||
const updated = relativeSessionTime(session.updated_at);
|
||||
// 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", {
|
||||
@@ -1946,9 +2060,9 @@ function renderChatRow(session, duplicateTitles = new Set()) {
|
||||
head.append(h("span", { class: `chat-activity ${statusClass}`, text: statusWord }));
|
||||
}
|
||||
sessionButton.append(head);
|
||||
const directory = String(session.directory ?? "").trim();
|
||||
if (directory !== "") {
|
||||
sessionButton.append(h("span", { class: "row-meta chat-row-meta", text: directory }));
|
||||
const meta = [updated, String(session.directory ?? "").trim()].filter(Boolean).join(" \u00b7 ");
|
||||
if (meta !== "") {
|
||||
sessionButton.append(h("span", { class: "row-meta chat-row-meta", text: meta }));
|
||||
}
|
||||
const model = String(session.model ?? "").trim();
|
||||
if (model !== "") {
|
||||
@@ -2549,11 +2663,13 @@ function renderChatTranscript(
|
||||
transcript.append(renderChatAgentTurn(row.turn, streaming, elapsed, thread));
|
||||
}
|
||||
});
|
||||
// The running indicator sits under the transcript, after the last agent turn:
|
||||
// a spinner, the phase headline, the turn's elapsed, then one line per running
|
||||
// tool (a call over 60 s is tinted and marked `· long`).
|
||||
if (running && thread && threadRunningTools(thread.messages).length === 0) {
|
||||
transcript.append(renderChatRunningIndicator(thread, now));
|
||||
// The live turn's one activity row lives inside the last agent turn. If the
|
||||
// turn has not produced an assistant row yet (the operator just sent the
|
||||
// prompt), show the same row after their message instead of a second indicator.
|
||||
const lastRow = rows[rows.length - 1] ?? null;
|
||||
if (running && lastRow?.kind !== "agent") {
|
||||
const placeholder = { key: `pending:${sessionId}`, parts: [], reasoning: "", reasoningSteps: [], tools: [] };
|
||||
transcript.append(renderChatActivity(placeholder, true, () => 0, thread));
|
||||
}
|
||||
// The conversation's local command lines sit after the turns, full width and
|
||||
// deliberately unlike a message bubble (see ChatCommandNoticeItem).
|
||||
@@ -2804,71 +2920,33 @@ function approvalControl(label, decision, sessionId, requestId, extraClass = "")
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The in-flight turn's indicator: a spinner, the phase headline (`Thinking…` /
|
||||
* `Running a tool…` / `Waiting…`), `· {elapsed}`, then one line per running tool
|
||||
* with its own elapsed. A call that has passed [TOOL_LONG_RUNNING_MILLIS] is
|
||||
* tinted and marked `· long` — the same threshold the tool chip uses.
|
||||
*/
|
||||
function renderChatRunningIndicator(thread, now) {
|
||||
const wrap = h("div", { class: "chat-running", id: "chatRunning" });
|
||||
const head = h("div", { class: "chat-running-head" });
|
||||
const spinner = h("span", { class: "spinner chat-running-spinner", "aria-hidden": "true" });
|
||||
// Every streamed delta re-renders the transcript, so a fresh spinner would
|
||||
// restart its CSS rotation at 0deg many times a second and look frozen. Start
|
||||
// it at the wall-clock phase instead, so re-renders continue the same turn.
|
||||
spinner.style.animationDelay = `-${(performance.now() % 800) / 1000}s`;
|
||||
head.append(spinner);
|
||||
head.append(
|
||||
h("span", {
|
||||
class: "chat-running-label",
|
||||
text: turnPhaseLabel(threadPhase(thread, now) ?? TURN_PHASE_WAITING),
|
||||
}),
|
||||
);
|
||||
head.append(
|
||||
h("span", {
|
||||
class: "chat-running-elapsed",
|
||||
text: `\u00b7 ${formatDuration(Math.trunc(threadElapsedMillis(thread, now) / 1000))}`,
|
||||
}),
|
||||
);
|
||||
wrap.append(head);
|
||||
return wrap;
|
||||
}
|
||||
|
||||
function runningToolText(part) {
|
||||
const name = toolLabel(part);
|
||||
const detail = toolDetail(part);
|
||||
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",
|
||||
text: formatToolDuration(threadToolElapsedMillis(thread, part, now)),
|
||||
}),
|
||||
);
|
||||
if (toolLongRunning(threadToolElapsedMillis(thread, part, now))) {
|
||||
line.classList.add("chat-running-tool-long");
|
||||
line.append(h("span", { class: "chat-tool-long", text: "\u00b7 long" }));
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
/** One operator turn, right-aligned, carrying its sender label when present. */
|
||||
function renderChatUserMessage(message) {
|
||||
const turn = h("div", { class: "chat-turn chat-turn-user" });
|
||||
const bubble = h("div", { class: "chat-bubble user-bubble" });
|
||||
const client = String(message?.client ?? "").trim();
|
||||
if (client !== "") bubble.append(h("div", { class: "chat-client", text: message.client }));
|
||||
const text = (message?.parts ?? [])
|
||||
const parts = message?.parts ?? [];
|
||||
const text = parts
|
||||
.filter((part) => part?.type === "text" || !part?.type)
|
||||
.map((part) => String(part?.text ?? ""))
|
||||
.join("\n")
|
||||
.trim();
|
||||
if (text !== "") bubble.append(h("div", { class: "chat-user-text", text }));
|
||||
const files = parts.filter(
|
||||
(part) => part?.type === "file" && (String(part?.name ?? "").trim() !== "" || String(part?.uri ?? "").trim() !== ""),
|
||||
);
|
||||
if (files.length > 0) {
|
||||
const strip = h("div", { class: "chat-user-files" });
|
||||
for (const part of files) {
|
||||
const name = attachmentDisplayName(part?.name, part?.uri);
|
||||
const file = h("span", { class: "chat-user-file", title: name });
|
||||
file.append(h("span", { class: "chat-user-file-glyph", "aria-hidden": "true", text: "\u{1F4CE}" }));
|
||||
file.append(h("span", { class: "chat-user-file-name", text: name }));
|
||||
strip.append(file);
|
||||
}
|
||||
bubble.append(strip);
|
||||
}
|
||||
turn.append(bubble);
|
||||
return turn;
|
||||
}
|
||||
@@ -2877,34 +2955,77 @@ function renderChatUserMessage(message) {
|
||||
function renderChatAgentTurn(turn, streaming = false, elapsedMillis = () => 0, thread = null) {
|
||||
const wrap = h("div", { class: "chat-turn chat-turn-agent" });
|
||||
const bubble = h("div", { class: "chat-bubble agent-bubble" });
|
||||
const steps = turn.reasoningSteps;
|
||||
// Thinking is evidence about the turn, not part of the answer bubble. Keep it
|
||||
// outside and above the message, the way the tool summary sits outside and
|
||||
// below it.
|
||||
if (steps.length > 0) wrap.append(renderChatReasoning(turn, streaming, thread));
|
||||
// One activity line carries the whole live turn: the spinner, the reasoning
|
||||
// toggle, the tool-call summary and the elapsed time. The old separate
|
||||
// reasoning, tool and bottom "thinking" rows made the transcript jump as each
|
||||
// phase came and went.
|
||||
const activity = renderChatActivity(turn, streaming, elapsedMillis, thread);
|
||||
if (activity) wrap.append(activity);
|
||||
if (turn.answer.trim() !== "") bubble.append(renderMarkdown(turn.answer));
|
||||
if (bubble.childElementCount > 0) wrap.append(bubble);
|
||||
// The tool summary is a quiet line beside the message, not a highlighted chip
|
||||
// inside it; its panel still opens right there.
|
||||
if (turn.tools.length > 0) {
|
||||
const tools = renderChatToolCalls(turn, { streaming, elapsedMillis });
|
||||
if (tools) wrap.append(tools);
|
||||
}
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The turn's one collapsible reasoning block. The open/closed state lives on the
|
||||
* conversation keyed by the turn, so it survives a re-render; toggling it never
|
||||
* rebuilds the transcript (and so never moves the operator's scroll). The label is
|
||||
* the app's own (see `reasoningLabel`) with the turn's server-reported duration
|
||||
* appended when it has one; a settled history turn reads `Reasoning` (or
|
||||
* `Reasoning · N steps`), a live one `Thinking…`/`Thinking · N steps`. Live
|
||||
* elapsed time is C5's; this renders the parts' own timing.
|
||||
* One stable activity row for a turn: spinner, reasoning toggle, tool-call
|
||||
* summary and the elapsed time. The reasoning body (when expanded) and the tool
|
||||
* panel hang off this row, so the three old live lines never appear and vanish
|
||||
* independently while a turn moves from thinking to tools and back.
|
||||
*/
|
||||
function renderChatReasoning(turn, streaming = false, thread = null) {
|
||||
function renderChatActivity(turn, streaming = false, elapsedMillis = () => 0, thread = null) {
|
||||
const steps = turn.reasoningSteps ?? [];
|
||||
const parts = turn.tools ?? [];
|
||||
if (!streaming && steps.length === 0 && parts.length === 0) return null;
|
||||
const wrap = h("div", {
|
||||
class: `chat-reasoning chat-activity${streaming ? " chat-reasoning-live" : ""}`,
|
||||
});
|
||||
const head = h("div", { class: "chat-activity-head" });
|
||||
if (streaming) {
|
||||
const spinner = h("span", {
|
||||
class: "spinner chat-activity-spinner",
|
||||
"aria-hidden": "true",
|
||||
});
|
||||
// Keep the rotation continuous across transcript repaints.
|
||||
spinner.style.animationDelay = `-${(performance.now() % 800) / 1000}s`;
|
||||
head.append(spinner);
|
||||
}
|
||||
if (steps.length > 0) {
|
||||
head.append(renderChatReasoningToggle(turn, streaming, steps));
|
||||
} else if (streaming) {
|
||||
head.append(
|
||||
h("span", {
|
||||
class: "chat-activity-phase",
|
||||
text: turnPhaseLabel(threadPhase(thread, Date.now()) ?? TURN_PHASE_WAITING),
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (parts.length > 0) {
|
||||
if (head.childElementCount > 0) head.append(h("span", { class: "chat-activity-sep", text: "\u00b7" }));
|
||||
head.append(renderChatToolChip(turn, { streaming, elapsedMillis }));
|
||||
}
|
||||
const elapsed = streaming
|
||||
? threadElapsedMillis(thread, Date.now())
|
||||
: turnElapsedMillis(turn.parts);
|
||||
if (elapsed != null) {
|
||||
head.append(
|
||||
h("span", {
|
||||
class: "chat-activity-elapsed",
|
||||
text: `\u00b7 ${formatDuration(Math.trunc(elapsed / 1000))}`,
|
||||
}),
|
||||
);
|
||||
}
|
||||
wrap.append(head);
|
||||
if (steps.length > 0) {
|
||||
const body = h("div", { class: "chat-reasoning-body", text: turn.reasoning });
|
||||
body.hidden = !state.chatReasoning.has(turn.key);
|
||||
wrap.append(body);
|
||||
}
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/** The reasoning half of the activity row: a quiet, expandable label. */
|
||||
function renderChatReasoningToggle(turn, streaming, steps) {
|
||||
const expanded = state.chatReasoning.has(turn.key);
|
||||
const block = h("div", { class: `chat-reasoning${streaming ? " chat-reasoning-live" : ""}` });
|
||||
const toggle = h("button", {
|
||||
class: "chat-reasoning-toggle",
|
||||
type: "button",
|
||||
@@ -2918,23 +3039,17 @@ function renderChatReasoning(turn, streaming = false, thread = null) {
|
||||
text: expanded ? "\u25be" : "\u25b8",
|
||||
}),
|
||||
);
|
||||
const label = reasoningLabel(turn.reasoningSteps.length, streaming);
|
||||
// A live turn has no completed timing envelope yet, so measure from the
|
||||
// thread's running clock; the one-second clock refreshes this label in place.
|
||||
const elapsedMillis = streaming
|
||||
? threadElapsedMillis(thread, Date.now())
|
||||
: turnElapsedMillis(turn.parts);
|
||||
const duration = elapsedMillis == null ? null : formatDuration(Math.trunc(elapsedMillis / 1000));
|
||||
toggle.append(
|
||||
h("span", {
|
||||
class: "chat-reasoning-label",
|
||||
"data-live-steps": streaming ? String(turn.reasoningSteps.length) : null,
|
||||
text: duration == null ? label : `${label} · ${duration}`,
|
||||
"data-live-steps": streaming ? String(steps.length) : null,
|
||||
text: reasoningLabel(steps.length, streaming),
|
||||
}),
|
||||
);
|
||||
const body = h("div", { class: "chat-reasoning-body", text: turn.reasoning });
|
||||
body.hidden = !expanded;
|
||||
toggle.addEventListener("click", () => {
|
||||
const block = toggle.closest(".chat-activity");
|
||||
const body = block?.querySelector(".chat-reasoning-body");
|
||||
if (!body) return;
|
||||
const next = body.hidden;
|
||||
body.hidden = !next;
|
||||
toggle.setAttribute("aria-expanded", String(next));
|
||||
@@ -2944,35 +3059,21 @@ function renderChatReasoning(turn, streaming = false, thread = null) {
|
||||
if (next) state.chatReasoning.add(turn.key);
|
||||
else state.chatReasoning.delete(turn.key);
|
||||
});
|
||||
block.append(toggle, body);
|
||||
return block;
|
||||
return toggle;
|
||||
}
|
||||
|
||||
/**
|
||||
* One turn's tool calls behind a single summary chip (C6), the browser's port of
|
||||
* `ui/chat/ChatToolCalls.kt`: `N tools called`, a spinner while any call is in
|
||||
* flight, a `· long` mark (error tint) once a running call has passed
|
||||
* [TOOL_LONG_RUNNING_MILLIS], error styling once a call failed, and a chevron
|
||||
* naming the panel it opens. The panel is a fixed overlay anchored below the chip
|
||||
* (flipped above when there is no room), with a header count, a close control, an
|
||||
* internally scrolling list, and per-row expand state; because it never joins the
|
||||
* transcript's flow, opening or closing it cannot re-flow the conversation nor
|
||||
* move its scroll position (C14).
|
||||
*
|
||||
* [streaming] is whether the turn is still live, and [elapsedMillis] the live age
|
||||
* of a running call (the conversation supplies it from its own clock, so the
|
||||
* `long` mark is derived from real time, never guessed). A settled history turn
|
||||
* passes neither, so a stored `running` status cannot spin or wear the mark.
|
||||
* One turn's tool calls behind a single summary chip: `N tools called`, the
|
||||
* current call while one is in flight, a `· long` mark and the panel chevron.
|
||||
* The line's single spinner lives in the activity row, not here.
|
||||
*/
|
||||
function renderChatToolCalls(turn, { streaming = false, elapsedMillis = () => 0 } = {}) {
|
||||
function renderChatToolChip(turn, { streaming = false, elapsedMillis = () => 0 } = {}) {
|
||||
const parts = turn.tools;
|
||||
if (parts.length === 0) return null;
|
||||
const count = toolCallCount(turn.parts);
|
||||
const running = streaming && toolsRunning(turn.parts);
|
||||
const failed = parts.some((part) => toolFailed(part.state));
|
||||
const long = running && parts.some((part) => toolRunning(part) && toolLongRunning(elapsedMillis(part)));
|
||||
|
||||
const wrap = h("div", { class: "chat-tools" });
|
||||
const chip = h("button", {
|
||||
class: `chip chat-tool-chip${failed ? " chat-tool-chip-failed" : ""}`,
|
||||
type: "button",
|
||||
@@ -2981,21 +3082,14 @@ function renderChatToolCalls(turn, { streaming = false, elapsedMillis = () => 0
|
||||
"aria-haspopup": "dialog",
|
||||
});
|
||||
const currentTool = running ? parts.filter((part) => toolRunning(part)).at(-1) ?? null : null;
|
||||
if (running) {
|
||||
chip.append(h("span", { class: "spinner chat-tool-spinner", "aria-hidden": "true" }));
|
||||
} else {
|
||||
chip.append(
|
||||
h("span", {
|
||||
class: `chat-tool-icon${failed ? " chat-tool-icon-failed" : ""}`,
|
||||
"aria-hidden": "true",
|
||||
text: failed ? "\u26a0" : "\u29c9",
|
||||
}),
|
||||
);
|
||||
}
|
||||
chip.append(
|
||||
h("span", {
|
||||
class: `chat-tool-icon${failed ? " chat-tool-icon-failed" : ""}`,
|
||||
"aria-hidden": "true",
|
||||
text: failed ? "\u26a0" : "\u29c9",
|
||||
}),
|
||||
);
|
||||
chip.append(h("span", { class: "chat-tool-label", text: toolCallsLabel(count) }));
|
||||
// The live call lives on the same line as the count instead of in a second
|
||||
// status line below the transcript. The chip therefore updates in place while
|
||||
// the count and the rest of the row remain stable.
|
||||
if (currentTool) {
|
||||
const detail = toolDetail(currentTool);
|
||||
const name = toolLabel(currentTool);
|
||||
@@ -3019,8 +3113,7 @@ function renderChatToolCalls(turn, { streaming = false, elapsedMillis = () => 0
|
||||
event.stopPropagation();
|
||||
openChatToolCalls(turn, parts, count);
|
||||
});
|
||||
wrap.append(chip);
|
||||
return wrap;
|
||||
return chip;
|
||||
}
|
||||
|
||||
/** The tool list body, shared by the modal: one expandable row per call. */
|
||||
@@ -3405,6 +3498,7 @@ function renderChatComposer(thread, session, sessionId) {
|
||||
input.value = thread.draft ?? "";
|
||||
input.addEventListener("input", (event) => onComposerInput(event, sessionId, session, controls));
|
||||
input.addEventListener("keydown", (event) => onComposerKeydown(event, sessionId, session, controls));
|
||||
input.addEventListener("paste", (event) => onComposerPaste(event, sessionId, session));
|
||||
row.append(input);
|
||||
|
||||
const primary = h("span", { class: "chat-composer-primary" });
|
||||
@@ -3759,24 +3853,20 @@ function stopChatClock() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Refresh the running indicator in place from the thread's own state at [now]. */
|
||||
/** Refresh the activity row in place from the thread's own state at [now]. */
|
||||
function updateChatIndicator(now) {
|
||||
const thread = state.chatActiveId ? state.chatThreads.get(state.chatActiveId) : null;
|
||||
if (!thread?.running) return;
|
||||
// The live reasoning label is a second continuous clock: "Thinking · N steps ·
|
||||
// 1m 2s" must keep counting even when no frame arrives.
|
||||
const liveReasoning = document.querySelector("#chatTranscript .chat-reasoning-live .chat-reasoning-label");
|
||||
if (liveReasoning) {
|
||||
const steps = Number(liveReasoning.dataset.liveSteps) || 0;
|
||||
const duration = formatDuration(Math.trunc(threadElapsedMillis(thread, now) / 1000));
|
||||
liveReasoning.textContent = `${reasoningLabel(steps, true)} · ${duration}`;
|
||||
// The live turn is the last activity row, not the first one in a long
|
||||
// transcript.
|
||||
const elapsed = [...document.querySelectorAll("#chatTranscript .chat-activity-elapsed")].at(-1);
|
||||
if (elapsed) {
|
||||
elapsed.textContent = `\u00b7 ${formatDuration(Math.trunc(threadElapsedMillis(thread, now) / 1000))}`;
|
||||
}
|
||||
const phase = [...document.querySelectorAll("#chatTranscript .chat-activity-phase")].at(-1);
|
||||
if (phase) {
|
||||
phase.textContent = turnPhaseLabel(threadPhase(thread, now) ?? TURN_PHASE_WAITING);
|
||||
}
|
||||
const el = document.getElementById("chatRunning");
|
||||
if (!el) return;
|
||||
const label = el.querySelector(".chat-running-label");
|
||||
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))}`;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -29,6 +29,7 @@ export function createRunsView(rt) {
|
||||
const { state } = rt;
|
||||
const renderContent = (...args) => rt.renderContent(...args);
|
||||
const selectRun = (...args) => rt.selectRun(...args);
|
||||
const renderAttentionBell = () => rt.renderAttentionBell();
|
||||
|
||||
|
||||
function renderRunList(now = Date.now()) {
|
||||
@@ -193,6 +194,7 @@ function renderRunToolbar() {
|
||||
state.openMenu === "sort" ? renderSortMenu() : null,
|
||||
),
|
||||
h("span", { class: "spacer" }),
|
||||
renderAttentionBell(),
|
||||
);
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// A shell cache for an installed Pipelines app. The API (the WebSocket proxy and
|
||||
// artifact files) is never cached; static files prefer the network and fall back
|
||||
// to the last good copy so an installed app still opens when the server is away.
|
||||
const CACHE = "pipelines-shell-v2";
|
||||
const CACHE = "pipelines-shell-v3";
|
||||
const SHELL = ["/", "/index.html", "/manifest.webmanifest", "/favicon.svg"];
|
||||
|
||||
self.addEventListener("install", (event) => {
|
||||
|
||||
@@ -136,6 +136,7 @@ import {
|
||||
queuedAfterFrame,
|
||||
readChatSeen,
|
||||
reasoningLabel,
|
||||
relativeSessionTime,
|
||||
renameChatOverride,
|
||||
restoreChatOverride,
|
||||
resumedThread,
|
||||
@@ -510,6 +511,18 @@ test("sessionActivity and its badge word follow streaming, unseen then open", ()
|
||||
assert.equal(sessionActivityBadge("idle", false), "Idle");
|
||||
});
|
||||
|
||||
test("relativeSessionTime names the latest chat update, not a meaningless idle state", () => {
|
||||
const now = Date.UTC(2026, 9, 20, 12, 0, 0);
|
||||
assert.equal(relativeSessionTime(0, now), "");
|
||||
assert.equal(relativeSessionTime(now - 20_000, now), "just now");
|
||||
assert.equal(relativeSessionTime(now - 50_000, now), "1 min ago");
|
||||
assert.equal(relativeSessionTime(now - 2 * 60_000, now), "2 min ago");
|
||||
assert.equal(relativeSessionTime(now - 3 * 60 * 60_000, now), "3 hr ago");
|
||||
assert.equal(relativeSessionTime(now - 26 * 60 * 60_000, now), "1 day ago");
|
||||
assert.equal(relativeSessionTime(now - 3 * 24 * 60 * 60_000, now), "3 days ago");
|
||||
assert.equal(relativeSessionTime(Date.UTC(2026, 8, 12, 9, 0, 0), now), "12 Sept");
|
||||
});
|
||||
|
||||
test("sessionStatusLabel reads Closed first, then Running or Idle", () => {
|
||||
assert.equal(sessionStatusLabel(true, true), "Closed");
|
||||
assert.equal(sessionStatusLabel(true, false), "Running");
|
||||
@@ -1109,6 +1122,30 @@ test("a text delta appends to the part the first frame started", () => {
|
||||
assert.equal(thread.lastDeltaAt, 1001);
|
||||
});
|
||||
|
||||
test("a remote user turn carries its file attachments into the message", () => {
|
||||
let thread = newChatThread("s1");
|
||||
thread = applyChatEvent(
|
||||
thread,
|
||||
evt("user", {
|
||||
message_id: "u1",
|
||||
operation_id: "op1",
|
||||
client: "Phone",
|
||||
part: { type: "text", text: "See attached" },
|
||||
attachments: [{ type: "file", name: "note.txt", mime: "text/plain", uri: "file:///tmp/note.txt" }],
|
||||
}),
|
||||
1000,
|
||||
);
|
||||
const message = thread.messages[0];
|
||||
assert.equal(message.role, "user");
|
||||
assert.equal(message.parts[0].text, "See attached");
|
||||
assert.deepEqual(message.parts[1], {
|
||||
type: "file",
|
||||
name: "note.txt",
|
||||
mime: "text/plain",
|
||||
uri: "file:///tmp/note.txt",
|
||||
});
|
||||
});
|
||||
|
||||
test("a text delta and a reasoning delta sharing a bare id land in separate parts", () => {
|
||||
let thread = newChatThread("s1");
|
||||
thread = applyChatEvent(thread, evt("text", { message_id: "a1", part: { id: "x" }, delta: "answer" }), 1000);
|
||||
|
||||
+44
-47
@@ -1404,7 +1404,9 @@ async function runDecisionChecks() {
|
||||
/** Expand the CLOSED chats group so a just-closed row is in the DOM to inspect. */
|
||||
async function expandClosedChats() {
|
||||
await page.evaluate(`(() => {
|
||||
const toggle = document.querySelector(".chat-group-toggle");
|
||||
const toggle = [...document.querySelectorAll(".chat-group-toggle")].find((node) =>
|
||||
node.textContent.trim().toLowerCase().startsWith("closed"),
|
||||
);
|
||||
if (toggle && toggle.getAttribute("aria-expanded") !== "true") toggle.click();
|
||||
return !!toggle;
|
||||
})()`);
|
||||
@@ -4616,9 +4618,9 @@ try {
|
||||
chatList.rows.find((row) => !row.closed && row.menu);
|
||||
if (operatorRow) {
|
||||
if (!operatorRow.title) throw new Error("the operator chat row has no title");
|
||||
// The row leads with the title and its status word; directory and model are
|
||||
// the two lines below, with no operator chip.
|
||||
if (!["Idle", "Open", "Streaming", "New", "Closed"].includes(operatorRow.status)) {
|
||||
// The row leads with the title; a live/unseen/closed row may carry a status
|
||||
// badge, while an ordinary idle row shows only its recency and directory.
|
||||
if (!["", "Streaming", "New", "Closed"].includes(operatorRow.status)) {
|
||||
throw new Error(`chat row status: ${JSON.stringify(operatorRow)}`);
|
||||
}
|
||||
// M6 names the control for its row: `Chat actions for {title}`, with the
|
||||
@@ -6173,19 +6175,19 @@ try {
|
||||
return true;
|
||||
})()`);
|
||||
const agentCount = () => page.evaluate(`document.querySelectorAll("#chatTranscript .chat-turn-agent").length`);
|
||||
const indicator = () =>
|
||||
const activity = () =>
|
||||
page.evaluate(`(() => {
|
||||
const el = document.querySelector("#chatRunning");
|
||||
const el = [...document.querySelectorAll("#chatTranscript .chat-activity")].at(-1);
|
||||
if (!el) return null;
|
||||
return {
|
||||
spinner: !!el.querySelector(".spinner"),
|
||||
label: el.querySelector(".chat-running-label")?.textContent ?? "",
|
||||
elapsed: el.querySelector(".chat-running-elapsed")?.textContent ?? "",
|
||||
tools: [...el.querySelectorAll(".chat-running-tool")].map((line) => ({
|
||||
text: line.querySelector(".chat-running-tool-text")?.textContent ?? "",
|
||||
long: line.querySelector(".chat-tool-long")?.textContent ?? "",
|
||||
longTinted: line.classList.contains("chat-running-tool-long"),
|
||||
})),
|
||||
spinner: !!el.querySelector(".chat-activity-spinner"),
|
||||
label: el.querySelector(".chat-reasoning-label")?.textContent ?? "",
|
||||
phase: el.querySelector(".chat-activity-phase")?.textContent ?? "",
|
||||
elapsed: el.querySelector(".chat-activity-elapsed")?.textContent ?? "",
|
||||
chip: el.querySelector(".chat-tool-chip")?.textContent ?? "",
|
||||
current: el.querySelector(".chat-tool-current")?.textContent ?? "",
|
||||
long: el.querySelector(".chat-tool-long")?.textContent ?? "",
|
||||
indicator: !!document.querySelector("#chatTranscript .chat-activity"),
|
||||
};
|
||||
})()`);
|
||||
|
||||
@@ -6241,23 +6243,17 @@ try {
|
||||
"the running tool",
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1300));
|
||||
const runningChip = await page.evaluate(`(() => {
|
||||
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
|
||||
return {
|
||||
current: chip?.querySelector(".chat-tool-current")?.textContent ?? "",
|
||||
spinner: !!chip?.querySelector(".chat-tool-spinner"),
|
||||
indicator: !!document.querySelector("#chatRunning"),
|
||||
};
|
||||
})()`);
|
||||
const runningChip = await activity();
|
||||
if (
|
||||
!runningChip ||
|
||||
!runningChip.spinner ||
|
||||
!runningChip.current.includes("shell") ||
|
||||
!runningChip.current.includes("npm run build") ||
|
||||
runningChip.indicator
|
||||
) {
|
||||
throw new Error(`C5: the current-tool chip is wrong: ${JSON.stringify(runningChip)}`);
|
||||
throw new Error(`C5: the activity line is wrong: ${JSON.stringify(runningChip)}`);
|
||||
}
|
||||
console.log(` current tool on the count line: "${runningChip.current}" (no second indicator)`);
|
||||
console.log(` one activity line: "${runningChip.label || runningChip.phase}" · "${runningChip.current}" ${runningChip.elapsed}`);
|
||||
await shot("57-chat-running.png");
|
||||
|
||||
// 3. A second running tool that started 61 s ago (protocol `time.ran`): the
|
||||
@@ -6279,14 +6275,8 @@ try {
|
||||
],
|
||||
"the long-running tool",
|
||||
);
|
||||
const longCall = await page.evaluate(`(() => {
|
||||
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
|
||||
return {
|
||||
current: chip?.querySelector(".chat-tool-current")?.textContent ?? "",
|
||||
long: chip?.querySelector(".chat-tool-long")?.textContent ?? "",
|
||||
};
|
||||
})()`);
|
||||
if (!longCall.current.includes("npm run long") || !longCall.long.includes("long")) {
|
||||
const longCall = await activity();
|
||||
if (!longCall?.current.includes("npm run long") || !longCall.long.includes("long")) {
|
||||
throw new Error(`C5: the long-running tool is not on the count line: ${JSON.stringify(longCall)}`);
|
||||
}
|
||||
const agentsWithTwoIds = await agentCount();
|
||||
@@ -6296,8 +6286,8 @@ try {
|
||||
}
|
||||
await shot("58-chat-long-call.png");
|
||||
|
||||
// 4. Finish the tools and end the step: the indicator disappears and the same
|
||||
// single agent bubble stands, settled.
|
||||
// 4. Finish the tools and end the step: the one activity line settles in place
|
||||
// (no spinner) and the same single agent bubble stands.
|
||||
await applyFrames(
|
||||
[
|
||||
sessionFrame({ message_id: "cap-live-1", kind: "tool", part: { type: "tool", id: "cap-tool-1", state: { status: "completed", content: [{ type: "text", text: "build ok" }] } } }),
|
||||
@@ -6311,7 +6301,9 @@ try {
|
||||
const bubbles = [...transcript.querySelectorAll(".chat-turn-agent")];
|
||||
const answer = bubbles.find((b) => b.textContent.includes("The live turn is growing."));
|
||||
return {
|
||||
indicator: !!document.querySelector("#chatRunning"),
|
||||
indicator: !!document.querySelector("#chatTranscript .chat-activity"),
|
||||
activity: !!document.querySelector("#chatTranscript .chat-activity"),
|
||||
spinner: !!document.querySelector("#chatTranscript .chat-activity-spinner"),
|
||||
agents: bubbles.length,
|
||||
answers: bubbles.filter((b) => b.textContent.includes("The live turn is growing.")).length,
|
||||
// The one bubble that carries the live answer must also carry the replayed
|
||||
@@ -6319,12 +6311,15 @@ try {
|
||||
settledOneBubble: !!answer && answer.textContent.includes("Planning the live capture."),
|
||||
};
|
||||
})()`);
|
||||
if (settled.indicator) throw new Error("C5: the running indicator survived the ended step");
|
||||
if (settled.indicator) throw new Error("C5: a second running indicator survived the ended step");
|
||||
if (!settled.activity || settled.spinner) {
|
||||
throw new Error(`C5: the one activity line did not settle in place: ${JSON.stringify(settled)}`);
|
||||
}
|
||||
if (settled.agents - agentBefore > 1 || settled.answers !== 1 || !settled.settledOneBubble) {
|
||||
throw new Error(`C5: the settled turn is not the same single agent bubble: ${JSON.stringify(settled)}`);
|
||||
}
|
||||
console.log(
|
||||
` after the tools completed and the step ended: no indicator, still ${settled.agents} agent bubble ` +
|
||||
` after the tools completed and the step ended: one settled activity line, still ${settled.agents} agent bubble ` +
|
||||
`carrying the live answer (unchanged from ${agentBefore})`,
|
||||
);
|
||||
await shot("59-chat-settled.png");
|
||||
@@ -6373,17 +6368,17 @@ try {
|
||||
return true;
|
||||
})()`);
|
||||
|
||||
// A synthetic in-flight turn, so the running indicator would be showing before
|
||||
// A synthetic in-flight turn, so the activity row would be showing before
|
||||
// the approval arrives — and must stand down while the request is pending.
|
||||
await applyFrames(
|
||||
[sessionFrame({ message_id: "cap-approval-turn", kind: "step", step: { status: "started" } })],
|
||||
"the synthetic in-flight turn",
|
||||
);
|
||||
await eventually(() => page.evaluate(`!!document.querySelector("#chatRunning")`), {
|
||||
await eventually(() => page.evaluate(`!!document.querySelector("#chatTranscript .chat-activity")`), {
|
||||
timeout: 8000,
|
||||
what: "the running indicator before the approval",
|
||||
what: "the activity row before the approval",
|
||||
});
|
||||
const runningBeforeApproval = await page.evaluate(`!!document.querySelector("#chatRunning")`);
|
||||
const runningBeforeApproval = await page.evaluate(`!!document.querySelector("#chatTranscript .chat-activity")`);
|
||||
|
||||
const readApproval = () =>
|
||||
page.evaluate(`(() => {
|
||||
@@ -6478,7 +6473,7 @@ try {
|
||||
})(),
|
||||
controls: [...(card?.querySelectorAll(".chat-approval-control") ?? [])].map((b) => b.textContent),
|
||||
topControl: top?.textContent ?? "",
|
||||
running: !!document.querySelector("#chatRunning"),
|
||||
running: !!document.querySelector("#chatTranscript .chat-activity"),
|
||||
};
|
||||
})()`);
|
||||
|
||||
@@ -6567,13 +6562,13 @@ try {
|
||||
throw new Error(`C10: top-bar control: ${JSON.stringify(pending.topControl)}`);
|
||||
}
|
||||
if (runningBeforeApproval && pending.running) {
|
||||
throw new Error("C10: the running indicator did not stand down while the approval is pending");
|
||||
throw new Error("C10: the activity row did not stand down while the approval is pending");
|
||||
}
|
||||
console.log(
|
||||
` pending card: "${pending.headline}" / "${pending.status}", ${pending.resources.length} resource lines ` +
|
||||
`(rendered ${pending.resourceLines} of ${pending.resourceFullLines} unclamped), risk "${pending.riskLabel}", ` +
|
||||
`controls ${JSON.stringify(pending.controls)} (Allow once filled: ${pending.primaryFilled}), ` +
|
||||
`top-bar "${pending.topControl}", #chatRunning ${pending.running ? "present" : "absent"}`,
|
||||
`top-bar "${pending.topControl}", one activity row ${pending.running ? "present" : "absent"}`,
|
||||
);
|
||||
await shot("65-chat-approval-pending.png");
|
||||
|
||||
@@ -7957,9 +7952,11 @@ try {
|
||||
{ timeout: 8000, what: "the renamed row to show its local title" },
|
||||
);
|
||||
console.log(` row ${throwawayId} shows the local title "${renamedTitle}"`);
|
||||
// Refresh the list from the server (the same header Refresh the page offers);
|
||||
// the local title must still win over the server's own.
|
||||
await page.clickText(".pane-head button.ghost", "Refresh");
|
||||
// Re-enter the destination to reload the list from the server (the list has no
|
||||
// manual Refresh control); the local title must still win over the server's own.
|
||||
await clickDestination("Pipelines");
|
||||
await clickDestination("Chat");
|
||||
await page.waitForSelector("#chatRows .chat-row", { timeout: 15000 });
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
|
||||
Reference in New Issue
Block a user