Human-facing task state

This commit is contained in:
Ian Gulliver
2026-10-16 10:59:46 -07:00
parent 07780b8701
commit db58d76837
12 changed files with 78 additions and 54 deletions
+17 -5
View File
@@ -55,14 +55,26 @@ export function currentSession(taskId) {
return state.sessions.get(taskId)?.findLast((s) => s.state !== "completed") ?? state.sessions.get(taskId)?.at(-1);
}
export function taskState(task) {
if (task.discarding) {
return "discarding";
const open = state.inbox.filter((item) => item.task_id === task.id);
if (open.some((item) => item.kind === "question")) {
return { kind: "answer", label: "Needs your answer", title: "The agent asked a question in the inbox" };
}
if (task.merging) {
return "merging";
return { kind: "merging", label: "Merging", title: "The merge turn is running" };
}
const s = currentSession(task.id)?.state;
return s === "idle" && task.reviewing ? "reviewing" : s;
if (task.merging_into_parent) {
return { kind: "merging", label: "Merging", title: "Waiting for the parent task's agent to merge it" };
}
if (task.merge_queued_at !== undefined) {
return { kind: "held", label: "Merge held", title: "Waiting for the merge in progress in this project to finish" };
}
if (open.length > 0) {
return { kind: "error", label: "Error", title: "The agent's session failed or hit a rate limit; see the inbox" };
}
if (task.discarding || task.reviewing || currentSession(task.id)?.state === "running") {
return { kind: "working", label: "Working", title: task.discarding ? "Discarding" : task.reviewing ? "A review is running" : "The agent is mid-turn" };
}
return { kind: "idle", label: "Idle", title: "Waiting for a message" };
}
export function currentLead() {
return state.leadSessions.findLast((s) => s.state !== "completed") ?? state.leadSessions.at(-1);