The per-agent page had these and the swarm terminal did not; they need no new backend. A cancel turn button beside send, shown while the agent is in a turn, posts to the controller's existing cancel route and says whether a turn was stopped. The terminal's badges add the effort and how long the agent has been in its turn state. The expand tool output setting moves to the shared package so both pages render the one component, and the swarm menu gets it. Docs follow.
25 lines
868 B
JavaScript
25 lines
868 B
JavaScript
// What the terminal page decides about cancelling a turn. Run by `npm test`.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import {
|
|
canCancel,
|
|
cancelNote,
|
|
cancelPath,
|
|
} from "../src/agent/terminal/cancel.ts";
|
|
|
|
test("cancel is offered while the agent is in a turn, and only then", () => {
|
|
assert.equal(canCancel("thinking"), true);
|
|
assert.equal(canCancel("idle"), false);
|
|
assert.equal(canCancel("compacting"), false);
|
|
assert.equal(canCancel(undefined), false);
|
|
});
|
|
|
|
test("the cancel path names the agent, escaped", () => {
|
|
assert.equal(cancelPath("iris"), "/api/agents/iris/cancel");
|
|
assert.equal(cancelPath("a/b"), "/api/agents/a%2Fb/cancel");
|
|
});
|
|
|
|
test("the note says whether a turn was stopped", () => {
|
|
assert.equal(cancelNote(true), "turn cancelled");
|
|
assert.equal(cancelNote(false), "nothing was running");
|
|
});
|