| 1 | /** |
| 2 | * An agent session's card in chat (`card.kind === "session"`), on old |
| 3 | * messages: g1t's agents posted it and kept it current. Agents no longer |
| 4 | * exist, so it is read-only and its state is where it was left; nothing |
| 5 | * pulses, since nothing is happening. |
| 6 | */ |
| 7 | |
| 8 | /** The states an agent session's card shows. */ |
| 9 | export const SESSION_STATES = ["Queued", "Working", "Waiting on helpers", "Needs approval", "Done", "Stopped", "Failed"] as const; |
| 10 | |
| 11 | export type SessionState = (typeof SESSION_STATES)[number]; |
| 12 | |
| 13 | /** How a state reads: its badge tone, and whether it is happening now (a soft pulse: never, now). */ |
| 14 | export type SessionChip = { tone: "neutral" | "accent" | "info" | "warn" | "success" | "danger"; live: boolean }; |
| 15 | |
| 16 | const CHIPS: Record<string, SessionChip> = { |
| 17 | queued: { tone: "neutral", live: false }, |
| 18 | working: { tone: "accent", live: false }, |
| 19 | "waiting on helpers": { tone: "info", live: false }, |
| 20 | "needs approval": { tone: "warn", live: false }, |
| 21 | done: { tone: "success", live: false }, |
| 22 | stopped: { tone: "neutral", live: false }, |
| 23 | failed: { tone: "danger", live: false }, |
| 24 | }; |
| 25 | |
| 26 | /** A session card's state chip; a state it does not know reads quietly. */ |
| 27 | export function sessionChip(state: string | null | undefined): SessionChip { |
| 28 | return CHIPS[String(state ?? "").trim().toLowerCase()] ?? { tone: "neutral", live: false }; |
| 29 | } |