Self-hosted, sharable kanban for humans and agents. One 4.7 MB binary, 5 MB of RAM, 10 to 60 tokens per agent reply, starts in 3 ms, zero setup.
Rust ai-agentsclaude-codeclicodexcoding-agentskanbanlocal-firstmcpmcp-servermodel-context-protocolproductivityproject-managementraspberry-pirustself-hostedsqlitetask-manager
Edit tasks in place, and add tasks in the same panel
emanuele-emf415e45d1799
diff --git a/src/app.js b/src/app.jsindex 6a55bc1..75817bf 100644--- a/src/app.js+++ b/src/app.js@@ -319,7 +319,7 @@ async function deleteProject(p) {if (!confirm(`Delete project ${p.slug}${tasks}? This cannot be undone.`)) return;try {await api("DELETE", `/projects/${encodeURIComponent(p.slug)}`);- if (panelTask?.project === p.slug) closeTask();+ if (panelTask?.project === p.slug) { fresh = null; closeTask(); }if (state.project === p.slug) setProject("all"); else loadBoard();} catch (err) { toast(err.message); }}@@ -348,7 +348,7 @@ function renderColumns() {el("span", { class: "count" })),el("div", { class: "cards" }),);- if (i === 0) col.append(addTaskForm());+ if (i === 0) col.append(el("div", { class: "add" }, el("button", { class: "ghost", onclick: newTask }, "+ Add task")));wireDrop(col, col.querySelector(".cards"), status);return col;}));@@ -373,8 +373,6 @@ function renderColumns() {: null;col.querySelector(".cards").replaceChildren(...[more].filter(Boolean), ...mine.slice(hidden).map((t) => card(t, all)));}- const select = columns.querySelector(".add select");- if (select) fillProjectSelect(select);}// Every word of the search must appear in the task's id, title, description or project.@@ -439,6 +437,7 @@ function wireDrop(col, list, status) {if (dragged) list.insertBefore(dragged, line.parentNode === list ? line : null);line.remove();state.dropped = true;+ if (fresh === id) fresh = null;const before = after ? Number(after.dataset.id) : null;try {await api("POST", `/tasks/${id}/move`, { status, before });@@ -448,52 +447,45 @@ function wireDrop(col, list, status) {});}-function fillProjectSelect(select) {- const { projects } = state.board;- const keep = select.value || localStorageGet("kanzo.newTaskProject");- select.replaceChildren(...projects.map((p) => el("option", { value: p.slug }, p.name)));- if (projects.some((p) => p.slug === keep)) select.value = keep;-}-function localStorageGet(k) {try { return localStorage.getItem(k); } catch { return null; }}-function addTaskForm() {- const wrap = el("div", { class: "add" });- const toggle = el("button", { class: "ghost", onclick: () => { toggle.hidden = true; form.hidden = false; title.focus(); } }, "+ Add task");- const title = el("textarea", { class: "field", placeholder: "Task title", rows: "2" });- const select = state.project === "all" ? el("select", { class: "field", title: "Project" }) : null;- const close = () => { form.hidden = true; toggle.hidden = false; title.value = ""; };- const form = el("form", { hidden: true },- title,- el("div", { class: "row" },- select,- el("button", { class: "btn primary", type: "submit" }, "Add"),- el("button", { class: "btn", type: "button", onclick: close }, "Cancel")));- form.addEventListener("submit", async (e) => {- e.preventDefault();- const text = title.value.trim();- if (!text) return;- const project = select ? select.value : state.project;- if (!project) { toast("Create a project first"); return; }- try {- if (select) try { localStorage.setItem("kanzo.newTaskProject", project); } catch {}- await api("POST", "/tasks", { project, title: text });- title.value = "";- title.focus();- loadBoard();- } catch (err) { toast(err.message); }- });- title.addEventListener("keydown", (e) => {- if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); form.requestSubmit(); }- if (e.key === "Escape") { e.stopPropagation(); close(); }- });- wrap.append(toggle, form);- wrap.open = () => toggle.click();- return wrap;+// ---------- new task ----------++// "+ Add task" creates the task at once and opens it like any other, with its+// title selected to type over. Closed untouched, it is deleted again.+const NEW_TITLE = "New task";+let fresh = null; // id of the task just added, until something in it is saved++async function newTask() {+ const { projects } = state.board;+ if (!projects.length) { toast("Create a project first"); return; }+ const last = localStorageGet("kanzo.newTaskProject");+ const project = state.project !== "all" ? state.project+ : projects.some((p) => p.slug === last) ? last : projects[0].slug;+ try {+ const task = await api("POST", "/tasks", { project, title: NEW_TITLE });+ await openTask(task.id);+ fresh = task.id;+ loadBoard();+ $("#p-title").focus({ preventScroll: true });+ $("#p-title").select();+ } catch (err) { toast(err.message); }}+function dropFresh() {+ if (!fresh) return;+ const id = fresh;+ fresh = null;+ api("DELETE", `/tasks/${id}`).then(loadBoard, () => {});+}++// Leaving the page also counts as closing the task.+window.addEventListener("pagehide", () => {+ if (fresh) fetch(`/api/tasks/${fresh}`, { method: "DELETE", keepalive: true });+});+// ---------- new project ----------function showNewProject() {@@ -522,14 +514,16 @@ $("#new-project").addEventListener("submit", async (e) => {// ---------- task panel ----------+// Every field is editable in place and saves when it loses focus.const panel = $("#panel");let panelTask = null;async function openTask(id) {+ leavePanelField();+ if (fresh !== id) dropFresh();state.task = id;document.querySelectorAll(".card.open").forEach((c) => c.classList.remove("open"));document.querySelector(`.card[data-id="${id}"]`)?.classList.add("open");- closeDescEditor();$("#p-comment").value = "";updateHash();await refreshTask();@@ -538,7 +532,14 @@ async function openTask(id) {panel.setAttribute("aria-hidden", "false");}+// Blurring a field saves it, so do that before the panel lets go of a task.+function leavePanelField() {+ if (panel.contains(document.activeElement)) document.activeElement.blur();+}+function closeTask() {+ leavePanelField();+ dropFresh();state.task = null;panelTask = null;updateHash();@@ -548,21 +549,26 @@ function closeTask() {}async function refreshTask() {- if (!state.task) return;+ const id = state.task;+ if (!id) return;let data;try {- data = await api("GET", `/tasks/${state.task}`);+ data = await api("GET", `/tasks/${id}`);} catch (e) {- if (/no task/.test(e.message)) { toast("That task was deleted"); closeTask(); }+ if (state.task === id && /no task/.test(e.message)) { toast("That task was deleted"); closeTask(); }return;}+ // Another task may have taken the panel meanwhile.+ if (state.task !== id) return;const { task, comments } = data;panelTask = task;$("#p-key").textContent = key(task);$("#p-project").replaceChildren(el("span", { class: "tag" },el("span", { class: "dot", style: `background:${projectColor(task.project)}` }), task.project));- const title = $("#p-title");- if (document.activeElement !== title) { title.value = task.title; fitTitle(); }+ // Never overwrite what is being typed.+ for (const [field, value] of [[$("#p-title"), task.title], [$("#p-desc"), task.description]]) {+ if (document.activeElement !== field) { field.value = value; fit(field); }+ }const status = $("#p-status");const statuses = state.board ? state.board.statuses : [task.status];status.replaceChildren(...statuses.map((s) => el("option", { value: s }, s)));@@ -570,7 +576,6 @@ async function refreshTask() {status.value = task.status;$("#p-created").replaceChildren(timeEl(task.created_at));$("#p-updated").replaceChildren(timeEl(task.updated_at));- if ($("#p-desc-editor").hidden) renderDesc(task.description);$("#p-comment-count").textContent = comments.length ? String(comments.length) : "";$("#p-comments").replaceChildren(...comments.map((c) => {const body = el("div", { class: "md" });@@ -579,20 +584,15 @@ async function refreshTask() {}));}-function renderDesc(text) {- const view = $("#p-desc-view");- if (text) view.innerHTML = markdown(text);- else view.replaceChildren(el("span", { class: "placeholder" }, "No description. Click to add one."));-}--function fitTitle() {- const t = $("#p-title");+// Textareas grow with their text instead of scrolling.+function fit(t) {t.style.height = "auto";t.style.height = t.scrollHeight + "px";}async function patchTask(fields) {if (!panelTask) return;+ if (fresh === panelTask.id) fresh = null;try {await api("PATCH", `/tasks/${panelTask.id}`, fields);await refreshTask();@@ -600,53 +600,49 @@ async function patchTask(fields) {} catch (e) { toast(e.message); refreshTask(); }}+// Escape undoes the field's edit; on a task just added and not saved yet, it drops the task.+function cancelField(e, saved) {+ e.stopPropagation();+ if (fresh && fresh === state.task) { closeTask(); return; }+ e.target.value = saved;+ fit(e.target);+ e.target.blur();+}+$("#p-close").addEventListener("click", closeTask);-$("#p-title").addEventListener("input", fitTitle);+for (const field of [$("#p-title"), $("#p-desc")]) field.addEventListener("input", () => fit(field));++// ⌘↵ in the title or description saves and closes.$("#p-title").addEventListener("keydown", (e) => {- if (e.key === "Enter") { e.preventDefault(); e.target.blur(); }- if (e.key === "Escape") { e.stopPropagation(); e.target.value = panelTask.title; e.target.blur(); }+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); closeTask(); }+ // The title is one line: Enter, like Tab, goes on to the description.+ else if ((e.key === "Enter" || e.key === "Tab") && !e.shiftKey) { e.preventDefault(); $("#p-desc").focus(); }+ else if (e.key === "Escape") cancelField(e, panelTask ? panelTask.title : "");});$("#p-title").addEventListener("blur", (e) => {+ if (!panelTask) return;const v = e.target.value.trim();- if (panelTask && v && v !== panelTask.title) patchTask({ title: v });- else if (panelTask) { e.target.value = panelTask.title; fitTitle(); }+ if (v && v !== panelTask.title) patchTask({ title: v });+ else { e.target.value = panelTask.title; fit(e.target); }});-$("#p-status").addEventListener("change", (e) => patchTask({ status: e.target.value }));--function openDescEditor() {- $("#p-desc").value = panelTask ? panelTask.description : "";- $("#p-desc-view").hidden = true;- $("#p-desc-edit").hidden = true;- $("#p-desc-editor").hidden = false;- $("#p-desc").focus();-}--function closeDescEditor() {- $("#p-desc-editor").hidden = true;- $("#p-desc-view").hidden = false;- $("#p-desc-edit").hidden = false;- if (panelTask) renderDesc(panelTask.description);-}-$("#p-desc-edit").addEventListener("click", openDescEditor);-$("#p-desc-view").addEventListener("click", (e) => { if (!e.target.closest("a")) openDescEditor(); });-$("#p-desc-cancel").addEventListener("click", closeDescEditor);-$("#p-desc-save").addEventListener("click", async () => {- const description = $("#p-desc").value;- closeDescEditor();- await patchTask({ description });-});$("#p-desc").addEventListener("keydown", (e) => {- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); $("#p-desc-save").click(); }- if (e.key === "Escape") { e.stopPropagation(); closeDescEditor(); }+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); closeTask(); }+ else if (e.key === "Escape") cancelField(e, panelTask ? panelTask.description : "");+});+$("#p-desc").addEventListener("blur", (e) => {+ if (panelTask && e.target.value.trim() !== panelTask.description) patchTask({ description: e.target.value });});+$("#p-status").addEventListener("change", (e) => patchTask({ status: e.target.value }));+$("#p-comment-form").addEventListener("submit", async (e) => {e.preventDefault();const body = $("#p-comment").value.trim();if (!body || !panelTask) return;try {await api("POST", `/tasks/${panelTask.id}/comments`, { body });+ if (fresh === panelTask.id) fresh = null;$("#p-comment").value = "";await refreshTask();loadBoard();@@ -661,6 +657,7 @@ $("#p-delete").addEventListener("click", async () => {const extra = panelTask.comments ? ` and its ${panelTask.comments} comment${panelTask.comments > 1 ? "s" : ""}` : "";if (!confirm(`Delete ${key(panelTask)}${extra}? This cannot be undone.`)) return;try {+ if (fresh === panelTask.id) fresh = null;await api("DELETE", `/tasks/${panelTask.id}`);closeTask();loadBoard();@@ -693,8 +690,7 @@ document.addEventListener("keydown", (e) => {$("#search").focus();}if (e.key === "n" && !typing && !e.metaKey && !e.ctrlKey) {- const add = $("#columns .add");- if (add) { e.preventDefault(); add.open(); }+ if ($("#columns .add")) { e.preventDefault(); newTask(); }}});diff --git a/src/index.html b/src/index.htmlindex 2068c5e..33e1544 100644--- a/src/index.html+++ b/src/index.html@@ -136,10 +136,6 @@ header .sub a { color: inherit; }.tag .dot { width: 6px; height: 6px; }.drop-line { height: 2px; background: var(--drop); border-radius: 2px; margin: -4px 2px; }.add { padding: 0 8px 8px; }-.add form { display: flex; flex-direction: column; gap: 6px; }-.add textarea { resize: none; min-height: 54px; }-.add .row { display: flex; gap: 6px; align-items: center; }-.add .row select { flex: 1; min-width: 0; }.empty {margin: auto; text-align: center; color: var(--muted); max-width: 360px; padding: 40px 20px;}@@ -159,12 +155,16 @@ header .sub a { color: inherit; }.panel .body { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; flex: 1; }/* The body scrolls instead; without this a long task squeezes the title and textareas to nothing. */.panel .body > * { flex-shrink: 0; }-.panel .title-input {- font-size: 18px; font-weight: 650; border: 1px solid transparent; background: none; padding: 4px 6px;- margin: -4px -6px; border-radius: 6px; width: calc(100% + 12px); resize: none; overflow: hidden; outline: none;+/* Title and description look like text and are edited in place. */+.panel .inline {+ border: 1px solid transparent; background: none; padding: 4px 6px; margin: -4px -6px; border-radius: 6px;+ width: calc(100% + 12px); resize: none; overflow: hidden; outline: none; display: block;}-.panel .title-input:hover { border-color: var(--border); }-.panel .title-input:focus { border-color: var(--accent); background: var(--card); }+.panel .inline:hover { border-color: var(--border); }+.panel .inline:focus { border-color: var(--accent); background: var(--card); }+.panel .inline::placeholder { color: var(--faint); }+.panel .title-input { font-size: 18px; font-weight: 650; }+.panel .desc-input { min-height: 3.2em; }.props { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; align-items: center; color: var(--muted); }.props select { width: auto; padding: 3px 6px; }.props span { color: var(--text); }@@ -172,11 +172,6 @@ header .sub a { color: inherit; }font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px;display: flex; align-items: center; gap: 8px; font-weight: 600;}-.section h3 .ghost { width: auto; padding: 0 6px; font-size: 12px; text-transform: none; letter-spacing: 0; }-.desc textarea { min-height: 200px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }-.desc .actions { display: flex; gap: 6px; margin-top: 6px; }-.desc .view { cursor: text; border-radius: 6px; padding: 2px 0; min-height: 24px; }-.desc .placeholder { color: var(--faint); }.comment { border-top: 1px solid var(--border); padding: 10px 0; }.comment:first-child { border-top: 0; padding-top: 0; }.comment .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }@@ -256,22 +251,15 @@ header .sub a { color: inherit; }<button class="ghost" style="width:auto" id="p-close" title="Close (Esc)">✕</button></div><div class="body">- <textarea class="title-input" id="p-title" rows="1" spellcheck="false"></textarea>+ <textarea class="inline title-input" id="p-title" rows="1" spellcheck="false" placeholder="Task title"></textarea><div class="props">Status <span><select class="field" id="p-status"></select></span>Created <span id="p-created"></span>Updated <span id="p-updated"></span></div>- <div class="section desc">- <h3>Description <button class="ghost" id="p-desc-edit">Edit</button></h3>- <div class="view md" id="p-desc-view" title="Click to edit"></div>- <div id="p-desc-editor" hidden>- <textarea class="field" id="p-desc" placeholder="Markdown"></textarea>- <div class="actions">- <button class="btn primary" id="p-desc-save">Save</button>- <button class="btn" id="p-desc-cancel">Cancel</button>- </div>- </div>+ <div class="section">+ <h3>Description</h3>+ <textarea class="inline desc-input" id="p-desc" rows="2" placeholder="Add a description (Markdown)"></textarea></div><div class="section"><h3>Comments <span class="count" id="p-comment-count"></span></h3>