From 2e942d11e7ffb9a039dd2edcd95f1d4cda2af82d Mon Sep 17 00:00:00 2001 From: kdrapel Date: Fri, 3 Apr 2026 17:40:07 +0200 Subject: [PATCH] fix(terminal): ignore errors when killing PTY on Windows Wrap session.pty.kill('SIGKILL') in a try/catch so killing an already-exited PTY is a no-op. This prevents the IPC call from rejecting and allows updateTaskAndNotify to complete (DB update + parent notification), fixing the working-directory two-click symptom. Typecheck passed. Co-authored-by: Copilot --- packages/domains/terminal/src/main/pty-manager.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/domains/terminal/src/main/pty-manager.ts b/packages/domains/terminal/src/main/pty-manager.ts index 6f7dc6d4..46d8e490 100644 --- a/packages/domains/terminal/src/main/pty-manager.ts +++ b/packages/domains/terminal/src/main/pty-manager.ts @@ -1344,7 +1344,12 @@ export function killPty(sessionId: string): boolean { sessions.delete(sessionId) notifySessionChange() // Use SIGKILL (9) to forcefully terminate - SIGTERM may not kill child processes - session.pty.kill('SIGKILL') + // Wrap in try/catch: on Windows, killing an already-dead process throws + try { + session.pty.kill('SIGKILL') + } catch { + // Process already exited — not an error + } return true }