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
Reorder projects by dragging them in the sidebar
emanuele-em192bbfd509e9
diff --git a/README.md b/README.mdindex a253794..92b63ee 100644--- a/README.md+++ b/README.md@@ -62,7 +62,7 @@ The board opens at http://localhost:4242. That's all the setup there is: the fir`n` adds a task, `/` or `⌘K` searches every project, `⌘`-click or a drag on empty board space selects tasks to move, tag or delete together, `f` filters the board and `↵` keeps the filter, `Tab` moves to the description, `⌘↵` saves and closes. `Esc` leaves a description or tags with what you typed saved, and cancels other fields. In Chrome or Edge, **Install app** at the bottom of the sidebar makes the board an app of its own; on macOS `kanzo` then opens it instead of a tab, on the default port. In the app, `⌘1`–`⌘8` pick a project, `⌘9` the last one and `⌘0` all of them.-Drag the left edge of a task's panel to resize it, or expand it to the whole window; double-click the edge to reset it. **Fold** at the bottom of the sidebar leaves only its icons.+Drag the left edge of a task's panel to resize it, or expand it to the whole window; double-click the edge to reset it. **Fold** at the bottom of the sidebar leaves only its icons. Drag a project there to reorder the list, for everyone on a shared board.Mark a task Human and agents leave it to you; the person icon shows only those. Paste or drop an image into a task or a comment to attach it. Give a task a URL, like its pull request on any site, and click the link on its card to open it; agents set it with `url`. A link to a file in a description or comment, `[name](file:///path)`, opens in your editor. When a new version is out, the sidebar offers it: one click installs it.diff --git a/src/app.js b/src/app.jsindex cdf9f39..d68bce3 100644--- a/src/app.js+++ b/src/app.js@@ -335,17 +335,19 @@ function render() {function renderNav() {// Redrawing would take the field away from someone renaming a project.if (renaming && document.contains(renaming.input)) return;+ // Nor while dragging a project: it would cancel the drag.+ if (movingProject) return;const { projects } = state.board;const open = projects.reduce((n, p) => n + p.open, 0);const link = (slug, name, count, glyph) =>- el("a", { href: "#" + slug, title: name, class: state.project === slug ? "active" : null,+ el("a", { href: "#" + slug, title: name, draggable: "false", class: state.project === slug ? "active" : null,onclick: (e) => { e.preventDefault(); setProject(slug); } },glyph,el("span", { class: "name" }, name),el("span", { class: "count" }, String(count)));const item = (p) => renaming && renaming.slug === p.slug? el("div", { class: "item renaming" }, icon("folder", projectColor(p.slug)), renaming.input)- : el("div", { class: "item" + (state.menu === p.slug ? " menu-open" : "") },+ : el("div", { class: "item" + (state.menu === p.slug ? " menu-open" : ""), draggable: "true", "data-slug": p.slug },link(p.slug, p.name, p.open, icon("folder", projectColor(p.slug))),el("button", { class: "more", title: "More", "aria-label": `More for ${p.name}`, "aria-haspopup": "menu",onclick: (e) => toggleProjectMenu(p, e.currentTarget) }, icon("more")));@@ -400,6 +402,36 @@ function toggleProjectMenu(p, button) {}let renaming = null;+let movingProject = null;+const projectLine = el("div", { class: "drop-line" });+const projectAfter = (y) => [...$("#nav").querySelectorAll("[data-slug]")]+ .find((i) => { const r = i.getBoundingClientRect(); return y < r.top + r.height / 2; }) || null;++$("#nav").addEventListener("dragstart", (e) => {+ // Or it's text dragged out of the field renaming a project.+ movingProject = e.target.dataset?.slug;+ if (!movingProject) return;+ e.dataTransfer.effectAllowed = "move";+ e.dataTransfer.setData("text/plain", movingProject);+});+$("#nav").addEventListener("dragover", (e) => {+ if (!movingProject) return;+ e.preventDefault();+ $("#nav").insertBefore(projectLine, projectAfter(e.clientY));+});+$("#nav").addEventListener("dragleave", (e) => { if (!$("#nav").contains(e.relatedTarget)) projectLine.remove(); });+$("#nav").addEventListener("drop", async (e) => {+ if (!movingProject) return;+ e.preventDefault();+ const before = projectAfter(e.clientY)?.dataset.slug || null;+ try { await api("POST", `/projects/${encodeURIComponent(movingProject)}/move`, { before }); } catch (err) { toast(err.message); }+ loadBoard();+});+$("#nav").addEventListener("dragend", () => {+ movingProject = null;+ projectLine.remove();+ renderNav();+});function startRename(p) {closeMenu();diff --git a/src/store.rs b/src/store.rsindex 5b9f580..8288193 100644--- a/src/store.rs+++ b/src/store.rs@@ -52,6 +52,7 @@ const MIGRATIONS: &[&str] = &[CREATE INDEX task_waits_by_blocker ON task_waits(waits_on_id);CREATE TRIGGER task_waits_insert AFTER INSERT ON task_waits BEGIN UPDATE meta SET value = value + 1 WHERE key = 'changes'; END;CREATE TRIGGER task_waits_delete AFTER DELETE ON task_waits BEGIN UPDATE meta SET value = value + 1 WHERE key = 'changes'; END;",+ "ALTER TABLE projects ADD COLUMN position REAL;",];const PROJECT_COLORS: &[&str] = &["gray", "red", "orange", "yellow", "green", "teal", "blue", "purple", "pink"];@@ -347,7 +348,7 @@ impl Store {}pub fn list_projects(&self) -> Result<Vec<Project>> {- let sql = format!("{} ORDER BY p.slug", Self::PROJECT_SELECT);+ let sql = format!("{} ORDER BY p.position IS NULL, p.position, p.slug", Self::PROJECT_SELECT);let mut stmt = self.conn.prepare(&sql)?;let rows = stmt.query_map([DONE], Self::project_row)?;Ok(rows.collect::<rusqlite::Result<_>>()?)@@ -471,6 +472,41 @@ impl Store {self.find_project(&project.slug)}+ /// Before `before`, or last. A project never moved has no position and comes after those that+ /// have one, by slug, so only a move that lands among those has to number them all.+ pub fn move_project(&self, slug: &str, before: Option<&str>) -> Result<Project> {+ let project = self.find_project(slug)?;+ let before = before.map(|b| self.find_project(b)).transpose()?;+ if before.as_ref().is_some_and(|b| b.id == project.id) {+ return Ok(project);+ }+ self.write(|c| {+ let mut others: Vec<(i64, Option<f64>)> = c+ .prepare("SELECT id, position FROM projects WHERE id <> ?1 ORDER BY position IS NULL, position, slug")?+ .query_map([project.id], |r| Ok((r.get(0)?, r.get(1)?)))?+ .collect::<rusqlite::Result<_>>()?;+ let at = before.and_then(|b| others.iter().position(|o| o.0 == b.id)).unwrap_or(others.len());+ let position = match (at.checked_sub(1).map(|i| others[i].1), others.get(at).map(|o| o.1)) {+ (None, Some(Some(next))) => Some(next - 1.0),+ (None, _) => Some(1.0),+ (Some(Some(prev)), Some(Some(next))) if next - prev >= 1e-9 => Some((prev + next) / 2.0),+ (Some(Some(prev)), Some(None) | None) => Some(prev + 1.0),+ _ => None,+ };+ let mut update = c.prepare("UPDATE projects SET position = ?1 WHERE id = ?2")?;+ if let Some(position) = position {+ update.execute(params![position, project.id])?;+ } else {+ others.insert(at, (project.id, None));+ for (i, (id, _)) in others.iter().enumerate() {+ update.execute(params![(i + 1) as f64, id])?;+ }+ }+ Ok(())+ })?;+ self.find_project(&project.slug)+ }+pub fn delete_project(&self, slug: &str) -> Result<Project> {let project = self.find_project(slug)?;// Tasks and comments go with it through ON DELETE CASCADE.@@ -1452,6 +1488,45 @@ mod tests {assert_eq!(titles(&s.list_tasks(None, None).unwrap()), ["c"]);}+ #[test]+ fn projects_keep_the_order_they_are_moved_to() {+ let (_dir, s) = store();+ for slug in ["a", "b", "c", "d"] {+ s.create_project(slug, "", None).unwrap();+ }+ let order = || s.list_projects().unwrap().into_iter().map(|p| p.slug).collect::<Vec<_>>().join("");+ let move_to = |slug, before| s.move_project(slug, before).unwrap();+ assert_eq!(order(), "abcd", "never moved: by slug");++ move_to("c", Some("a"));+ assert_eq!(order(), "cabd", "first");+ let positioned: i64 = s.conn.query_row("SELECT count(position) FROM projects", [], |r| r.get(0)).unwrap();+ assert_eq!(positioned, 1, "only the moved project needed a position");++ move_to("d", Some("b"));+ assert_eq!(order(), "cadb", "among projects with no position");+ move_to("c", None);+ assert_eq!(order(), "adbc", "last");+ move_to("b", Some("d"));+ assert_eq!(order(), "abdc", "between two");+ move_to("b", Some("b"));+ assert_eq!(order(), "abdc", "onto itself");++ s.create_project("0new", "", None).unwrap();+ assert_eq!(order(), "abdc0new", "a new project goes last");+ move_to("0new", Some("b"));+ assert_eq!(order(), "a0newbdc");++ for _ in 0..80 {+ // Out of float room between two neighbours: numbers them again.+ move_to("c", Some("b"));+ move_to("d", Some("b"));+ }+ assert_eq!(order(), "a0newcdb");+ assert!(s.move_project("a", Some("nope")).is_err());+ assert!(s.move_project("nope", None).is_err());+ }+#[test]fn keeps_only_the_newest_done_tasks() {let (_dir, s) = store();diff --git a/src/web.rs b/src/web.rsindex 4187ca6..ff9e2ab 100644--- a/src/web.rs+++ b/src/web.rs@@ -159,6 +159,7 @@ fn router(home: Home, guard: Arc<Guard>, shutdown: CancellationToken) -> Router.route("/api/projects", post(create_project)).route("/api/projects/{slug}", patch(update_project).delete(delete_project)).route("/api/projects/{slug}/repos", post(link_repo).delete(unlink_repo))+ .route("/api/projects/{slug}/move", post(move_project)).route("/api/tasks", post(create_task)).route("/api/tasks/bulk", post(bulk_tasks)).route("/api/tasks/{id}", get(get_task).patch(update_task).delete(delete_task))@@ -486,6 +487,15 @@ async fn update_project(State(home): Shared, Path(slug): Path<String>, Json(p):.await}+#[derive(Deserialize)]+struct ProjectMove {+ before: Option<String>,+}++async fn move_project(State(home): Shared, Path(slug): Path<String>, Json(m): Json<ProjectMove>) -> Response {+ with_store(home, move |_, s| s.move_project(&slug, m.before.as_deref())).await+}+#[derive(Deserialize)]struct RepoLink {repo: String,