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
fix: tidy Windows updates
marcuslannister6c31cb7abca0
diff --git a/src/main.rs b/src/main.rsindex 24e0d93..8eb4bf2 100644--- a/src/main.rs+++ b/src/main.rs@@ -88,8 +88,10 @@ enum ServiceAction {fn main() -> ExitCode {let cli = Cli::parse();- if cfg!(windows) {- update::remove_old_exes();+ if cfg!(windows)+ && let Ok(exe) = std::env::current_exe()+ {+ update::remove_old_exes(&exe);}// One thread runs all the async work: the board serves one person, and each// agent starts its own `kanzo mcp`. Database calls run on a few blockingdiff --git a/src/update.rs b/src/update.rsindex 049f0c4..314aa2f 100644--- a/src/update.rs+++ b/src/update.rs@@ -98,9 +98,9 @@ fn old_exe(exe: &Path) -> PathBuf {exe.with_extension(format!("exe.{CURRENT}.old"))}-/// Deletes the programs that updates replaced on Windows, except those still running.-pub fn remove_old_exes() {- let Ok(exe) = std::env::current_exe() else { return };+/// Deletes the programs that updates replaced `exe` with on Windows (see `old_exe`),+/// except those still running.+pub fn remove_old_exes(exe: &Path) {let (Some(dir), Some(name)) = (exe.parent(), exe.file_name()) else { return };let prefix = format!("{}.", name.to_string_lossy());for entry in std::fs::read_dir(dir).into_iter().flatten().flatten() {@@ -113,29 +113,35 @@ pub fn remove_old_exes() {}fn run_installer(script: &[u8], dir: &Path) -> Result<Output, String> {+ // PowerShell runs a script from a file, not from stdin.+ let file = std::env::temp_dir().join("kanzo-installer.ps1");let mut cmd = if cfg!(windows) {- // PowerShell runs a script from a file, not from stdin.- let file = std::env::temp_dir().join("kanzo-installer.ps1");std::fs::write(&file, script).map_err(|e| format!("cannot write {}: {e}", file.display()))?;let mut ps = Command::new("powershell");- ps.args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-File"]).arg(file).stdin(Stdio::null());+ ps.args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-File"]).arg(&file).stdin(Stdio::null());ps} else {let mut sh = Command::new("sh");sh.arg("-s").stdin(Stdio::piped());sh};- let mut child = cmd- .env("KANZO_INSTALL_DIR", dir)- .env("KANZO_NO_MODIFY_PATH", "1")- .stdout(Stdio::null())- .stderr(Stdio::piped())- .spawn()- .map_err(|e| format!("cannot run the installer: {e}"))?;- if let Some(mut stdin) = child.stdin.take() {- stdin.write_all(script).map_err(|e| e.to_string())?;+ let out = (|| {+ let mut child = cmd+ .env("KANZO_INSTALL_DIR", dir)+ .env("KANZO_NO_MODIFY_PATH", "1")+ .stdout(Stdio::null())+ .stderr(Stdio::piped())+ .spawn()+ .map_err(|e| format!("cannot run the installer: {e}"))?;+ if let Some(mut stdin) = child.stdin.take() {+ stdin.write_all(script).map_err(|e| e.to_string())?;+ }+ child.wait_with_output().map_err(|e| e.to_string())+ })();+ if cfg!(windows) {+ let _ = std::fs::remove_file(&file);}- child.wait_with_output().map_err(|e| e.to_string())+ out}/// The arguments to start again with: the same ones, without opening another browser tab.@@ -184,6 +190,20 @@ mod tests {assert!(!newer("not a version"));}+ #[test]+ fn removes_only_old_programs() {+ let tmp = tempfile::tempdir().unwrap();+ let keep = ["kanzo.exe", "kanzo.exe.bak", "other.exe.old", "kanzo.old"];+ for f in keep.iter().chain(&["kanzo.exe.0.2.1.old", "kanzo.exe.0.3.0.old"]) {+ std::fs::write(tmp.path().join(f), "").unwrap();+ }+ remove_old_exes(&tmp.path().join("kanzo.exe"));+ let mut left: Vec<_> =+ std::fs::read_dir(tmp.path()).unwrap().map(|e| e.unwrap().file_name().into_string().unwrap()).collect();+ left.sort();+ assert_eq!(left, ["kanzo.exe", "kanzo.exe.bak", "kanzo.old", "other.exe.old"]);+ }+#[test]#[cfg(unix)]fn restarts_without_opening_a_tab() {diff --git a/src/web.rs b/src/web.rsindex d14bb13..8fed010 100644--- a/src/web.rs+++ b/src/web.rs@@ -641,10 +641,11 @@ async fn update_status(Query(q): Query<UpdateQuery>) -> Response {/// Installs the latest release over this program, answers, then starts it in place, or/// asks the user to restart it where it can't.async fn update_now(State(home): Shared) -> Response {- let restart = update::can_restart(&home.dir);- match tokio::task::spawn_blocking(update::install).await {- Ok(Ok(_)) if !restart => Json(json!({ "restarting": false })).into_response(),- Ok(Ok(exe)) => {+ // `can_restart` runs schtasks on Windows, so it waits off the async thread too.+ let dir = home.dir.clone();+ match tokio::task::spawn_blocking(move || (update::can_restart(&dir), update::install())).await {+ Ok((false, Ok(_))) => Json(json!({ "restarting": false })).into_response(),+ Ok((true, Ok(exe))) => {tokio::spawn(async move {// Let the answer reach the board first.tokio::time::sleep(std::time::Duration::from_millis(300)).await;@@ -655,7 +656,7 @@ async fn update_now(State(home): Shared) -> Response {});Json(json!({ "restarting": true })).into_response()}- Ok(Err(error)) => (StatusCode::INTERNAL_SERVER_ERROR, Json(json!({ "error": error }))).into_response(),+ Ok((_, Err(error))) => (StatusCode::INTERNAL_SERVER_ERROR, Json(json!({ "error": error }))).into_response(),Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, Json(json!({ "error": e.to_string() }))).into_response(),}}