Let task links open a tab, and link the lead to inboxes for review

This commit is contained in:
Ian Gulliver
2026-10-15 18:55:38 -07:00
parent 5a07658523
commit 805f6091bf
8 changed files with 18 additions and 16 deletions
+6 -5
View File
@@ -2,7 +2,7 @@ import { get, put, subscribe } from "./api.js";
import { errorText, h, replace, showAlert } from "./dom.js";
import { mountNavbar } from "./navbar.js";
import { leadPane, taskPane } from "./panes.js";
import { handleEvent, loadFocus, loadInbox, loadLeadSessions, loadMe, loadProjects, notify, on, selectTask, setFocus, startLeadStream, state } from "./state.js";
import { handleEvent, loadFocus, loadInbox, loadLeadSessions, loadMe, loadProjects, notify, on, selectTask, setFocus, startLeadStream, state, tabs } from "./state.js";
function identityBanner(root: HTMLElement): void {
const render = () => {
@@ -32,12 +32,13 @@ function identityBanner(root: HTMLElement): void {
}
function route(): void {
const match = /^#\/(task|project)\/(\w+)$/.exec(location.hash);
const match = /^#\/(task|project)\/(\w+)(?:\/(\w+))?$/.exec(location.hash);
const taskId = match?.[1] === "task" ? match[2] : undefined;
const projectId = match?.[1] === "project" ? match[2] : undefined;
const tab = tabs.find((t) => t === match?.[3]);
if (taskId) {
if (taskId !== state.focus.task_id) {
setFocus({ task_id: taskId }).catch((err: unknown) => console.error("set focus", err));
if (taskId !== state.focus.task_id || (tab && tab !== state.focus.tab)) {
setFocus({ task_id: taskId, tab }).catch((err: unknown) => console.error("set focus", err));
}
} else if (state.focus.task_id || projectId !== state.focus.project_id) {
setFocus({ task_id: null, project_id: projectId ?? null }).catch((err: unknown) => console.error("set focus", err));
@@ -55,7 +56,7 @@ async function main(): Promise<void> {
await Promise.all([loadMe(), loadProjects(), loadInbox(), loadLeadSessions()]);
const linked = location.hash;
await loadFocus();
if (/^#\/(task|project)\/\w+$/.test(linked)) {
if (/^#\/(task|project)\/\w+(\/\w+)?$/.test(linked)) {
location.hash = linked;
}
startLeadStream();
+1 -1
View File
@@ -311,7 +311,7 @@ function link(href: string, children: Node[]): Node {
if (/^https?:\/\//i.test(href)) {
return h("a", { href, target: "_blank", rel: "noopener noreferrer" }, ...children);
}
const task = /^#\/task\/(\w+)$/.exec(href);
const task = /^#\/task\/(\w+)(\/\w+)?$/.exec(href);
if (task) {
return h("a", { href, class: "task-link", style: taskStyle(task[1]!) }, ...children);
}