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
Send the board only the newest 50 done tasks
emanuele-emc66ce27d0aa7
diff --git a/src/app.js b/src/app.jsindex d3f62c0..efe23b2 100644--- a/src/app.js+++ b/src/app.js@@ -16,7 +16,6 @@ if (!HTMLFormElement.prototype.requestSubmit) {}const $ = (sel, root = document) => root.querySelector(sel);-const DONE_SHOWN = 50;const STATUS_COLORS = ["#8a8a83", "#3b82f6", "#e8a317", "#2f9e44", "#ae3ec9", "#e8590c"];const state = {@@ -224,7 +223,10 @@ let boardRequest = 0;async function loadBoard() {const request = ++boardRequest;try {- const board = await api("GET", "/board?project=" + encodeURIComponent(state.project));+ // The server leaves out older done tasks unless asked: the board does not show+ // them, and the done column only grows. Search needs them all.+ const done = fullDone() ? "&done=all" : "";+ const board = await api("GET", "/board?project=" + encodeURIComponent(state.project) + done);if (request !== boardRequest) return;state.board = board;state.changes = board.changes;@@ -240,6 +242,10 @@ async function loadBoard() {}}+function fullDone() {+ return state.allDone || state.query.trim() !== "";+}+// The address is #project or #project/task-id, so a task can be linked to.function updateHash() {const hash = "#" + state.project + (state.task ? "/" + state.task : "");@@ -357,7 +363,7 @@ function renderHeader() {if (!projects.length) { header.replaceChildren(); return; }if (!p) {header.replaceChildren(el("h1", {}, "All projects"),- el("span", { class: "sub" }, `${tasks.length} tasks across ${projects.length} projects`));+ el("span", { class: "sub" }, `${projects.reduce((n, p) => n + p.total, 0)} tasks across ${projects.length} projects`));return;}header.replaceChildren(@@ -416,15 +422,15 @@ function renderColumns() {for (const status of statuses) {const col = columns.querySelector(`[data-status="${CSS.escape(status)}"]`);const mine = shown.filter((t) => t.status === status);- col.querySelector("h2 .count").textContent = mine.length ? String(mine.length) : "";- // The done column only grows; draw its newest cards (at the bottom) unless asked,- // so a long-lived board stays quick on old machines.+ // Older done tasks the server left out (see loadBoard).const last = status === statuses[statuses.length - 1];- const hidden = last && !state.allDone && !state.query.trim() ? Math.max(0, mine.length - DONE_SHOWN) : 0;+ const hidden = last && !fullDone() ? state.board.done_hidden || 0 : 0;+ const count = mine.length + hidden;+ col.querySelector("h2 .count").textContent = count ? String(count) : "";const more = hidden- ? el("button", { class: "ghost more", onclick: () => { state.allDone = true; renderColumns(); } }, `Show ${hidden} older`)+ ? el("button", { class: "ghost more", onclick: () => { state.allDone = true; loadBoard(); } }, `Show ${hidden} older`): null;- col.querySelector(".cards").replaceChildren(...[more].filter(Boolean), ...mine.slice(hidden).map((t) => card(t, all)));+ col.querySelector(".cards").replaceChildren(...[more].filter(Boolean), ...mine.map((t) => card(t, all)));}}@@ -762,8 +768,11 @@ $("#p-delete").addEventListener("click", async () => {// ---------- search ----------$("#search").addEventListener("input", (e) => {+ const wasFull = fullDone();state.query = e.target.value;- if (state.board) renderColumns();+ // Searching needs every done task; load them when a search starts.+ if (fullDone() !== wasFull) loadBoard();+ else if (state.board) renderColumns();});$("#search").addEventListener("keydown", (e) => {if (e.key === "Escape") {diff --git a/src/web.rs b/src/web.rsindex 1b87828..749c7bc 100644--- a/src/web.rs+++ b/src/web.rs@@ -245,9 +245,15 @@ async fn changes(State(home): Shared) -> Response {with_store(home, |h, s| Ok(json!({ "changes": change_token(h, s)? }))).await}+/// Done tasks the board gets unless it asks for all: the newest, which are all it shows.+/// The done column only grows, and every change reloads the board.+const DONE_SHOWN: usize = 50;+#[derive(Deserialize)]struct BoardQuery {project: Option<String>,+ /// "all" for every done task.+ done: Option<String>,}async fn board(State(home): Shared, Query(q): Query<BoardQuery>) -> Response {@@ -256,10 +262,24 @@ async fn board(State(home): Shared, Query(q): Query<BoardQuery>) -> Response {Some(slug) => Some(s.find_project(slug)?),None => None,};+ let mut tasks = s.list_tasks(project.map(|p| p.id), None)?;+ let done = s.statuses().last().expect("config has at least two statuses");+ let mut done_hidden = 0;+ if q.done.as_deref() != Some("all") {+ // Done tasks run oldest to newest; drop the oldest.+ done_hidden = tasks.iter().filter(|t| t.status == *done).count().saturating_sub(DONE_SHOWN);+ let mut drop = done_hidden;+ tasks.retain(|t| {+ let old = drop > 0 && t.status == *done;+ drop -= usize::from(old);+ !old+ });+ }Ok(json!({"statuses": s.statuses(),"projects": s.list_projects()?,- "tasks": s.list_tasks(project.map(|p| p.id), None)?,+ "tasks": tasks,+ "done_hidden": done_hidden,"changes": change_token(h, s)?,}))})