From 281daee58c962fad79e909b2bd55f2eadb0f562a Mon Sep 17 00:00:00 2001 From: iret77 <63622643+iret77@users.noreply.github.com> Date: Sat, 6 Jun 2026 01:33:16 +0200 Subject: [PATCH] =?UTF-8?q?fix(windows):=20restart=5Fclaude=5Fdesktop=20?= =?UTF-8?q?=E2=80=94=20remove=20duplicate=20pre-lookup=20taskkill?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex audit of v0.4.40 → v0.4.46 flagged a regression in `restart_claude_desktop`: a second `taskkill /IM Claude.exe` call has been duplicated *above* the sysinfo lookup that captures the running binary's path. By the time the sysinfo branch ran, Claude was already gone, the lookup returned `None`, and resolution fell through to the hardcoded `%LOCALAPPDATA%` candidates — defeating exactly the MSIX / Store / custom-install coverage we added in PR #128. Fix: drop the leading taskkill block. The post-lookup taskkill that we explicitly placed "after capture" remains, with its existing comment spelling out the ordering contract. A new comment at the top of the block records the history so this regression can't slip back in unnoticed. Verification (macOS arm64): cargo check / clippy `-D warnings` / test --lib (98/98), all clean. No backend behaviour change on Mac. Codex finding reference: SCOPE B / NICE-TO-HAVE / lib.rs:510. Co-Authored-By: Claude Opus 4.7 (1M context) --- companion/src-tauri/src/lib.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/companion/src-tauri/src/lib.rs b/companion/src-tauri/src/lib.rs index add0e72..1558a3a 100644 --- a/companion/src-tauri/src/lib.rs +++ b/companion/src-tauri/src/lib.rs @@ -507,13 +507,6 @@ async fn restart_claude_desktop() -> Result { use std::path::PathBuf; use std::process::Command; - // Best-effort graceful close (no `/F`). If Claude is already gone - // taskkill returns exit code 128 — we don't surface that. - let _ = no_window( - Command::new("taskkill").args(["/IM", "Claude.exe"]), - ) - .output(); - // Capture the path of the running Claude.exe *before* we tell it // to quit — that's the most reliable way to find the right binary // (covers MSIX/Store installs, custom install dirs, renames), @@ -525,6 +518,14 @@ async fn restart_claude_desktop() -> Result { // existing candidate path, which silently picks the older binary // when both NSIS and MSIX installs coexist (mid-upgrade), and // misses Store-installed Claudes entirely. + // + // History: an earlier taskkill block was duplicated *above* the + // sysinfo lookup at some point between v0.4.40 and v0.4.46, which + // defeated the whole point — by the time sysinfo ran, Claude was + // already gone and the fallback paths ended up being the only + // resolution. Codex spotted the regression in the v0.4.40→main + // audit. The single, post-capture taskkill below is the + // intended order. let running_exe: Option = { use sysinfo::{ProcessRefreshKind, RefreshKind, System}; let sys = System::new_with_specifics(