Merge branch 'main' into web-run-polish

This commit is contained in:
2026-10-19 20:11:08 +01:00
33 changed files with 3249 additions and 831 deletions
+668 -217
View File
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -122,11 +122,12 @@ function isProtocol(value) {
}
/**
* The header's compact connection state badge. It is the page's own indicator
* (Android renders the same facts in SettingsScreen.kt's connection card): the
* one job it does that ConnectionBanner.kt's banner text does not is name the
* retry attempt while disconnected, so "reason + retrying + attempt" are all
* visible at a glance. `tone` names the dot colour class (ok/warn/bad/idle).
* The compact connection state helper behind the shell's dot+word control and
* the Settings status card. It is the page's own indicator (Android renders the
* same facts in SettingsScreen.kt's connection card): the one job it does that
* ConnectionBanner.kt's banner text does not is name the retry attempt while
* disconnected, so "reason + retrying + attempt" are all visible at a glance.
* `tone` names the dot colour class (ok/warn/bad/idle).
*/
export function stateBadge(connection) {
const c = connection ?? {};
+13 -6
View File
@@ -1338,14 +1338,21 @@ export function mount(container, graph, options = {}) {
selectNode(key, { notify: false });
// The pane is still detached while the caller builds the detail, so reveal
// it on the next frame, once renderContent has put it in the document. The
// sticky top bar must stay clear of the pane head: scroll to the pane's top
// minus the bar's own measured height (CSS scroll-margin-top is the
// fallback for browsers that reveal it another way).
// detail's own `.pane-scroll` is the only scroller in the shell: move it,
// never the never-scrolling document.
const reveal = () => {
if (typeof pane.getBoundingClientRect !== "function") return;
const topbar = document.querySelector(".topbar");
const bar = topbar?.getBoundingClientRect?.().height ?? 0;
const top = pane.getBoundingClientRect().top + (window.scrollY ?? 0) - bar - 12;
const scroller = pane.closest(".pane-scroll");
if (scroller) {
const top =
pane.getBoundingClientRect().top -
scroller.getBoundingClientRect().top +
scroller.scrollTop -
12;
scroller.scrollTop = Math.max(0, top);
return;
}
const top = pane.getBoundingClientRect().top + (window.scrollY ?? 0) - 12;
window.scrollTo?.({ top: Math.max(0, top), behavior: "instant" });
};
if (typeof requestAnimationFrame === "function") requestAnimationFrame(reveal);
+107
View File
@@ -0,0 +1,107 @@
// The persistent app shell's pure model (L2/L3/L4): the four destinations, the
// roving-tabindex arithmetic shared by the destination and section tablists, the
// compact connection word shown in the rail/dock, and the view -> destination
// mapping. Deliberately DOM-free, so every branch is unit-testable in Node.
//
// The rail is the wide presentation; the bottom dock is the narrow one. Both
// render the same DESTINATIONS model (roles: tablist + tab, aria-current on the
// route as well as aria-selected). Templates stays a route but not a
// destination: it is reached from Settings, the card that owns its entry point.
/** The four destinations, in Android's destination-bar order. */
export const DESTINATIONS = Object.freeze([
Object.freeze({ key: "pipelines", label: "Pipelines", path: "/pipelines", icon: "pipelines" }),
Object.freeze({ key: "runs", label: "Runs", path: "/runs", icon: "runs" }),
Object.freeze({ key: "chat", label: "Chat", path: "/chat", icon: "chat" }),
Object.freeze({ key: "settings", label: "Settings", path: "/settings", icon: "settings" }),
]);
/** The destination key that owns a view. Templates is reached from Settings. */
export function destinationForView(view) {
switch (view) {
case "runs":
return "runs";
case "chat":
return "chat";
case "settings":
case "templates":
return "settings";
default:
return "pipelines";
}
}
/** The index of a destination key in DESTINATIONS (0 for an unknown key). */
export function destinationIndex(key) {
const index = DESTINATIONS.findIndex((item) => item.key === key);
return index < 0 ? 0 : index;
}
/** Roving tabindex: the selected tab is the only stop in its tablist. */
export function rovingTabindex(selectedIndex, index) {
return selectedIndex === index ? "0" : "-1";
}
/**
* The next index after one of the roving-tablist keys, or -1 when the key is not
* one this tablist handles. ArrowLeft/ArrowRight always move (both tablists use
* a horizontal axis in the narrow strip); ArrowUp/ArrowDown are also accepted
* because the wide rail is vertical. Home/End jump to the ends. Movement wraps,
* as WAI-ARIA's tabs pattern recommends.
*/
export function tabIndexForKey(key, index, count, { vertical = false } = {}) {
if (!Number.isInteger(index) || !Number.isInteger(count) || count <= 0 || index < 0 || index >= count) {
return -1;
}
const last = count - 1;
switch (key) {
case "ArrowRight":
return index >= last ? 0 : index + 1;
case "ArrowLeft":
return index <= 0 ? last : index - 1;
case "ArrowDown":
return vertical ? (index >= last ? 0 : index + 1) : -1;
case "ArrowUp":
return vertical ? (index <= 0 ? last : index - 1) : -1;
case "Home":
return 0;
case "End":
return last;
default:
return -1;
}
}
/**
* The compact connection word for the shell status control. It deliberately does
* not repeat the banner's full sentence: the dot's tone carries the state and
* the word always names it, so colour is never the only signal. With no endpoint
* configured, the shell says exactly that instead of asking for a URL (Settings
* is the only place that asks).
*/
export function shellStatus(connection, { hasEndpoint = false } = {}) {
const c = connection ?? {};
switch (c.kind) {
case "connected":
return { text: "Connected", tone: "ok", state: "connected" };
case "connecting":
return { text: "Connecting\u2026", tone: "warn", state: "connecting" };
case "disconnected":
return { text: "Disconnected", tone: "bad", state: "disconnected" };
default:
return hasEndpoint
? { text: "Not connected", tone: "idle", state: "idle" }
: { text: "Not configured", tone: "idle", state: "unconfigured" };
}
}
/**
* The section tabs for the current detail. `tabs` is the model's own
* `{key,label}` list, `active` the selected key. No detail means no tablist.
*/
export function sectionModel(model) {
const tabs = Array.isArray(model?.tabs) ? model.tabs : [];
if (!tabs.length) return { tabs: [], active: -1 };
const active = Math.max(0, tabs.findIndex((tab) => tab.key === model.active));
return { tabs, active };
}
+22 -15
View File
@@ -43,7 +43,7 @@ export function createAttentionView(rt) {
/**
* The attention bell action, shown in the top bar on every view (R15). Its
* The attention bell action, shown in the Runs list heading (R15). Its
* accessible name comes from `attentionBadgeLabel`; the visible badge is drawn
* only when something genuinely needs the operator, and the count comes from the
* same pure model the sheet reads.
@@ -83,22 +83,29 @@ function attentionCount() {
* loads, without rebuilding the header and disturbing the URL field.
*/
function refreshAttentionBell() {
const button = document.querySelector("#attentionBell");
if (!button) return;
const count = attentionCount();
const label = attentionBadgeLabel(count);
button.setAttribute("aria-label", label);
button.title = label;
let badge = button.querySelector(".attention-badge");
if (count > 0) {
if (!badge) {
badge = h("span", { class: "attention-badge", "aria-hidden": "true" });
button.append(badge);
const button = document.querySelector("#attentionBell");
if (button) {
button.setAttribute("aria-label", label);
button.title = label;
let badge = button.querySelector(".attention-badge");
if (count > 0) {
if (!badge) {
badge = h("span", { class: "attention-badge", "aria-hidden": "true" });
button.append(badge);
}
badge.dataset.count = String(count);
badge.textContent = String(count);
} else if (badge) {
badge.remove();
}
badge.dataset.count = String(count);
badge.textContent = String(count);
} else if (badge) {
badge.remove();
}
// The Runs destination mirrors the same count, so an operator on any surface
// can see that something needs attention without first opening Runs.
for (const destinationBadge of document.querySelectorAll("[data-attention-badge]")) {
destinationBadge.hidden = count <= 0;
destinationBadge.textContent = count > 0 ? String(count) : "";
}
}
@@ -106,7 +113,7 @@ function refreshAttentionBell() {
/**
* The attention sheet: the ordered list from the pure `attentionEntries` model,
* opened from the bell in the top bar. It is a single managed dialog — Escape,
* opened from the bell in the Runs heading. It is a single managed dialog — Escape,
* a backdrop click and the Close button all close it — with the exact app
* wording: title `Needs you`, rows of status icon + the run label + the
* `{pipeline} · {detail}` line + a trailing `Dismiss`, and the empty state
+20 -6
View File
@@ -258,6 +258,7 @@ export function createChatView(rt) {
let chatClock = null;
let chatNow = Date.now();
const renderContent = (...args) => rt.renderContent(...args);
const focusDetailHeading = (...args) => rt.focusDetailHeading(...args);
const renderActionFailedDialog = (...args) => rt.views.dialogs.renderActionFailedDialog(...args);
/** Remember one conversation's scroll position (index of the first visible row). */
@@ -406,6 +407,7 @@ function startNewChat() {
state.chatCreate = newChatCreateState(newChatOperationId());
state.chatDirectoriesError = "";
renderContent();
focusDetailHeading();
loadChatDirectories();
}
@@ -504,6 +506,7 @@ async function openChatSession(id) {
error: "",
});
renderContent();
focusDetailHeading();
// Attach the shared live stream once per session per connection; its failure is
// non-fatal — history stays usable and the badge reads "not live".
subscribeChatSession(id);
@@ -511,6 +514,9 @@ async function openChatSession(id) {
// only after the next pushed shell frame.
loadChatShells(id);
await loadChatHistory(id);
// The history load repaints the pane; keep the row activation's focus contract
// true after it lands, not only for the loading paint.
focusDetailHeading();
}
/** Replace one conversation's fields, keeping every other field intact. */
@@ -1443,7 +1449,7 @@ function renderChatList() {
}),
);
list.append(toolbar);
const rows = h("div", { id: "chatRows", class: "chat-rows" });
const rows = h("div", { id: "chatRows", class: "chat-rows list-scroll" });
fillChatRows(rows);
list.append(rows);
return list;
@@ -1620,7 +1626,13 @@ function renderChatCreate() {
},
h("span", { class: "chat-create-back-glyph", "aria-hidden": "true", text: "←" }),
),
h("h2", { class: "chat-bar-title chat-create-title", text: CHAT_CREATE_TITLE }),
// The create pane is a chat detail too: its title is the route's h1.
h("h1", {
class: "chat-bar-title chat-create-title",
id: "detailTitle",
tabindex: "-1",
text: CHAT_CREATE_TITLE,
}),
);
pane.append(bar);
@@ -1799,14 +1811,16 @@ function renderChatConversation() {
const thread = state.chatThreads.get(state.chatActiveId) ?? null;
const title = effective ? sessionTitle(effective) : state.chatActiveId.slice(0, 18);
// The pending approval card (C10), derived from the stored frame plus the local
// answer. While it is actionable the top bar offers a jump control and the
// answer. While it is actionable the chat pane offers a jump control and the
// running indicator stands down (a turn blocked on a decision is not generating).
const approval = approvalCard(thread?.permission, thread?.permissionAnswer);
const awaiting = approval?.actionable === true;
const bar = h("div", { class: "chat-bar" });
const titles = h("div", { class: "chat-bar-titles" });
titles.append(h("h2", { class: "chat-bar-title", text: title }));
// The open conversation is the route's one h1; the list heading above becomes
// its h2 while the detail is open.
titles.append(h("h1", { class: "chat-bar-title", id: "detailTitle", tabindex: "-1", text: title }));
const meta = chatHeaderMeta({
model: session?.model,
tag: session?.tag,
@@ -2151,7 +2165,7 @@ function renderChatTranscript(
// deliberately unlike a message bubble (see ChatCommandNoticeItem).
for (const notice of notices) transcript.append(renderChatCommandNotice(sessionId, notice));
// The approval card is the transcript's last item (C10) — after the notices and
// after the running indicator when it is shown — so the top bar's jump control
// after the running indicator when it is shown — so the pane's jump control
// and a fresh card both land at the end.
if (approval) transcript.append(renderChatApproval(sessionId, approval));
wrap.append(transcript);
@@ -2173,7 +2187,7 @@ function renderChatTranscript(
return wrap;
}
/** The top bar's approval jump control (C10), naming the pending request. */
/** The chat pane's approval jump control (C10), naming the pending request. */
function approvalJumpButton() {
return h("button", {
class: "ghost chat-approval-jump",
+7 -19
View File
@@ -35,7 +35,7 @@ export function createPipelinesView(rt) {
function renderPipelineList() {
const list = h("div", { class: "list" });
list.append(renderPipelineControls());
const rows = h("div", { id: "pipelineRows" });
const rows = h("div", { id: "pipelineRows", class: "list-scroll" });
fillPipelineRows(rows);
list.append(rows);
return list;
@@ -259,7 +259,11 @@ function renderPipelineRow(pipeline, latestRuns, runsKnown, now) {
}
return h(
"button",
{ class: `row${state.selectedPipelineId === pipeline.id ? " selected" : ""}`, onclick: () => selectPipeline(pipeline) },
{
class: `row${state.selectedPipelineId === pipeline.id ? " selected" : ""}`,
"data-pipeline-id": String(pipeline.id),
onclick: () => selectPipeline(pipeline),
},
...children,
);
}
@@ -271,23 +275,7 @@ function renderPipelineDetail() {
pane.append(h("div", { class: "muted pad", text: "Select a pipeline." }));
return pane;
}
pane.append(h("h2", { text: d.name || `pipeline ${d.id}` }));
pane.append(
h(
"div",
{ class: "detail-tabs" },
...PIPELINE_DETAIL_TABS.map((tab) =>
h("button", {
class: `detail-tab${state.pipelineTab === tab.key ? " active" : ""}`,
text: tab.label,
onclick: () => {
state.pipelineTab = tab.key;
renderContent();
},
}),
),
),
);
pane.append(h("h1", { class: "detail-title", id: "detailTitle", tabindex: "-1", text: d.name || `pipeline ${d.id}` }));
if (state.pipelineTab === "graph") {
pane.append(h("p", { class: "graph-note muted", text: graphNote() }));
const stages = d.graph?.stages ?? [];
+8 -17
View File
@@ -123,24 +123,16 @@ function renderRunDetail(now = Date.now()) {
// the Android run detail does, so opening the run is enough — no tab hunt.
const decision = pendingDecision(d);
if (decision) pane.append(renderDecisionCard(decision));
pane.append(
h("h1", {
class: "run-detail-title",
id: "detailTitle",
tabindex: "-1",
text: runLabelFor(d),
}),
);
const actions = renderRunActions(d);
if (actions) pane.append(actions);
pane.append(
h(
"div",
{ class: "detail-tabs" },
...RENDERED_RUN_TABS.map((tab) =>
h("button", {
class: `detail-tab${state.runTab === tab.key ? " active" : ""}`,
text: tab.label,
onclick: () => {
state.runTab = tab.key;
renderContent();
},
}),
),
),
);
if (state.runTab === "graph") {
pane.append(renderRunGraphTab(d));
} else if (state.runTab === "input") {
@@ -702,7 +694,6 @@ function renderRunActions(d) {
function renderRunTitleRow(d) {
const row = h("div", { class: "run-title-row" });
row.append(h("h2", { class: "run-detail-title", text: runLabelFor(d) }));
if (state.renameValue == null) {
row.append(
h("button", {
+2 -1
View File
@@ -35,7 +35,7 @@ function renderRunList(now = Date.now()) {
const pane = h("div", { class: "list runs" });
pane.append(renderRunToolbar());
const scroll = h("div", { class: "run-scroll" });
const scroll = h("div", { class: "run-scroll list-scroll" });
if (state.loading && !state.runs.length) {
scroll.append(h("div", { class: "muted pad", text: "Loading…" }));
pane.append(scroll);
@@ -121,6 +121,7 @@ function renderRunRow(run, now) {
const identity = runIdentity(run.title, run.name);
const row = h("button", {
class: `row run-row${state.selectedRunId === run.id ? " selected" : ""}`,
"data-run-id": String(run.id),
onclick: () => selectRun(run.id),
});
+47 -4
View File
@@ -1,6 +1,6 @@
// Omni-search: the top-bar panel, kind/sort controls, rows and result routing.
// Debounce/staleness/ordering/empty-state decisions are pure in search.js; this
// module owns the DOM and the route hand-off.
// Omni-search: the shell's Search control, kind/sort controls, rows and result
// routing. Debounce/staleness/ordering/empty-state decisions are pure in
// search.js; this module owns the DOM and the route hand-off.
import { h } from "../dom.js";
import { describeError } from "../format.js";
@@ -28,6 +28,9 @@ export function createSearchView(rt) {
const { state, repo, searchHost } = rt;
let searchTimer = null;
let searchEdit = null;
// Where focus goes when the panel closes: the rail or dock Search control that
// opened it, so Escape/Close never drops the operator on <body>.
let searchTriggerId = null;
const renderHeader = (...args) => rt.renderHeader(...args);
const renderContent = (...args) => rt.renderContent(...args);
const selectPipeline = (...args) => rt.selectPipeline(...args);
@@ -40,6 +43,8 @@ export function createSearchView(rt) {
/** Open the search field and ask for focus; the current view is left alone. */
function openSearch() {
if (state.searchOpen) return;
const trigger = document.activeElement;
searchTriggerId = trigger && trigger.id ? trigger.id : null;
state.searchOpen = true;
state.searchError = "";
state.searchFocusPending = true;
@@ -68,6 +73,9 @@ function closeSearch() {
state.searchFocusPending = false;
renderHeader();
renderSearch();
const trigger = searchTriggerId ? document.getElementById(searchTriggerId) : null;
searchTriggerId = null;
if (trigger && trigger.getClientRects().length > 0) trigger.focus();
}
function cancelSearchDebounce() {
@@ -220,6 +228,35 @@ function renderSearch() {
);
sortSelect.value = state.searchSort;
const fieldRow = h(
"div",
{ class: "search-field-row" },
h("input", {
id: "searchInput",
class: "search-input",
type: "text",
placeholder: "Search pipelines, runs and artifacts",
value: state.searchQuery,
spellcheck: "false",
autocomplete: "off",
"aria-label": "Search",
oninput: (event) => onSearchInput(event.target.value),
onkeydown: (event) => {
if (event.key === "Enter") {
event.preventDefault();
sendSearchNow();
}
},
}),
h("button", {
id: "searchClose",
class: "ghost search-close",
type: "button",
text: "Close search",
onclick: () => closeSearch(),
}),
);
const controls = h(
"div",
{ class: "search-controls" },
@@ -241,7 +278,13 @@ function renderSearch() {
const area = h("div", { id: "searchResults", class: "search-results", "aria-live": "polite" });
fillSearchResults(area);
searchHost.replaceChildren(h("div", { id: "searchPanel", class: "search-panel" }, controls, area));
searchHost.replaceChildren(
h("div", { id: "searchPanel", class: "search-panel", role: "search", "aria-label": "Search" }, fieldRow, controls, area),
);
if (state.searchFocusPending) {
document.getElementById("searchInput")?.focus();
state.searchFocusPending = false;
}
}
/**
+10 -2
View File
@@ -26,7 +26,8 @@ import {
notificationEnvironment,
notificationPermissionState,
} from "../notify.js";
import { bannerState } from "../connection.js";
import { bannerState, protocolMismatch } from "../connection.js";
import { PROTOCOL_VERSION } from "../protocol.js";
export function createSettingsView(rt) {
const { state, repo, setServerUrlDraft, endpointConfigured } = rt;
@@ -48,6 +49,7 @@ export function createSettingsView(rt) {
function renderSettingsView() {
const pane = h("div", { class: "settings" });
pane.append(
h("h1", { class: "settings-page-title", id: "detailTitle", tabindex: "-1", text: "Settings" }),
renderSettingsConnection(),
renderSettingsWorkspace(),
renderSettingsNotifications(),
@@ -138,6 +140,12 @@ function renderSettingsConnection() {
card.append(h("p", { class: "settings-status-line", text: line }));
});
section.append(card, renderTrustWarning());
const warning = protocolMismatch(PROTOCOL_VERSION, state.serverProtocol);
if (warning) {
section.append(
h("p", { class: "settings-warning-line settings-protocol-warning", role: "alert", text: warning }),
);
}
return section;
}
@@ -223,7 +231,7 @@ function renderTrustWarning() {
/**
* Route a Settings connection control through the page's existing single client,
* mirroring AppViewModel: Disconnect closes the shared socket, Connect is
* connect-only (validate + persist + open — never the header's toggle), and
* connect-only (validate + persist + open — never a toggle), and
* Reconnect re-opens the same validated endpoint now. Nothing here opens a second
* connection.
*/
+5 -30
View File
@@ -27,6 +27,7 @@ import {
export function createTemplatesView(rt) {
const { state, repo } = rt;
const renderContent = (...args) => rt.renderContent(...args);
const focusDetailHeading = (...args) => rt.focusDetailHeading(...args);
const pushRoute = (...args) => rt.pushRoute(...args);
const setError = (...args) => rt.setError(...args);
const refreshPipelines = (...args) => rt.views.pipelines.refreshPipelines(...args);
@@ -60,14 +61,6 @@ function templateGraphFor(key) {
function renderTemplateGallery() {
const pane = h("div", { class: "list gallery" });
pane.append(
h(
"div",
{ class: "pane-head" },
h("h2", { text: "Templates" }),
h("button", { class: "ghost", text: "Refresh templates", onclick: () => loadTemplates(true) }),
),
);
if (state.templateLoading && !state.templates.length) {
pane.append(h("div", { class: "muted pad", text: "Loading templates…" }));
return pane;
@@ -76,7 +69,7 @@ function renderTemplateGallery() {
pane.append(h("div", { class: "muted pad", text: "No templates are available on this server." }));
return pane;
}
const cards = h("div", { class: "cards" });
const cards = h("div", { class: "cards list-scroll" });
for (const entry of state.templates) {
const card = templateCard(entry, templateGraphFor(entry.key));
cards.append(
@@ -84,6 +77,7 @@ function renderTemplateGallery() {
"button",
{
class: `card${state.selectedTemplateKey === entry.key ? " selected" : ""}`,
"data-template-key": entry.key,
onclick: () => selectTemplate(entry.key),
},
h("span", { class: "card-name", text: templateGalleryName(card.name) }),
@@ -105,15 +99,7 @@ function renderTemplateDetail() {
}
const graph = templateGraphFor(entry.key);
pane.append(renderTemplateDetailActions());
pane.append(
h(
"div",
{ class: "tabstrip" },
templateTabButton("summary", "Summary"),
templateTabButton("graph", "Graph"),
templateTabButton("source", "Source"),
),
);
pane.append(h("h1", { class: "detail-title", id: "detailTitle", tabindex: "-1", text: templateDetailName(entry) }));
if (state.templateTab === "graph") pane.append(renderTemplateGraphTab(graph));
else if (state.templateTab === "source") pane.append(renderTemplateSourceTab(entry, graph));
else pane.append(renderTemplateSummaryTab(entry, graph));
@@ -287,20 +273,8 @@ async function createFromTemplate(entry) {
renderContent();
}
function templateTabButton(tab, label) {
return h("button", {
class: `minitab${state.templateTab === tab ? " active" : ""}`,
text: label,
onclick: () => {
state.templateTab = tab;
renderContent();
},
});
}
function renderTemplateSummaryTab(entry, graph) {
const wrap = h("div", { class: "tabbody" });
wrap.append(h("h2", { text: templateDetailName(entry) }));
if ((entry.description ?? "").trim()) {
wrap.append(h("p", { class: "body", text: entry.description }));
}
@@ -392,6 +366,7 @@ function selectTemplate(key) {
state.selectedTemplateKey = key || null;
resetTemplateCreateState();
renderContent();
if (key) focusDetailHeading();
}
return {