Human-facing task state
This commit is contained in:
+9
-13
@@ -2,7 +2,7 @@ import { get, post, type ByreEvent, type Project, type Schemas, type Task } from
|
||||
import { errorText, h, replace, showAlert } from "./dom.js";
|
||||
import { markdown } from "./markdown.js";
|
||||
import { models } from "./task.js";
|
||||
import { currentSession, findTask, focusedProject, focusTask, on, onEach, state, taskState } from "./state.js";
|
||||
import { findTask, focusedProject, focusTask, on, onEach, state, taskState, type TaskState } from "./state.js";
|
||||
import { taskStyle } from "./taskcolor.js";
|
||||
|
||||
type Todo = Schemas["Todo"];
|
||||
@@ -121,13 +121,11 @@ function nested(active: Task[]): { task: Task; depth: number }[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
const busyStates = new Set(["running", "reviewing", "merging", "discarding"]);
|
||||
|
||||
function stateMark(s: string | undefined): HTMLElement {
|
||||
if (s !== undefined && busyStates.has(s)) {
|
||||
return h("span", { class: "spinner", title: s });
|
||||
function stateMark(ts: TaskState): HTMLElement {
|
||||
if (ts.kind === "working" || ts.kind === "merging") {
|
||||
return h("span", { class: "spinner", title: ts.title });
|
||||
}
|
||||
return h("span", { class: `dot ${s ?? "none"}`, title: s ?? "no session" });
|
||||
return h("span", { class: `dot ${ts.kind}`, title: ts.title });
|
||||
}
|
||||
|
||||
function tasksBlock(active: Task[]): HTMLElement {
|
||||
@@ -157,9 +155,7 @@ function tasksBlock(active: Task[]): HTMLElement {
|
||||
stateMark(ts),
|
||||
h("span", { class: "task-title task-name" }, task.title),
|
||||
count > 0 && h("span", { class: "badge", title: "inbox items" }, count),
|
||||
task.merge_queued_at !== undefined && h("span", { class: "task-state warn", title: "Waiting for the merge in progress in this project to finish" }, "merge held"),
|
||||
task.merging_into_parent && h("span", { class: "task-state warn", title: "Waiting for the parent task's agent to merge it" }, "merging into parent"),
|
||||
h("span", { class: "task-state" }, ts ?? "no agent"),
|
||||
h("span", { class: `task-state ${ts.kind}`, title: ts.title }, ts.label),
|
||||
),
|
||||
);
|
||||
}),
|
||||
@@ -196,7 +192,7 @@ function todoBlock(project: Project, todo: Todo | string | undefined, active: Ta
|
||||
const task = active.find((t) => t.todo_item === item.title);
|
||||
let action: HTMLElement;
|
||||
if (task) {
|
||||
const sess = currentSession(task.id);
|
||||
const ts = taskState(task);
|
||||
action = h(
|
||||
"a",
|
||||
{
|
||||
@@ -207,8 +203,8 @@ function todoBlock(project: Project, todo: Todo | string | undefined, active: Ta
|
||||
focusTask(task.id);
|
||||
},
|
||||
},
|
||||
stateMark(sess?.state),
|
||||
sess?.state ?? "no agent",
|
||||
stateMark(ts),
|
||||
ts.label,
|
||||
);
|
||||
} else {
|
||||
const busy = starting.has(`${project.id}\n${item.title}`);
|
||||
|
||||
Reference in New Issue
Block a user