Skip to content

armgit / kanzo

Public Imported from GitHub
0

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.

Fix the columns, with an optional backlog kept in kanzo.db

emanuele-emd20c23b47974
diff --git a/README.md b/README.md
index bb0140c..1700f9c 100644
--- a/README.md
+++ b/README.md
@@ -84,10 +84,6 @@ Everything lives in `~/kanzo`: the board in `kanzo.db`, settings in `config.toml
```toml
port = 4242
listen = "127.0.0.1" # "0.0.0.0" opens the board to your network: no logins, so only on one you trust
-statuses = ["backlog", "todo", "doing", "review", "done"] # the last counts as done
-collapsed = ["backlog", "done"] # start as thin strips on the board
-inbox = "todo" # new tasks go here, and agents take their next task from here
-working = "doing" # ... and move it here
mcp_http = true # MCP at /mcp
```
diff --git a/src/app.js b/src/app.js
index c56378d..f014168 100644
--- a/src/app.js
+++ b/src/app.js
@@ -129,12 +129,12 @@ function projectColor(slug) {
return PROJECT_COLORS[projectColorName(slug)];
}
-// How many columns a status is past the inbox, where new tasks go: negative for the
-// columns before it, like backlog, and 0 for a status the board doesn't know.
+// How many columns a status is past todo: -1 for backlog, and 0 for a status the board
+// doesn't know.
function statusStep(status) {
- const { statuses, inbox } = state.board;
+ const { statuses } = state.board;
const i = statuses.indexOf(status);
- return i < 0 ? 0 : i - Math.max(statuses.indexOf(inbox), 0);
+ return i < 0 ? 0 : i - statuses.indexOf("todo");
}
function statusColor(status) {
@@ -142,13 +142,12 @@ function statusColor(status) {
return STATUS_COLORS[Math.max(i, 0) % STATUS_COLORS.length];
}
-// A column's status as a small progress circle, as in Linear: dashed before the inbox,
-// empty for the inbox, filling up across the board, a check for the last. A shape, so it
-// can't be taken for a project's colour dot.
+// A column's status as a small progress circle, as in Linear: dashed for backlog, empty
+// for todo, filling up across the board, a check for done. A shape, so it can't be taken
+// for a project's colour dot.
function statusIcon(status) {
- const { statuses, inbox } = state.board;
- const step = statusStep(status), steps = statuses.length - 1 - Math.max(statuses.indexOf(inbox), 0);
- const f = steps > 0 ? Math.max(step, 0) / steps : 0;
+ const step = statusStep(status), steps = statusStep("done");
+ const f = Math.max(step, 0) / steps;
const color = statusColor(status);
const dash = step < 0 ? ' stroke-dasharray="2.36 2.36"' : "";
let inside = "";
@@ -515,12 +514,11 @@ function renderColumns() {
columns.style.display = "";
// Build the columns once per layout so a refresh never wipes a half-typed task.
- const { collapsed, inbox } = state.board;
- const layout = [statuses.join(","), collapsed.join(","), inbox, state.project].join("|");
+ const layout = statuses.join(",") + "|" + state.project;
if (state.layout !== layout) {
state.layout = layout;
columns.replaceChildren(...statuses.map((status) => {
- const collapsible = collapsed.includes(status);
+ const collapsible = status === "backlog" || status === "done";
const col = el("section", { class: "column", "data-status": status },
el("h2", {},
statusIcon(status), status,
@@ -553,16 +551,14 @@ function renderColumns() {
}
}
-// Columns listed under `collapsed` in config.toml, like done, which only grows, start
-// collapsed to a thin strip, as in Trello or Linear, and each browser remembers the
-// choice. Cards can still be dropped on a strip.
+// Backlog and done, which only grows, start collapsed to a thin strip, as in Trello or
+// Linear, and each browser remembers the choice. Cards can still be dropped on a strip.
function isCollapsed(status) {
- const saved = localStorageGet("kanzo.collapsed." + status);
- return saved === null ? state.board.collapsed.includes(status) : saved === "1";
+ return localStorageGet(`kanzo.${status}Collapsed`) !== "0";
}
function setCollapsed(status, collapsed) {
- try { localStorage.setItem("kanzo.collapsed." + status, collapsed ? "1" : "0"); } catch {}
+ try { localStorage.setItem(`kanzo.${status}Collapsed`, collapsed ? "1" : "0"); } catch {}
showCollapsed();
}
@@ -576,9 +572,9 @@ function showCollapsed() {
const { status } = col.dataset;
const collapsed = isCollapsed(status);
col.classList.toggle("collapsed", collapsed);
- // The arrows point the way the column folds: to the right edge, or for the
- // columns before the inbox, to the left one.
- const left = statusStep(status) < 0;
+ // The arrows point the way the column folds: to the right edge, or for backlog,
+ // to the left one.
+ const left = status === "backlog";
button.replaceChildren(icon(collapsed !== left ? "expand" : "collapse"));
button.title = collapsed ? `Show ${status}` : `Collapse ${status}`;
button.setAttribute("aria-label", button.title);
diff --git a/src/export.rs b/src/export.rs
index 02b1259..b8ba5bb 100644
--- a/src/export.rs
+++ b/src/export.rs
@@ -189,7 +189,7 @@ mod tests {
assert!(md.contains("## Web `web`"), "{md}");
let json: serde_json::Value = serde_json::to_value(&board).unwrap();
- assert_eq!(json["statuses"][0], "backlog");
+ assert_eq!(json["statuses"][0], "todo");
assert_eq!(json["projects"][0]["slug"], "api");
assert_eq!(json["projects"][0]["tasks"][0]["key"], "api#1");
assert_eq!(json["projects"][0]["tasks"][0]["comments"][0]["author"], "claude-code");
diff --git a/src/home.rs b/src/home.rs
index 5efcbc8..fae18cb 100644
--- a/src/home.rs
+++ b/src/home.rs
@@ -5,10 +5,10 @@ use std::net::{IpAddr, Ipv4Addr};
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant};
-use anyhow::{Context, Result, bail};
+use anyhow::{Context, Result};
use serde::Deserialize;
-use crate::store::{self, Columns, ImagesOf, Store};
+use crate::store::{self, ImagesOf, Store};
const DEFAULT_PORT: u16 = 4242;
@@ -23,18 +23,6 @@ port = 4242
# port can read and change the board, and use its MCP endpoint.
listen = "127.0.0.1"
-# Board columns, left to right. Tasks in the last one count as done.
-statuses = ["backlog", "todo", "doing", "review", "done"]
-
-# Columns the board starts collapsed to a thin strip. Each browser remembers
-# when you open or close one.
-collapsed = ["backlog", "done"]
-
-# New tasks go in `inbox`, and agents take their next task from there and
-# move it to `working`. Without these, the first and second column.
-inbox = "todo"
-working = "doing"
-
# Also serve MCP over HTTP at http://localhost:<port>/mcp, for agents
# that cannot start `kanzo mcp` themselves.
mcp_http = true
@@ -61,69 +49,16 @@ const LOCK_WAIT: Duration = Duration::from_secs(10);
pub struct Config {
pub port: u16,
pub listen: IpAddr,
- pub statuses: Vec<String>,
- pub collapsed: Option<Vec<String>>,
- pub inbox: Option<String>,
- pub working: Option<String>,
+ /// Before 0.2 this set the columns; they're fixed now, with an optional backlog
+ /// switched on from the board. Still read, so older files keep working.
+ #[serde(rename = "statuses")]
+ _statuses: Option<toml::Value>,
pub mcp_http: bool,
}
impl Default for Config {
fn default() -> Self {
- Self {
- port: DEFAULT_PORT,
- listen: IpAddr::V4(Ipv4Addr::LOCALHOST),
- // A config.toml from before `collapsed`, `inbox` and `working` keeps its board.
- statuses: ["todo", "doing", "review", "done"].map(String::from).to_vec(),
- collapsed: None,
- inbox: None,
- working: None,
- mcp_http: true,
- }
- }
-}
-
-impl Config {
- /// Checks the column settings and fills in the ones left out.
- fn columns(&self) -> Result<Columns> {
- if self.statuses.len() < 2 {
- bail!("config.toml: `statuses` needs at least two columns");
- }
- for (i, s) in self.statuses.iter().enumerate() {
- if s.is_empty() || !s.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-' || c == '_')
- {
- bail!("config.toml: status {s:?} must be lowercase letters, digits, - or _");
- }
- if self.statuses[..i].contains(s) {
- bail!("config.toml: status {s:?} is listed twice");
- }
- }
- let listed = |key: &str, s: &String| {
- if self.statuses.contains(s) {
- Ok(s.clone())
- } else {
- bail!("config.toml: {key} {s:?} is not one of the statuses: {}", self.statuses.join(", "))
- }
- };
- let mut columns = Columns::new(self.statuses.clone());
- if let Some(s) = &self.inbox {
- columns.inbox = listed("inbox", s)?;
- }
- let at = self.statuses.iter().position(|s| *s == columns.inbox).unwrap_or(0);
- if at == self.statuses.len() - 1 {
- bail!("config.toml: inbox {:?} is the done column; pick another", columns.inbox);
- }
- columns.working = match &self.working {
- Some(s) => listed("working", s)?,
- None => self.statuses[at + 1].clone(),
- };
- if columns.working == columns.inbox {
- bail!("config.toml: inbox and working are both {:?}", columns.inbox);
- }
- if let Some(collapsed) = &self.collapsed {
- columns.collapsed = collapsed.iter().map(|s| listed("collapsed", s)).collect::<Result<_>>()?;
- }
- Ok(columns)
+ Self { port: DEFAULT_PORT, listen: IpAddr::V4(Ipv4Addr::LOCALHOST), _statuses: None, mcp_http: true }
}
}
@@ -132,7 +67,6 @@ impl Config {
pub struct Home {
pub dir: PathBuf,
pub config: Config,
- pub columns: Columns,
}
impl Home {
@@ -158,9 +92,8 @@ impl Home {
let path = dir.join("config.toml");
let text = fs::read_to_string(&path).with_context(|| format!("cannot read {}", path.display()))?;
let config: Config = toml::from_str(&text).with_context(|| format!("{} is not valid", path.display()))?;
- let columns = config.columns()?;
- let home = Self { dir, config, columns };
+ let home = Self { dir, config };
home.store()?.migrate()?;
Ok(home)
}
@@ -204,7 +137,7 @@ impl Home {
Err(TryLockError::Error(_)) => break None,
}
};
- Store::open(&self.db_path(), self.columns.clone(), lock)
+ Store::open(&self.db_path(), lock)
}
/// Runs `delete`, then deletes the image files of `of` that nothing uses any more:
@@ -260,54 +193,15 @@ mod tests {
assert!(dir.join(".gitignore").exists());
assert!(dir.join("kanzo.db").exists());
assert_eq!(home.config.port, DEFAULT_PORT);
- assert_eq!(home.columns.statuses, ["backlog", "todo", "doing", "review", "done"]);
- assert_eq!(home.columns.collapsed, ["backlog", "done"]);
- assert_eq!((home.columns.inbox.as_str(), home.columns.working.as_str()), ("todo", "doing"));
assert!(home.config.mcp_http);
assert!(home.config.listen.is_loopback());
}
#[test]
- fn rejects_bad_statuses() {
- let tmp = tempfile::tempdir().unwrap();
- fs::write(tmp.path().join("config.toml"), "statuses = [\"todo\", \"todo\"]\n").unwrap();
- let err = Home::open(tmp.path().to_path_buf()).unwrap_err();
- assert!(err.to_string().contains("listed twice"), "{err}");
- }
-
- #[test]
- fn statuses_alone_keep_the_old_board() {
+ fn statuses_from_before_0_2_are_ignored() {
let tmp = tempfile::tempdir().unwrap();
- let text = "statuses = [\"todo\", \"doing\", \"review\", \"done\"]\n";
- fs::write(tmp.path().join("config.toml"), text).unwrap();
+ fs::write(tmp.path().join("config.toml"), "statuses = [\"todo\", \"doing\", \"done\"]\n").unwrap();
let home = Home::open(tmp.path().to_path_buf()).unwrap();
- assert_eq!(home.columns, Columns::new(["todo", "doing", "review", "done"].map(String::from).to_vec()));
- assert_eq!(home.columns.collapsed, ["done"]);
- }
-
- #[test]
- fn working_follows_inbox() {
- let tmp = tempfile::tempdir().unwrap();
- let text = "statuses = [\"later\", \"next\", \"now\", \"done\"]\ninbox = \"next\"\n";
- fs::write(tmp.path().join("config.toml"), text).unwrap();
- let home = Home::open(tmp.path().to_path_buf()).unwrap();
- assert_eq!((home.columns.inbox.as_str(), home.columns.working.as_str()), ("next", "now"));
- }
-
- #[test]
- fn rejects_bad_columns() {
- for (extra, says) in [
- ("inbox = \"nope\"", "not one of the statuses"),
- ("working = \"nope\"", "not one of the statuses"),
- ("collapsed = [\"nope\"]", "not one of the statuses"),
- ("inbox = \"done\"", "done column"),
- ("inbox = \"doing\"\nworking = \"doing\"", "both"),
- ] {
- let tmp = tempfile::tempdir().unwrap();
- let text = format!("statuses = [\"todo\", \"doing\", \"done\"]\n{extra}\n");
- fs::write(tmp.path().join("config.toml"), text).unwrap();
- let err = Home::open(tmp.path().to_path_buf()).unwrap_err();
- assert!(err.to_string().contains(says), "{extra}: {err}");
- }
+ assert_eq!(home.store().unwrap().statuses(), ["todo", "doing", "review", "done"]);
}
}
diff --git a/src/mcp.rs b/src/mcp.rs
index 58a6961..c20c777 100644
--- a/src/mcp.rs
+++ b/src/mcp.rs
@@ -180,7 +180,7 @@ struct CreateTaskArgs {
project: Option<String>,
/// Comma-separated.
tags: Option<String>,
- /// Column, like backlog; defaults to todo.
+ /// Column; defaults to todo.
status: Option<String>,
}
@@ -383,15 +383,14 @@ impl Kanzo {
.await)
}
- #[tool(description = "Add a task to todo.")]
+ #[tool(description = "Add a task, to todo unless you pass status.")]
async fn create_task(&self, Parameters(args): Parameters<CreateTaskArgs>) -> Result<CallToolResult, ErrorData> {
Ok(self
.run(move |ctx, store| {
let project = ctx.project(store, args.project.as_deref())?;
let status = args.status.map(|s| s.trim().to_ascii_lowercase()).filter(|s| !s.is_empty());
- let status = status.as_deref().unwrap_or(&store.columns().inbox);
let description = args.description.as_deref().unwrap_or("");
- let mut t = store.create_task_in(project.id, status, &args.title, description)?;
+ let mut t = store.create_task_in(project.id, status.as_deref(), &args.title, description)?;
if args.tags.is_some() {
t = store.update_task(t.id, TaskPatch { tags: args.tags, ..Default::default() })?;
}
@@ -454,7 +453,7 @@ impl Kanzo {
Some(task) => Ok(format!("Moved to {}:\n{}", task.status, task_detail(ctx, store, &task)?)),
None => {
let scope = project.map_or("any project".into(), |p| p.slug);
- Ok(format!("Nothing in {} for {scope}.", store.columns().inbox))
+ Ok(format!("Nothing in todo for {scope}."))
}
}
})
diff --git a/src/store.rs b/src/store.rs
index 5e2aa05..cfc11aa 100644
--- a/src/store.rs
+++ b/src/store.rs
@@ -162,41 +162,23 @@ pub struct TaskPatch {
pub human: Option<bool>,
}
-/// The board's columns, from `config.toml`.
-#[derive(Debug, Clone, PartialEq)]
-pub struct Columns {
- /// Left to right; tasks in the last one count as done.
- pub statuses: Vec<String>,
- /// Columns the board starts collapsed.
- pub collapsed: Vec<String>,
- /// Where new tasks go, and where agents take the next task from.
- pub inbox: String,
- /// Where an agent's next task moves to.
- pub working: String,
-}
+/// The board's columns, left to right. New tasks go in todo, agents take theirs from
+/// there and move them to doing, and tasks in done count as done.
+const STATUSES: [&str; 4] = ["todo", "doing", "review", "done"];
-impl Columns {
- /// New tasks in the first column, agents move them to the second, done starts collapsed.
- pub fn new(statuses: Vec<String>) -> Self {
- Self {
- collapsed: statuses.last().cloned().into_iter().collect(),
- inbox: statuses[0].clone(),
- working: statuses[1].clone(),
- statuses,
- }
- }
-}
+/// An optional column before todo, for tasks that agents leave alone.
+pub const BACKLOG: &str = "backlog";
pub struct Store {
conn: Connection,
- columns: Columns,
+ statuses: Vec<String>,
/// Held while the connection is open; declared after `conn` so it is released after it closes.
_lock: Option<std::fs::File>,
}
impl Store {
/// Opens the database. `lock` is kept until the store is dropped (see `Home::store`).
- pub fn open(path: &Path, columns: Columns, lock: Option<std::fs::File>) -> Result<Self> {
+ pub fn open(path: &Path, lock: Option<std::fs::File>) -> Result<Self> {
let conn = Connection::open(path)?;
// The board and any number of agents share this file; wait instead of failing.
conn.busy_timeout(Duration::from_secs(5))?;
@@ -206,19 +188,39 @@ impl Store {
// when a board loses power.
conn.pragma_update_and_check(None, "journal_mode", "TRUNCATE", |_| Ok(()))?;
conn.pragma_update(None, "foreign_keys", "ON")?;
- Ok(Self { conn, columns, _lock: lock })
+ // Before the first migration there is no meta table, and so no backlog.
+ let backlog = conn
+ .query_row("SELECT value FROM meta WHERE key = 'backlog'", [], |r| r.get::<_, String>(0))
+ .is_ok_and(|v| v == "1");
+ let statuses = backlog.then_some(BACKLOG).into_iter().chain(STATUSES).map(String::from).collect();
+ Ok(Self { conn, statuses, _lock: lock })
}
pub fn statuses(&self) -> &[String] {
- &self.columns.statuses
+ &self.statuses
}
- pub fn columns(&self) -> &Columns {
- &self.columns
+ fn done_status(&self) -> &str {
+ STATUSES[3]
}
- fn done_status(&self) -> &str {
- self.columns.statuses.last().expect("config has at least two statuses")
+ /// Shows or hides the backlog column. It must be empty to hide it, or its
+ /// tasks would vanish from the board.
+ pub fn set_backlog(&self, on: bool) -> Result<()> {
+ self.write(|c| {
+ let left: i64 = c.query_row("SELECT count(*) FROM tasks WHERE status = ?1", [BACKLOG], |r| r.get(0))?;
+ if !on && left > 0 {
+ let tasks = if left == 1 { "task" } else { "tasks" };
+ return Err(Error::Invalid(format!("move the {left} {tasks} out of backlog first")));
+ }
+ c.execute(
+ "INSERT INTO meta (key, value) VALUES ('backlog', ?1) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
+ [if on { "1" } else { "0" }],
+ )?;
+ // Other open boards redraw their columns.
+ c.execute("UPDATE meta SET value = value + 1 WHERE key = 'changes'", [])?;
+ Ok(())
+ })
}
/// Runs `f` in an immediate transaction, so concurrent writers queue up
@@ -595,15 +597,22 @@ impl Store {
Ok(max.map_or(1.0, |m| m.floor() + 1.0))
}
- /// Adds a task at the bottom of the inbox column; a shorthand for tests.
+ /// Adds a task at the bottom of todo; a shorthand for tests.
#[cfg(test)]
pub fn create_task(&self, project_id: i64, title: &str, description: &str) -> Result<Task> {
- self.create_task_in(project_id, &self.columns.inbox, title, description)
+ self.create_task_in(project_id, None, title, description)
}
- /// Adds a task at the bottom of `status`.
- pub fn create_task_in(&self, project_id: i64, status: &str, title: &str, description: &str) -> Result<Task> {
+ /// Adds a task at the bottom of `status`, todo when left out.
+ pub fn create_task_in(
+ &self,
+ project_id: i64,
+ status: Option<&str>,
+ title: &str,
+ description: &str,
+ ) -> Result<Task> {
let title = clean_title(title)?;
+ let status = status.unwrap_or(STATUSES[0]);
self.check_status(status)?;
let id = self.write(|c| {
let position = Self::end_of_column(c, status, 0)?;
@@ -728,11 +737,10 @@ impl Store {
Ok(())
}
- /// Takes the top task of the inbox column that isn't for a person, and moves it to
- /// the bottom of the working one.
+ /// Takes the top task of todo that isn't for a person, and moves it to the bottom
+ /// of doing.
pub fn next_task(&self, project_id: Option<i64>) -> Result<Option<Task>> {
- let from = &self.columns.inbox;
- let to = &self.columns.working;
+ let [from, to, ..] = STATUSES;
let id = self.write(|c| {
let id: Option<i64> = c
.query_row(
@@ -1002,12 +1010,8 @@ mod tests {
use super::*;
fn store() -> (tempfile::TempDir, Store) {
- store_with(Columns::new(["todo", "doing", "review", "done"].map(String::from).to_vec()))
- }
-
- fn store_with(columns: Columns) -> (tempfile::TempDir, Store) {
let dir = tempfile::tempdir().unwrap();
- let store = Store::open(&dir.path().join("kanzo.db"), columns, None).unwrap();
+ let store = Store::open(&dir.path().join("kanzo.db"), None).unwrap();
store.migrate().unwrap();
(dir, store)
}
@@ -1173,8 +1177,7 @@ mod tests {
)
.unwrap();
}
- let statuses = ["todo", "doing", "review", "done"].map(String::from).to_vec();
- let s = Store::open(&path, Columns::new(statuses), None).unwrap();
+ let s = Store::open(&path, None).unwrap();
s.migrate().unwrap();
assert_eq!(s.find_project("api").unwrap().repos, ["me/api"]);
assert!(s.find_project("web").unwrap().repos.is_empty());
@@ -1301,20 +1304,27 @@ mod tests {
}
#[test]
- fn inbox_and_working_need_not_be_the_first_columns() {
- let statuses = ["backlog", "todo", "doing", "done"].map(String::from).to_vec();
- let columns = Columns { inbox: "todo".into(), working: "doing".into(), ..Columns::new(statuses) };
- let (_dir, s) = store_with(columns);
+ fn backlog_is_a_column_agents_skip() {
+ let (dir, s) = store();
+ assert_eq!(s.statuses(), STATUSES);
+ s.set_backlog(true).unwrap();
+ let s = Store::open(&dir.path().join("kanzo.db"), None).unwrap();
+ assert_eq!(s.statuses(), ["backlog", "todo", "doing", "review", "done"]);
let api = s.create_project("api", "", None).unwrap();
- let backlog = s.create_task_in(api.id, "backlog", "later", "").unwrap();
+ let backlog = s.create_task_in(api.id, Some("backlog"), "later", "").unwrap();
assert_eq!(backlog.status, "backlog");
- assert!(s.create_task_in(api.id, "nope", "x", "").is_err());
+ assert!(s.create_task_in(api.id, Some("nope"), "x", "").is_err());
assert_eq!(s.create_task(api.id, "now", "").unwrap().status, "todo");
let t = s.next_task(None).unwrap().unwrap();
assert_eq!((t.title.as_str(), t.status.as_str()), ("now", "doing"));
assert!(s.next_task(None).unwrap().is_none());
assert_eq!(s.get_task(backlog.id).unwrap().status, "backlog");
+
+ // Hiding it would hide its tasks.
+ assert!(s.set_backlog(false).is_err());
+ s.delete_task(backlog.id).unwrap();
+ s.set_backlog(false).unwrap();
}
#[test]
diff --git a/src/sync.rs b/src/sync.rs
index 93ee322..11376b9 100644
--- a/src/sync.rs
+++ b/src/sync.rs
@@ -149,7 +149,7 @@ pub fn sync(home: &Home, keep: Option<Keep>, prompt: bool) -> Result<String> {
// kanzo.db, never across a commit (hooks, signing prompts) or the network.
{
let _lock = home.lock_exclusive()?;
- crate::store::Store::open(&home.db_path(), home.columns.clone(), None)?.settle()?;
+ crate::store::Store::open(&home.db_path(), None)?.settle()?;
git(&["add", "--all"])?;
}
if !git_ok(&["diff", "--cached", "--quiet"]) {
diff --git a/src/web.rs b/src/web.rs
index cbf20aa..ebb8d02 100644
--- a/src/web.rs
+++ b/src/web.rs
@@ -140,6 +140,7 @@ fn router(home: Home, guard: Guard, shutdown: CancellationToken) -> Router {
.route("/api/tasks/{id}/images", post(attach_image))
.route("/api/update", get(update_status).post(update_now))
.route("/api/sync", get(sync_status).post(sync_now).put(sync_repo))
+ .route("/api/settings", patch(update_settings))
.layer(middleware::from_fn_with_state(Arc::new(guard), protect))
.with_state(Arc::new(home))
}
@@ -283,9 +284,7 @@ struct BoardQuery {
#[derive(Serialize)]
struct Board {
changes: String,
- collapsed: Vec<String>,
done_hidden: usize,
- inbox: String,
projects: Vec<store::Project>,
statuses: Vec<String>,
tasks: Vec<store::Task>,
@@ -302,9 +301,7 @@ async fn board(State(home): Shared, Query(q): Query<BoardQuery>) -> Response {
let (tasks, done_hidden) = s.list_tasks_keeping_done(project.map(|p| p.id), None, keep_done)?;
Ok(Board {
changes: change_token(h, s)?,
- collapsed: s.columns().collapsed.clone(),
done_hidden,
- inbox: s.columns().inbox.clone(),
projects: s.list_projects()?,
statuses: s.statuses().to_vec(),
tasks,
@@ -384,19 +381,26 @@ struct NewTask {
title: String,
#[serde(default)]
description: String,
- /// The column; the inbox when left out.
- status: Option<String>,
}
async fn create_task(State(home): Shared, Json(t): Json<NewTask>) -> Response {
with_store(home, move |_, s| {
let project = s.find_project(&t.project)?;
- let status = t.status.as_deref().unwrap_or(&s.columns().inbox);
- s.create_task_in(project.id, status, &t.title, &t.description)
+ s.create_task_in(project.id, None, &t.title, &t.description)
})
.await
}
+/// Board settings, kept in kanzo.db so they sync with the board.
+#[derive(Deserialize)]
+struct Settings {
+ backlog: bool,
+}
+
+async fn update_settings(State(home): Shared, Json(r): Json<Settings>) -> Response {
+ with_store(home, move |_, s| s.set_backlog(r.backlog)).await
+}
+
#[derive(Serialize)]
struct TaskReply {
comments: Vec<store::Comment>,