Add a per-user lead agent and make the right pane task-focused

This commit is contained in:
Ian Gulliver
2026-10-15 09:40:30 -07:00
parent d212590cdc
commit bdd1ae48f0
68 changed files with 3332 additions and 1364 deletions
+26 -8
View File
@@ -1,17 +1,21 @@
import { get, post } from "./api.js";
import { errorText, h, replace, showAlert } from "./dom.js";
import { markdown } from "./markdown.js";
import { openTranscript } from "./panes.js";
import { models } from "./task.js";
import { currentSession, on, onEach, state } from "./state.js";
import { currentSession, findTask, focusTask, on, onEach, state } from "./state.js";
const refreshKinds = new Set(["task.merged", "project.created"]);
export function mountTodo(root) {
const todos = new Map();
const starting = new Set();
let disposed = false;
const project = () => {
const task = state.selectedTaskId ? findTask(state.selectedTaskId) : undefined;
return state.projects.find((p) => p.id === task?.project_id);
};
const render = () => {
const scrollTop = root.querySelector(".todo-view")?.scrollTop ?? 0;
replace(root, h("div", { class: "todo-view" }, ...state.projects.map((p) => projectBlock(p, todos.get(p.id), starting, start))));
const p = project();
replace(root, h("div", { class: "todo-view" }, p ? projectBlock(p, todos.get(p.id), starting, start) : h("div", { class: "empty" }, "No task selected.")));
root.querySelector(".todo-view").scrollTop = scrollTop;
};
const load = async (projectId) => {
@@ -27,7 +31,8 @@ export function mountTodo(root) {
}
};
const refresh = () => {
for (const p of state.projects) {
const p = project();
if (p) {
void load(p.id);
}
};
@@ -37,8 +42,7 @@ export function mountTodo(root) {
render();
try {
const task = await post("/api/projects/{projectId}/todo/tasks", { path: { projectId: project.id }, body: { title: item.title, model: models[0] } });
location.hash = `#/task/${task.id}`;
openTranscript();
focusTask(task.id);
}
catch (err) {
void showAlert(errorText(err));
@@ -64,7 +68,14 @@ export function mountTodo(root) {
}
}),
on("projects", refresh),
onEach(["tasks", "sessions", "selection"], render),
on("selection", () => {
render();
const p = project();
if (p && !todos.has(p.id)) {
void load(p.id);
}
}),
onEach(["tasks", "sessions"], render),
];
render();
refresh();
@@ -106,7 +117,14 @@ function projectBlock(project, todo, starting, start) {
let action;
if (task) {
const sess = currentSession(task.id);
action = h("a", { class: "todo-task", href: `#/task/${task.id}`, onclick: openTranscript }, h("span", { class: `dot ${sess?.state ?? "none"}`, title: sess?.state ?? "no session" }), sess?.state ?? "no agent");
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");
}
else {
const busy = starting.has(`${project.id}\n${item.title}`);