fix: persist and retry run alerts and honor notification modes
This commit is contained in:
+1
-1
@@ -166,7 +166,7 @@ to it, but the server never lists it and a reload drops it.
|
||||
| B3 | Equal phone dock cells | — | done — the narrow dock is a four-cell grid (one cell per destination plus Search) with a subgrid for the tablist, so every control has the same width and height. At 390×844 the measured widths are 92/92/92/92 and the row is 48px high. The phone shell uses `100svh` so a browser toolbar cannot hide the tab row while leaving only the Connected/Settings status row visible. |
|
||||
| B4 | Full-height pipeline Source | — | done — the Source block no longer caps itself at `60vh`; it is as tall as its content and the detail pane owns the scroll. Verified at 390×844: a 4386px definition sits in the full pane (656px viewport) and scrolls. |
|
||||
| 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. |
|
||||
| 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 stage, run-level and browser tray notifications (Needs you still reflects run state). Auto retains existing definition plus waiting/failed defaults; on additionally alerts terminal success, including runs without notify hooks. Mode travels in summaries/events and is inherited by retries unless overridden. Run-level system publications use a durable bounded-retry outbox and publisher receipts; stage final success coverage avoids a second system alert. Browser mode behavior is unit-tested, not OS-observed; no new UI captures in this audit. |
|
||||
| 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), abbreviating the server home prefix to `~` (`~/repos/pipelines`) in both the band and the row meta. `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. |
|
||||
|
||||
+20
-6
@@ -1,6 +1,5 @@
|
||||
// Pure, DOM-free notification model for failed/waiting runs (L5). It mirrors
|
||||
// android/.../notify/RunAlerts.kt: the same two qualifying kinds, the same
|
||||
// headlines, the same run line and the same one-notification-per-run+kind rule.
|
||||
// Pure, DOM-free notification model. Auto retains failed/waiting alerts;
|
||||
// per-run on also alerts terminal success and off suppresses every tray alert.
|
||||
//
|
||||
// Everything here is pure: no DOM, no clock, no storage access. The page owns
|
||||
// the Notification constructor, the permission request gesture and localStorage;
|
||||
@@ -13,14 +12,16 @@ import { AttentionKind, attentionKey, attentionKindOf } from "./attention.js";
|
||||
// Kinds, headlines and the run line
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** The two run events that raise a notification (RunAlerts.kt RunAlertKind). */
|
||||
/** Notification kinds; success does not create a Needs you entry. */
|
||||
export const RunAlertKind = Object.freeze({
|
||||
Decision: AttentionKind.Decision,
|
||||
Failed: AttentionKind.Failed,
|
||||
Succeeded: Object.freeze({ name: "Succeeded" }),
|
||||
});
|
||||
|
||||
/** `alertKindOf`: an attention kind is already exactly the notification kind. */
|
||||
export function alertKindOf(kind) {
|
||||
if (kind?.name === "Succeeded") return RunAlertKind.Succeeded;
|
||||
if (kind === AttentionKind.Decision || kind?.name === AttentionKind.Decision.name) {
|
||||
return AttentionKind.Decision;
|
||||
}
|
||||
@@ -37,6 +38,8 @@ export function alertTitle(kind) {
|
||||
return "A run needs your decision";
|
||||
case "Failed":
|
||||
return "A run failed";
|
||||
case "Succeeded":
|
||||
return "A run succeeded";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@@ -90,15 +93,18 @@ export function alertBody(run) {
|
||||
*/
|
||||
export function createAlertLedger() {
|
||||
const lastStatus = new Map();
|
||||
const modes = new Map();
|
||||
const notified = new Set();
|
||||
let seeding = false;
|
||||
|
||||
function seed(runs) {
|
||||
const next = new Map();
|
||||
modes.clear();
|
||||
for (const run of runs ?? []) {
|
||||
const runId = runIdOf(run?.id ?? run?.run_id);
|
||||
if (runId == null) continue;
|
||||
next.set(runId, normalizeStatus(run?.status));
|
||||
modes.set(runId, normalizeStatus(run?.notify_mode) || "auto");
|
||||
}
|
||||
lastStatus.clear();
|
||||
for (const [runId, status] of next) lastStatus.set(runId, status);
|
||||
@@ -113,16 +119,23 @@ export function createAlertLedger() {
|
||||
const previous = lastStatus.get(runId);
|
||||
lastStatus.set(runId, status);
|
||||
|
||||
const kind = attentionKindOf(status);
|
||||
if (frame?.notify_mode != null) modes.set(runId, normalizeStatus(frame.notify_mode));
|
||||
const mode = modes.get(runId) || "auto";
|
||||
|
||||
const kind = status === "succeeded" && mode === "on" ? RunAlertKind.Succeeded : attentionKindOf(status);
|
||||
if (!kind) {
|
||||
forget(runId, AttentionKind.Decision);
|
||||
forget(runId, AttentionKind.Failed);
|
||||
forget(runId, RunAlertKind.Succeeded);
|
||||
return null;
|
||||
}
|
||||
// A run can only be in one qualifying state; forget the other kind's key so
|
||||
// a later transition back into it is a new event.
|
||||
forget(runId, kind === AttentionKind.Decision ? AttentionKind.Failed : AttentionKind.Decision);
|
||||
for (const other of Object.values(RunAlertKind)) {
|
||||
if (other !== kind) forget(runId, other);
|
||||
}
|
||||
if (seeding) return null;
|
||||
if (mode === "off") return null;
|
||||
if (previous === undefined || previous === status) return null;
|
||||
|
||||
const key = alertKey(runId, kind);
|
||||
@@ -143,6 +156,7 @@ export function createAlertLedger() {
|
||||
|
||||
function reset() {
|
||||
lastStatus.clear();
|
||||
modes.clear();
|
||||
seeding = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,7 @@ function sameResourceWait(a, b) {
|
||||
/** The run-state fields a frame advances, shared by the summary row and the detail. */
|
||||
function runStateFields(current) {
|
||||
return {
|
||||
notify_mode: current.notify_mode ?? "auto",
|
||||
resource_wait: current.resource_wait ?? null,
|
||||
status: current.status ?? "",
|
||||
outcome: current.outcome ?? "",
|
||||
@@ -196,6 +197,7 @@ function applyRunStateFields(current, frame) {
|
||||
? "queued"
|
||||
: advanceRunStatus(before.status, frame.status);
|
||||
const merged = {
|
||||
notify_mode: blank(frame.notify_mode) ? before.notify_mode : frame.notify_mode,
|
||||
resource_wait: isTerminalRunStatus(status)
|
||||
? null
|
||||
: frame.resource_wait_set === true
|
||||
@@ -210,6 +212,7 @@ function applyRunStateFields(current, frame) {
|
||||
executing: executingFor(status, before.executing),
|
||||
};
|
||||
const changed =
|
||||
merged.notify_mode !== before.notify_mode ||
|
||||
!sameResourceWait(merged.resource_wait, before.resource_wait) ||
|
||||
merged.status !== before.status ||
|
||||
merged.outcome !== before.outcome ||
|
||||
@@ -236,6 +239,7 @@ export function newRunSummaryFromFrame(frame) {
|
||||
id: Number(frame.run_id),
|
||||
pipeline_id: pipelineId,
|
||||
name,
|
||||
notify_mode: frame.notify_mode ?? "auto",
|
||||
title: blank(frame.title) ? null : frame.title,
|
||||
version: Number(frame.version) || 0,
|
||||
status: frame.status ?? "",
|
||||
|
||||
@@ -31,6 +31,26 @@ const frame = (runId, status, extra = {}) => ({
|
||||
...extra,
|
||||
});
|
||||
|
||||
test("off suppresses every browser alert from summaries and pushed modes", () => {
|
||||
for (const status of ["waiting", "failed", "succeeded"]) {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 1, status: "running", notify_mode: "off" }]);
|
||||
assert.equal(ledger.observe(frame(1, status)), null);
|
||||
ledger.seed([{ id: 1, status: "running", notify_mode: "on" }]);
|
||||
assert.equal(ledger.observe(frame(1, status, { notify_mode: "off" })), null);
|
||||
}
|
||||
});
|
||||
|
||||
test("on adds final success once while auto retains attention-only semantics", () => {
|
||||
const ledger = createAlertLedger();
|
||||
ledger.seed([{ id: 1, status: "running", notify_mode: "on" }, { id: 2, status: "running", notify_mode: "auto" }]);
|
||||
const alert = ledger.observe(frame(1, "succeeded"));
|
||||
assert.equal(alert.title, "A run succeeded");
|
||||
assert.equal(alert.key, "1:Succeeded");
|
||||
assert.equal(ledger.observe(frame(1, "succeeded")), null);
|
||||
assert.equal(ledger.observe(frame(2, "succeeded")), null);
|
||||
});
|
||||
|
||||
test("headlines are exactly the app's two, and unknown kinds are blank", () => {
|
||||
assert.equal(alertTitle(AttentionKind.Failed), "A run failed");
|
||||
assert.equal(alertTitle(AttentionKind.Decision), "A run needs your decision");
|
||||
|
||||
@@ -87,6 +87,16 @@ function frame({
|
||||
|
||||
// --- lifecycle vocabulary ----------------------------------------------------
|
||||
|
||||
test("run summaries and detail preserve notification mode from live frames", () => {
|
||||
const incoming = { ...frame({ pipelineId: 4, name: "test", status: "queued" }), notify_mode: "off" };
|
||||
assert.equal(newRunSummaryFromFrame(incoming).notify_mode, "off");
|
||||
const runs = [summary(1)];
|
||||
const folded = foldRunEvent(runs, { ...incoming, status: "running" });
|
||||
assert.equal(folded.runs[0].notify_mode, "off");
|
||||
const result = foldRunEventDetail(detail({status:"running"}), { ...incoming, status: "failed" });
|
||||
assert.equal(result.notify_mode, "off");
|
||||
});
|
||||
|
||||
test("the lifecycle ladders mirror RunEvents.kt", () => {
|
||||
assert.deepEqual(TERMINAL_RUN_STATUSES, ["succeeded", "failed", "canceled", "interrupted"]);
|
||||
assert.equal(runLifecycleRank("queued"), 0);
|
||||
|
||||
Reference in New Issue
Block a user