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:
2026-10-20 14:30:57 +01:00
parent f5ccec8e1f
commit 3799d37d7c
11 changed files with 583 additions and 306 deletions
+63 -66
View File
@@ -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.