From a7cad2fc2fc759bba8a2c2c317c3dcc69fe07f94 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 9 Sep 2026 11:59:03 +0800 Subject: [PATCH] Terminate stale Kapture instances at launch; log topmost windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A stale copy surviving an update keeps its own hotkey and overlays on screen, silently eating every click meant for the new instance (matching the empty session logs). New copies now force-terminate older instances, and the first window scan logs the topmost on-screen windows so anything covering the overlays is visible in diagnostics. 💘 Generated with Crush Assisted-by: Crush:deepseek-v4-flash-0731 --- Sources/Kapture/App.swift | 11 +++++++++++ build-app.sh | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Sources/Kapture/App.swift b/Sources/Kapture/App.swift index c336588..cac7aed 100644 --- a/Sources/Kapture/App.swift +++ b/Sources/Kapture/App.swift @@ -21,6 +21,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate { runOCRSelfTest() return } + // Single instance: stale copies keep their own hotkey + overlays alive + // after app updates and eat clicks meant for the new instance. + let myPid = ProcessInfo.processInfo.processIdentifier + let others = NSRunningApplication.runningApplications(withBundleIdentifier: "dev.tzgyn.kapture") + .filter { $0.processIdentifier != myPid } + if !others.isEmpty { + CaptureController.log("launch: other Kapture instances pids=\(others.map { String($0.processIdentifier) }.joined(separator: ",")) — terminating them") + for other in others { + other.forceTerminate() + } + } HotkeyManager.shared.onTrigger = { CaptureController.shared.begin() } HotkeyManager.shared.register() } diff --git a/build-app.sh b/build-app.sh index db88268..eecc9da 100755 --- a/build-app.sh +++ b/build-app.sh @@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST' CFBundleIconFile Icon CFBundleShortVersionString - 1.6.4 + 1.6.5 CFBundleVersion - 64 + 65 LSUIElement NSHighResolutionCapable