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
Filter the board with search's match, and find words in comments too
emanuele-em6113bad4d822
diff --git a/src/app.js b/src/app.jsindex 8e74f1a..038bc65 100644--- a/src/app.js+++ b/src/app.js@@ -285,7 +285,9 @@ async function loadBoard() {// 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 = state.allDone ? "&done=all" : "";- const board = await api("GET", "/board?project=" + encodeURIComponent(state.project) + done);+ const q = $("#filter").value.trim();+ const board = await api("GET", "/board?project=" + encodeURIComponent(state.project) + done+ + (q ? "&q=" + encodeURIComponent(q) : ""));if (request !== boardRequest) return;state.board = board;state.changes = board.changes;@@ -548,11 +550,11 @@ function renderColumns() {if (state.dragging) return;const all = state.project === "all";const humanOnly = isHumanOnly();- const words = filterWords();+ const words = wordsOf($("#filter").value);$("#filter").classList.toggle("on", words.length > 0);for (const status of statuses) {const col = columns.querySelector(`[data-status="${CSS.escape(status)}"]`);- const mine = tasks.filter((t) => t.status === status && (!humanOnly || t.human) && matchesFilter(t, words));+ const mine = tasks.filter((t) => t.status === status && (!humanOnly || t.human));// Older done tasks the server left out (see loadBoard).const last = status === statuses[statuses.length - 1];const hidden = last && !state.allDone ? state.board.done_hidden || 0 : 0;@@ -564,20 +566,21 @@ function renderColumns() {? el("button", { class: "ghost more", onclick: () => { state.allDone = true; loadBoard(); } },filtered ? "Show older" : `Show ${hidden} older`): null;- col.querySelector(".cards").replaceChildren(...[more].filter(Boolean), ...mine.map((t) => card(t, all)));+ col.querySelector(".cards").replaceChildren(...[more].filter(Boolean), ...mine.map((t) => card(t, all, words)));}}-// The filter box keeps on the board only the tasks that hold every word typed, in their key,-// title, description or tags: the same match as search, but the board stays a board.-function filterWords() {- return $("#filter").value.toLowerCase().split(/\s+/).filter(Boolean);+// The filter box keeps on the board only the tasks search finds (see loadBoard): search+// shows one to open, the filter all of them in their columns.+function wordsOf(query) {+ return query.toLowerCase().split(/\s+/).filter(Boolean);}-function matchesFilter(t, words) {- if (!words.length) return true;- const text = `${t.project}#${t.id} ${t.title} ${t.description || ""} ${t.tags.join(" ")}`.toLowerCase();- return words.every((w) => text.includes(w));+// The text with each of the words found in it marked, for search and the filter.+function marked(text, words) {+ if (!words.length) return text;+ const re = new RegExp(`(${words.map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})`, "i");+ return text.split(re).map((part, i) => (i % 2 ? el("mark", {}, part) : part));}// The board can show only human tasks; off at first, and each browser remembers the choice.@@ -632,17 +635,17 @@ function plainText(md) {.trim();}-function card(t, showProject) {+function card(t, showProject, words = []) {const node = el("div", { class: "card" + (state.task === t.id ? " open" : ""), draggable: "true", "data-id": t.id,onclick: () => openTask(t.id) },el("div", { class: "head" },- el("div", { class: "title" }, t.title),+ el("div", { class: "title" }, marked(t.title, words)),// On "All projects" a dot in the project's colour tells the projects apart.t.human ? el("span", { class: "human-mark", title: "Human task: agents skip it" }, icon("human")) : null,el("span", { class: "num", title: `Copy ${key(t)}`, onclick: (e) => { e.stopPropagation(); copyKey(key(t)); } },showProject ? el("span", { class: "dot", style: `background:${projectColor(t.project)}` }) : null, `#${t.id}`)),- t.description ? el("div", { class: "desc" }, plainText(t.description)) : null,- t.tags.length ? el("div", { class: "tags" }, t.tags.map((tag) => el("span", { class: "tag" }, tag))) : null);+ t.description ? el("div", { class: "desc" }, marked(plainText(t.description), words)) : null,+ t.tags.length ? el("div", { class: "tags" }, t.tags.map((tag) => el("span", { class: "tag" }, marked(tag, words)))) : null);node.addEventListener("dragstart", (e) => {state.dragging = t.id;e.dataTransfer.effectAllowed = "move";@@ -750,9 +753,10 @@ function hideNewProject() {$("#new-task").addEventListener("click", newTask);$("#human-only").addEventListener("click", () => setHumanOnly(!isHumanOnly()));-$("#filter").addEventListener("input", render);+let filterTimer;+$("#filter").addEventListener("input", () => { clearTimeout(filterTimer); filterTimer = setTimeout(loadBoard, 120); });$("#filter").addEventListener("keydown", (e) => {- if (e.key === "Escape") { e.stopPropagation(); $("#filter").value = ""; render(); $("#filter").blur(); }+ if (e.key === "Escape") { e.stopPropagation(); $("#filter").value = ""; loadBoard(); $("#filter").blur(); }});$("#new-project-toggle").addEventListener("click", showNewProject);$("#new-project-cancel").addEventListener("click", hideNewProject);@@ -1107,7 +1111,7 @@ async function runSearch() {...results.map((t, i) => el("button", { type: "button", class: "result" + (i === 0 ? " selected" : ""),onmousemove: () => select(i), onclick: () => pick(t) },el("span", { class: "dot", style: `background:${projectColor(t.project)}` }),- el("span", { class: "title" }, t.title),+ el("span", { class: "title" }, marked(t.title, wordsOf(q))),el("span", { class: "meta" }, el("span", { class: "mono" }, key(t)), t.status))),...(results.length ? [] : [el("div", { class: "note" }, q ? "No tasks match." : "No tasks yet.")]));} catch (err) { toast(err.message); }diff --git a/src/index.html b/src/index.htmlindex 16fb669..7e0f16b 100644--- a/src/index.html+++ b/src/index.html@@ -154,13 +154,15 @@ header .repo-link .icon svg { width: 14px; height: 14px; }}#new-task { display: inline-flex; align-items: center; gap: 6px; padding-left: 12px; }#new-task .icon svg { width: 16px; height: 16px; }-/* Filter: the board keeps only the tasks whose key, title, description or tags hold every word typed. */+/* Filter: the board keeps only the tasks search finds. */#filter {width: 180px; height: 35px; padding: 0 14px; border: 1px solid var(--border); border-radius: 99px;background: transparent; color: var(--text); font: inherit; font-size: 13px; outline: none;}#filter:focus { border-color: var(--link); }#filter.on { border-color: var(--link); background: color-mix(in srgb, var(--link) 8%, transparent); }+/* The words search or the filter found. */+mark { background: color-mix(in srgb, var(--link) 25%, transparent); color: inherit; border-radius: 3px; }/* Show only human tasks: a small icon, coloured while the filter is on. */#human-only { color: var(--muted); }#human-only:hover, #human-only:focus-visible { color: var(--text); }diff --git a/src/store.rs b/src/store.rsindex d171f87..d59d2b5 100644--- a/src/store.rs+++ b/src/store.rs@@ -535,19 +535,21 @@ impl Store {Ok((tasks, hidden))}- /// Tasks of any project whose key, title, description, tags or project hold every- /// word of `query`: open ones first, then the most recently changed. An empty query- /// gives the most recently changed tasks.- pub fn search(&self, query: &str, limit: usize) -> Result<Vec<Task>> {+ /// Tasks of any project whose key, title, description, tags, project or comments hold+ /// every word of `query`: open ones first, then the most recently changed. An empty+ /// query gives the most recently changed tasks. The board's filter uses it too.+ pub fn search(&self, query: &str, limit: Option<usize>) -> Result<Vec<Task>> {let words: Vec<String> = query.split_whitespace().take(10).map(|w| w.to_lowercase()).collect();let mut sql = format!("{} WHERE 1", Self::TASK_SELECT);for i in 0..words.len() {sql.push_str(&format!(- " AND lower(p.slug || '#' || t.id || ' ' || t.title || ' ' || t.description || ' ' || t.tags) \- LIKE ?{} ESCAPE '\\'",- i + 2+ " AND (lower(p.slug || '#' || t.id || ' ' || t.title || ' ' || t.description || ' ' || t.tags) \+ LIKE ?{n} ESCAPE '\\' OR t.id IN (SELECT task_id FROM comments WHERE lower(body) LIKE ?{n} ESCAPE '\\'))",+ n = i + 2));}+ // SQLite reads a negative LIMIT as no limit.+ let limit = limit.map_or(-1, |n| n as i64);sql.push_str(&format!(" ORDER BY t.status = ?1, t.updated_at DESC, t.id DESC LIMIT {limit}"));let mut values: Vec<String> = vec![self.done_status().to_string()];for w in &words {@@ -1119,15 +1121,17 @@ mod tests {s.update_task(old.id, TaskPatch { status: Some("done".into()), ..Default::default() }).unwrap();let other = s.create_task(web.id, "Pricing 100%", "").unwrap();s.update_task(other.id, TaskPatch { tags: Some("ui".into()), ..Default::default() }).unwrap();- let titles = |q: &str| s.search(q, 10).unwrap().into_iter().map(|t| t.title).collect::<Vec<_>>();+ let titles = |q: &str| s.search(q, Some(10)).unwrap().into_iter().map(|t| t.title).collect::<Vec<_>>();assert_eq!(titles("LOGIN"), ["Fix login", "Login page copy"], "any project, open first, done too");assert_eq!(titles("login api"), ["Fix login"], "every word must match, the project too");assert_eq!(titles(&format!("web#{}", other.id)), ["Pricing 100%"], "by key");assert_eq!(titles("ui"), ["Pricing 100%"], "by tag");+ s.add_comment(old.id, "you", "Needs the new logo", &[]).unwrap();+ assert_eq!(titles("logo login"), ["Login page copy"], "by comment, with the task's own words");assert_eq!(titles("100%"), ["Pricing 100%"], "% is a plain character");assert!(titles("nothing-like-this").is_empty());- assert_eq!(s.search("", 10).unwrap().len(), 3, "no words: the latest changes");- assert_eq!(s.search("login", 1).unwrap()[0].id, login.id);+ assert_eq!(s.search("", Some(10)).unwrap().len(), 3, "no words: the latest changes");+ assert_eq!(s.search("login", Some(1)).unwrap()[0].id, login.id);}#[test]diff --git a/src/web.rs b/src/web.rsindex b94a668..000f238 100644--- a/src/web.rs+++ b/src/web.rs@@ -1,6 +1,6 @@//! `kanzo`: the board page, the small JSON API behind it, and MCP over HTTP at `/mcp`.-use std::collections::HashMap;+use std::collections::{HashMap, HashSet};use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};use std::sync::{Arc, Mutex, OnceLock};use std::time::{Duration, Instant};@@ -417,6 +417,9 @@ struct BoardQuery {project: Option<String>,/// "all" for every done task.done: Option<String>,+ /// The filter: only the tasks that search finds.+ #[serde(default)]+ q: String,}/// The whole board, serialized straight from the store's rows.@@ -437,7 +440,11 @@ async fn board(State(home): Shared, Query(q): Query<BoardQuery>) -> Response {None => None,};let keep_done = (q.done.as_deref() != Some("all")).then_some(DONE_SHOWN);- let (tasks, done_hidden) = s.list_tasks_keeping_done(project.map(|p| p.id), None, keep_done)?;+ let (mut tasks, done_hidden) = s.list_tasks_keeping_done(project.map(|p| p.id), None, keep_done)?;+ if !q.q.trim().is_empty() {+ let found: HashSet<i64> = s.search(&q.q, None)?.into_iter().map(|t| t.id).collect();+ tasks.retain(|t| found.contains(&t.id));+ }Ok(Board {changes: change_token(h, s)?,done_hidden,@@ -458,7 +465,7 @@ struct SearchQuery {/// Tasks of every project matching the search, for the search window.async fn search(State(home): Shared, Query(q): Query<SearchQuery>) -> Response {- with_store(home, move |_, s| s.search(&q.q, 30)).await+ with_store(home, move |_, s| s.search(&q.q, Some(30))).await}#[derive(Deserialize)]