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
+16 -9
View File
@@ -1,8 +1,8 @@
import { get, put, subscribe } from "./api.js";
import { errorText, h, replace, showAlert } from "./dom.js";
import { mountNavbar } from "./navbar.js";
import { Pane } from "./panes.js";
import { handleEvent, loadInbox, loadMe, loadProjects, notify, on, selectTask, state } from "./state.js";
import { leadPane, taskPane } from "./panes.js";
import { handleEvent, loadFocus, loadInbox, loadLeadSessions, loadMe, loadProjects, notify, on, selectTask, setFocus, startLeadStream, state } from "./state.js";
function identityBanner(root) {
const render = () => {
const me = state.me;
@@ -33,6 +33,9 @@ function identityBanner(root) {
function route() {
const match = /^#\/task\/(\w+)$/.exec(location.hash);
const taskId = match?.[1];
if (taskId !== state.focus.task_id) {
setFocus({ task_id: taskId ?? null }).catch((err) => console.error("set focus", err));
}
if (taskId !== state.selectedTaskId) {
selectTask(taskId);
}
@@ -40,10 +43,16 @@ function route() {
async function main() {
const navbar = h("header", { class: "navbar" });
const banner = h("div", { class: "banner", hidden: true });
const left = new Pane("left", "transcript");
const right = new Pane("right", "inbox");
replace(document.body, navbar, banner, h("div", { class: "panes" }, left.el, right.el));
mountNavbar(navbar, (view) => right.show(view));
const status = await get("/api/admin/status");
await Promise.all([loadMe(), loadProjects(), loadInbox(), loadLeadSessions()]);
const linked = location.hash;
await loadFocus();
if (/^#\/task\/\w+$/.test(linked)) {
location.hash = linked;
}
startLeadStream();
replace(document.body, navbar, banner, h("div", { class: "panes" }, leadPane(), taskPane()));
mountNavbar(navbar);
identityBanner(banner);
addEventListener("keydown", (e) => {
if (e.key !== "Escape") {
@@ -52,9 +61,7 @@ async function main() {
e.preventDefault();
document.querySelector("dialog[open]")?.close();
}, { capture: true });
const status = await get("/api/admin/status");
await Promise.all([loadMe(), loadProjects(), loadInbox()]);
subscribe(status.last_event_seq, undefined, handleEvent, (connected) => {
subscribe(status.last_event_seq, {}, handleEvent, (connected) => {
state.connected = connected;
notify("connection");
});