web: run pipelines from the browser and quiet background chat

Add the Run pipeline dialog with prompt, server directory and a per-run
notification choice; add --notify auto/on/off to run and retry; move the live
tool call onto the tool-count line and tick the reasoning duration; stop chat
frames from repainting a different screen.
This commit is contained in:
2026-10-20 12:56:47 +01:00
parent f7a3a49f94
commit 0d7e81362f
17 changed files with 428 additions and 80 deletions
+178 -1
View File
@@ -29,10 +29,11 @@ import { statusIcon } from "../statusIcon.js";
import { writeGraphExpanded } from "../graphPrefs.js";
export function createPipelinesView(rt) {
const { state, repo } = rt;
const { state, repo, modal } = rt;
const renderContent = (...args) => rt.renderContent(...args);
const selectPipeline = (...args) => rt.selectPipeline(...args);
const pushRoute = (...args) => rt.pushRoute(...args);
const applyRoute = (...args) => rt.applyRoute(...args);
function renderPipelineList() {
@@ -374,6 +375,171 @@ function pipelineGlyph() {
return svg;
}
/** Open the Run pipeline dialog for [pipeline]. */
async function openRunDialog(pipeline) {
const pipelineId = Number(pipeline?.id) || 0;
if (pipelineId <= 0) return;
const start = {
pipelineId,
version: Number(pipeline?.version) || Number(pipeline?.latest_version) || 0,
name: String(pipeline?.name ?? ""),
prompt: "",
workspace: String(state.workspace ?? "").startsWith("/") ? state.workspace : "",
notifyMode: "auto",
directories: [],
loading: true,
sending: false,
error: "",
};
state.runStart = start;
renderContent();
try {
const directories = await repo.chatDirectories();
start.directories = Array.isArray(directories)
? directories.filter((entry) => typeof entry === "string" && entry.startsWith("/"))
: [];
} catch (error) {
start.directories = [];
start.error = describeError(error);
}
if (!start.workspace && start.directories.length) start.workspace = start.directories[0];
start.loading = false;
if (state.runStart === start) renderContent();
}
function closeRunDialog() {
state.runStart = null;
renderContent();
}
async function startRun() {
const start = state.runStart;
if (!start || start.sending) return;
const prompt = start.prompt.trim();
if (prompt === "") {
start.error = "Enter a prompt for this run.";
renderContent();
return;
}
if (!start.workspace.startsWith("/")) {
start.error = "Choose an absolute working directory on the server.";
renderContent();
return;
}
start.sending = true;
start.error = "";
renderContent();
try {
const run = await repo.runPipeline({
pipelineId: start.pipelineId,
version: start.version,
prompt,
workspace: start.workspace,
notifyMode: start.notifyMode,
title: "",
});
state.runStart = null;
await applyRoute({ kind: "run", id: run.id });
} catch (error) {
if (state.runStart !== start) return;
start.sending = false;
start.error = describeError(error);
renderContent();
}
}
function renderRunStartDialog() {
const start = state.runStart;
const overlay = h("div", {
class: "confirm-dialog run-start-dialog",
role: "dialog",
"aria-modal": "true",
"aria-label": `Run ${start.name || "pipeline"}`,
});
overlay.addEventListener("click", (event) => {
if (event.target === overlay) closeRunDialog();
});
const panel = h("div", { class: "confirm-panel" });
panel.append(h("h2", { class: "confirm-title", text: `Run ${start.name || "pipeline"}` }));
const promptField = h("label", { class: "run-start-field", for: "runPrompt" });
promptField.append(h("span", { class: "run-start-label", text: "Prompt" }));
const prompt = h("textarea", {
id: "runPrompt",
class: "run-start-prompt",
rows: "5",
placeholder: "What should this run do?",
spellcheck: "false",
oninput: (event) => { start.prompt = event.target.value; },
});
prompt.value = start.prompt;
promptField.append(prompt);
panel.append(promptField);
const listId = "runWorkspaceChoices";
const datalist = h("datalist", { id: listId });
for (const directory of start.directories) datalist.append(h("option", { value: directory }));
const workField = h("label", { class: "run-start-field", for: "runWorkspace" });
workField.append(h("span", { class: "run-start-label", text: "Working directory (on the server)" }));
const work = h("input", {
id: "runWorkspace",
type: "text",
list: listId,
value: start.workspace,
spellcheck: "false",
autocomplete: "off",
placeholder: "/absolute/path/on/the/server",
oninput: (event) => { start.workspace = event.target.value; },
});
workField.append(work, datalist);
workField.append(h("span", { class: "run-start-helper muted", text: "Choose a recent directory or type an absolute path." }));
panel.append(workField);
const notifyField = h("label", { class: "run-start-field", for: "runNotify" });
notifyField.append(h("span", { class: "run-start-label", text: "Notifications for this run" }));
const notify = h("select", { id: "runNotify", onchange: (event) => { start.notifyMode = event.target.value; } });
for (const [value, label] of [
["auto", "Pipeline default"],
["on", "Notify me"],
["off", "Silent"],
]) {
const option = h("option", { value, text: label });
option.selected = start.notifyMode === value;
notify.append(option);
}
notifyField.append(notify);
panel.append(notifyField);
if (start.loading) panel.append(h("div", { class: "run-start-helper muted", text: "Loading directories…" }));
if (start.error) panel.append(h("div", { class: "run-start-error", role: "alert", text: start.error }));
const actions = h("div", { class: "confirm-actions" });
actions.append(
h("button", {
class: "ghost run-start-cancel",
type: "button",
text: "Cancel",
disabled: start.sending,
onclick: closeRunDialog,
}),
h("button", {
class: "primary run-start-confirm",
type: "button",
text: start.sending ? "Starting…" : "Run",
disabled: start.sending,
onclick: startRun,
}),
);
panel.append(actions);
overlay.append(panel);
modal.stage("run-start", overlay, {
onClose: closeRunDialog,
triggerSelector: ".run-pipeline",
fallbackSelectors: ["#detailTitle", "#pane-main"],
});
return overlay;
}
function renderPipelineDetail() {
const d = state.pipelineDetail;
const pane = h("div", { class: "detail" });
@@ -382,6 +548,16 @@ function renderPipelineDetail() {
return pane;
}
pane.append(h("h1", { class: "detail-title", id: "detailTitle", tabindex: "-1", text: d.name || `pipeline ${d.id}` }));
pane.append(
h("div", { class: "pipeline-actions" },
h("button", {
class: "primary run-pipeline",
type: "button",
text: "Run",
onclick: () => openRunDialog(d),
}),
),
);
if (state.pipelineTab === "graph") {
pane.append(h("p", { class: "graph-note muted", text: graphNote() }));
const stages = d.graph?.stages ?? [];
@@ -466,6 +642,7 @@ function renderPipelineDetail() {
}
pane.append(body);
}
if (state.runStart) pane.append(renderRunStartDialog());
return pane;
}