Inbox consideration

This commit is contained in:
Ian Gulliver
2026-10-15 20:20:02 -07:00
parent 35368242e3
commit 8d5ebe727a
13 changed files with 186 additions and 6 deletions
+10
View File
@@ -1,6 +1,7 @@
import { copyable, h } from "./dom.js";
import { diagram } from "./mermaid.js";
import { taskStyle } from "./taskcolor.js";
import { todoLink } from "./todolink.js";
const choiceMarker = /^(\([ *]\)|\[[ xX]\])\s+(\S.*?)\s*$/;
const detailsOpen = /^\s*<details>\s*(?:<summary>(.*?)<\/summary>)?\s*$/i;
const summaryLine = /^\s*<summary>(.*?)<\/summary>\s*$/i;
@@ -275,6 +276,15 @@ function link(href, children) {
if (task) {
return h("a", { href, class: "task-link", style: taskStyle(task[1]) }, ...children);
}
const todo = /^#\/todo\/(\w+)\/(.+)$/.exec(href);
if (todo) {
try {
return todoLink(todo[1], decodeURIComponent(todo[2]), children);
}
catch {
return h("span", {}, ...children);
}
}
if (href.startsWith("#/")) {
return h("a", { href }, ...children);
}
+1 -1
View File
File diff suppressed because one or more lines are too long
+4
View File
@@ -5,6 +5,7 @@ import { previewURL } from "./preview.js";
import { findingCount, reviewCounts } from "./reviews.js";
import { currentSession, findTask, focusTab, focusTask, onEach, pinSnapshot, setFocus, showReview, state } from "./state.js";
import { taskStyle } from "./taskcolor.js";
import { fillTodoLinks } from "./todolink.js";
export const models = [
"claude-opus-5-5",
"claude-sonnet-5-5",
@@ -302,6 +303,7 @@ export function mountChat(root, src, makeHead) {
stream.timer = 0;
stream.el.hidden = ctx.held !== undefined || quietReply.startsWith(stream.text.trim());
replace(stream.el, markdown(stream.text, "text md", { taskId: ctx.taskId }));
fillTodoLinks(stream.el, models[0]);
pin();
}, 100);
};
@@ -414,6 +416,7 @@ export function mountChat(root, src, makeHead) {
renderComposer();
}
}
fillTodoLinks(transcript, models[0]);
pin();
};
const renderAll = () => {
@@ -442,6 +445,7 @@ export function mountChat(root, src, makeHead) {
}),
onEach([src.transcriptTopic], (fresh) => appendEvents(fresh)),
onEach([src.streamTopic], (ev) => appendDelta(ev)),
onEach(["tasks", "sessions"], () => fillTodoLinks(transcript, models[0])),
];
replace(root, h("div", { class: "transcript-view" }, head, transcript, composer));
renderAll();
+1 -1
View File
File diff suppressed because one or more lines are too long
+53
View File
@@ -0,0 +1,53 @@
import { post } from "./api.js";
import { errorText, h, replace, showAlert } from "./dom.js";
import { currentSession, focusTask, state } from "./state.js";
import { taskStyle } from "./taskcolor.js";
const starting = new Set();
export function todoLink(projectId, title, children) {
return h("span", { class: "todo-link", data: { project: projectId, title } }, h("span", { class: "todo-title" }, ...children), " ", h("span", { class: "todo-action" }));
}
export function fillTodoLinks(root, model) {
for (const el of root.querySelectorAll(".todo-link")) {
fill(el, model);
}
}
function fill(el, model) {
const projectId = el.dataset["project"];
const title = el.dataset["title"];
const action = el.querySelector(".todo-action");
const titleEl = el.querySelector(".todo-title");
const task = (state.tasks.get(projectId) ?? []).find((t) => t.status === "active" && t.todo_item === title);
if (task) {
const sess = currentSession(task.id);
el.setAttribute("style", taskStyle(task.id));
titleEl.classList.add("task-name");
replace(action, h("a", {
class: "todo-task",
href: `#/task/${task.id}`,
onclick: (e) => {
e.preventDefault();
focusTask(task.id);
},
}, h("span", { class: `dot ${sess?.state ?? "none"}`, title: sess?.state ?? "no session" }), sess?.state ?? "no agent"));
return;
}
el.removeAttribute("style");
titleEl.classList.remove("task-name");
const key = `${projectId}\n${title}`;
const busy = starting.has(key);
const button = h("button", { disabled: busy }, busy ? "Starting…" : "Start");
button.onclick = async () => {
starting.add(key);
fill(el, model);
try {
await post("/api/projects/{projectId}/todo/tasks", { path: { projectId }, body: { title, model } });
}
catch (err) {
void showAlert(errorText(err));
}
starting.delete(key);
fill(el, model);
};
replace(action, button);
}
//# sourceMappingURL=todolink.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"todolink.js","sourceRoot":"","sources":["../src/todolink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE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AC,OAAO,CAAC,CAAC;IAC7E,MAAM,CAAC,OAAO,GAAG,KAAK,IAAI,EAAE;QAC1B,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAChB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,sCAAsC,EAAE,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACtG,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,KAAK,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAClB,CAAC,CAAC;IACF,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1B,CAAC"}
+9
View File
@@ -1,6 +1,7 @@
import { copyable, h } from "./dom.js";
import { diagram } from "./mermaid.js";
import { taskStyle } from "./taskcolor.js";
import { todoLink } from "./todolink.js";
type Block = HTMLElement;
@@ -315,6 +316,14 @@ function link(href: string, children: Node[]): Node {
if (task) {
return h("a", { href, class: "task-link", style: taskStyle(task[1]!) }, ...children);
}
const todo = /^#\/todo\/(\w+)\/(.+)$/.exec(href);
if (todo) {
try {
return todoLink(todo[1]!, decodeURIComponent(todo[2]!), children);
} catch {
return h("span", {}, ...children);
}
}
if (href.startsWith("#/")) {
return h("a", { href }, ...children);
}
+4
View File
@@ -5,6 +5,7 @@ import { previewURL } from "./preview.js";
import { findingCount, reviewCounts } from "./reviews.js";
import { currentSession, findTask, focusTab, focusTask, onEach, pinSnapshot, setFocus, showReview, state, type Topic } from "./state.js";
import { taskStyle } from "./taskcolor.js";
import { fillTodoLinks } from "./todolink.js";
export type Usage = { used: number; window: number; model: string };
@@ -380,6 +381,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
stream.timer = 0;
stream.el.hidden = ctx.held !== undefined || quietReply.startsWith(stream.text.trim());
replace(stream.el, markdown(stream.text, "text md", { taskId: ctx.taskId }));
fillTodoLinks(stream.el, models[0]!);
pin();
}, 100);
};
@@ -493,6 +495,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
renderComposer();
}
}
fillTodoLinks(transcript, models[0]!);
pin();
};
@@ -523,6 +526,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
}),
onEach([src.transcriptTopic], (fresh) => appendEvents(fresh as ByreEvent[])),
onEach([src.streamTopic], (ev) => appendDelta(ev as ByreEvent)),
onEach(["tasks", "sessions"], () => fillTodoLinks(transcript, models[0]!)),
];
replace(root, h("div", { class: "transcript-view" }, head, transcript, composer));
+65
View File
@@ -0,0 +1,65 @@
import { post } from "./api.js";
import { errorText, h, replace, showAlert } from "./dom.js";
import { currentSession, focusTask, state } from "./state.js";
import { taskStyle } from "./taskcolor.js";
const starting = new Set<string>();
export function todoLink(projectId: string, title: string, children: Node[]): HTMLElement {
return h("span", { class: "todo-link", data: { project: projectId, title } }, h("span", { class: "todo-title" }, ...children), " ", h("span", { class: "todo-action" }));
}
export function fillTodoLinks(root: HTMLElement, model: string): void {
for (const el of root.querySelectorAll<HTMLElement>(".todo-link")) {
fill(el, model);
}
}
function fill(el: HTMLElement, model: string): void {
const projectId = el.dataset["project"]!;
const title = el.dataset["title"]!;
const action = el.querySelector<HTMLElement>(".todo-action")!;
const titleEl = el.querySelector<HTMLElement>(".todo-title")!;
const task = (state.tasks.get(projectId) ?? []).find((t) => t.status === "active" && t.todo_item === title);
if (task) {
const sess = currentSession(task.id);
el.setAttribute("style", taskStyle(task.id));
titleEl.classList.add("task-name");
replace(
action,
h(
"a",
{
class: "todo-task",
href: `#/task/${task.id}`,
onclick: (e: MouseEvent) => {
e.preventDefault();
focusTask(task.id);
},
},
h("span", { class: `dot ${sess?.state ?? "none"}`, title: sess?.state ?? "no session" }),
sess?.state ?? "no agent",
),
);
return;
}
el.removeAttribute("style");
titleEl.classList.remove("task-name");
const key = `${projectId}\n${title}`;
const busy = starting.has(key);
const button = h("button", { disabled: busy }, busy ? "Starting…" : "Start");
button.onclick = async () => {
starting.add(key);
fill(el, model);
try {
await post("/api/projects/{projectId}/todo/tasks", { path: { projectId }, body: { title, model } });
} catch (err) {
void showAlert(errorText(err));
}
starting.delete(key);
fill(el, model);
};
replace(action, button);
}
+10
View File
@@ -461,6 +461,16 @@ a.task-link {
margin-top: 4px;
}
.todo-link .todo-task {
display: inline-flex;
vertical-align: middle;
}
.todo-link button {
padding: 1px 8px;
vertical-align: middle;
}
.project h2 {
font-size: 13px;
margin: 16px 0 6px;