Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/src/agent/terminal/cancel.ts
iris 214d7000d3 swarm-ui: the agent terminal page gets cancel turn, effort, state age and the expand-output setting
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.
2026-10-28 20:12:11 +01:00

18 lines
750 B
TypeScript

// What the terminal page decides about cancelling a turn, without a DOM. The
// controller answers `POST /api/agents/{name}/cancel` with whether a turn was
// running and was stopped (`acted`), so a cancel is never silently a no-op.
/** Whether to offer the cancel button: while the agent is in a turn. */
export function canCancel(turnState: string | undefined): boolean {
return turnState === "thinking";
}
/** The path a cancel is sent to. */
export function cancelPath(agentName: string): string {
return `/api/agents/${encodeURIComponent(agentName)}/cancel`;
}
/** What to tell the operator once the agent has answered. */
export function cancelNote(acted: boolean): string {
return acted ? "turn cancelled" : "nothing was running";
}