web: run-level actions — human decision, cancel, retry and rename (R11–R14)

Add the run-level operator actions to the browser run detail, matching the
Android client's wording and wire frames:

- R11 human decision: pure model in src/actions.js (pendingDecision,
  lastWaitingStep, waitingPrompt/waitingOptions, humanOptions,
  decisionTargetLabel, DecisionDraft) plus the decision card and sheet;
  decide_run sends run_id, the chosen option and trimmed feedback.
- R12 cancel: a Cancel run action offered only while executing; the Android
  confirm copy; cancel_run then a silent get_run refresh.
- R13 retry: offered only for a loaded, non-executing failed run; resume is
  the default (no retry_mode, like Android) with a browser-only
  Restart from start secondary that sends retry_mode:"restart".
- R14 rename: an inline set_run_title field; refreshes the run and its list row.
- One shared Action failed dialog for all of the above.

Add the protocol constants and typed builders, a hand-written dark-palette
section for the card/sheet/dialogs, focused unit tests for the helpers and
request shapes, and ui-smoke captures for the new states. Update PARITY.md:
R11 stays partial (no live waiting run), R12–R14 done with the stated
shown-not-executed and Android-divergence notes.

Also harden openRunDetail() in the UI smoke: the tabstrip already exists from
the previously opened run, so wait for the target run's identity line before
asserting on its actions (review finding).
This commit is contained in:
2026-10-19 04:37:35 +01:00
parent 9555bfe58f
commit 6992ecd4e8
9 changed files with 1534 additions and 14 deletions
+88
View File
@@ -104,3 +104,91 @@ test("validate throws when the reply has no graph", async () => {
ws.reply = (frame) => ({ id: frame.id, type: "validated" });
await assert.rejects(() => repo.validate("empty"), ProtocolError);
});
/** The run detail a run.action reply carries in these tests. */
const RUN_DETAIL = { id: 440, status: "failed" };
test("decideRun sends exactly {type:'decide_run',run_id,option,feedback} and returns the run detail", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "run", run_detail: RUN_DETAIL });
const detail = await repo.decideRun(440, { stage: "review", option: "approve", feedback: " yes " });
assert.deepEqual(lastFrame(ws), {
type: "decide_run",
run_id: 440,
stage: "review",
option: "approve",
feedback: "yes",
});
assert.deepEqual(detail, RUN_DETAIL);
});
test("decideRun omits a blank stage and blank feedback", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "run", run_detail: RUN_DETAIL });
await repo.decideRun(12, { stage: " ", option: "publish", feedback: " " });
assert.deepEqual(lastFrame(ws), { type: "decide_run", run_id: 12, option: "publish" });
});
test("cancelRun sends exactly {type:'cancel_run',run_id} and returns the run detail", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "run", run_detail: RUN_DETAIL });
const detail = await repo.cancelRun(440);
assert.deepEqual(lastFrame(ws), { type: "cancel_run", run_id: 440 });
assert.deepEqual(detail, RUN_DETAIL);
});
test("retryRun always sends request_key and omits retry_mode for the default resume", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "run_started", run_detail: RUN_DETAIL });
await repo.retryRun(440, { requestKey: "key-1" });
assert.deepEqual(lastFrame(ws), { type: "retry_run", run_id: 440, request_key: "key-1" });
});
test("retryRun sends retry_mode only for an explicit restart", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "run_started", run_detail: RUN_DETAIL });
await repo.retryRun(440, { mode: "restart", requestKey: "key-2" });
assert.deepEqual(lastFrame(ws), {
type: "retry_run",
run_id: 440,
request_key: "key-2",
retry_mode: "restart",
});
});
test("setRunTitle sends exactly {type:'set_run_title',run_id,title} and returns the run detail", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "run", run_detail: RUN_DETAIL });
const detail = await repo.setRunTitle(440, "New title");
assert.deepEqual(lastFrame(ws), { type: "set_run_title", run_id: 440, title: "New title" });
assert.deepEqual(detail, RUN_DETAIL);
});
test("each run action rejects a server error envelope instead of returning a detail", async () => {
const calls = [
(repo) => () => repo.decideRun(440, { option: "approve" }),
(repo) => () => repo.cancelRun(440),
(repo) => () => repo.retryRun(440, { requestKey: "key-3" }),
(repo) => () => repo.setRunTitle(440, ""),
];
for (const makeCall of calls) {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "error", error: "a title with usable text is required" });
await assert.rejects(makeCall(repo), {
name: "ProtocolError",
message: "a title with usable text is required",
});
}
});
test("a run action throws when the reply has no run detail", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "run" });
await assert.rejects(() => repo.cancelRun(7), ProtocolError);
});