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.
18 lines
750 B
TypeScript
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";
|
|
}
|