From 0f4e110512eb691222b353950bc7f5ff11e72515 Mon Sep 17 00:00:00 2001 From: maksarsanjeev Date: Tue, 20 Oct 2026 13:07:32 +0300 Subject: [PATCH] Chat: a reply stopped by BroV itself is not an error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit claude catches SIGTERM and exits 143, so a reply cancelled by a new message, a new dialog or a closed tab showed «claude: код выхода 143». Co-Authored-By: Claude Opus 5.5 --- NotchBuddy/Sources/App/ClaudeCodeCLI.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NotchBuddy/Sources/App/ClaudeCodeCLI.swift b/NotchBuddy/Sources/App/ClaudeCodeCLI.swift index 3d330ec..db7972f 100644 --- a/NotchBuddy/Sources/App/ClaudeCodeCLI.swift +++ b/NotchBuddy/Sources/App/ClaudeCodeCLI.swift @@ -147,7 +147,11 @@ final class ClaudeCodeCLI { } } p.waitUntilExit() + // cancel() (new message, new dialog, closed tab) drops our reference before the + // process dies; `claude` catches SIGTERM and exits 143 instead of dying on the signal. + let stoppedByUs = process !== p if process === p { process = nil } + if stoppedByUs && parser.finalText == nil { throw CancellationError() } if let error = parser.errorMessage { if error.localizedCaseInsensitiveContains("authenticate") || error.localizedCaseInsensitiveContains("login") { @@ -161,6 +165,9 @@ final class ClaudeCodeCLI { if p.terminationReason == .uncaughtSignal { throw CancellationError() } if parser.finalText == nil, p.terminationStatus != 0 { let stderr = String(data: err.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" + if p.terminationStatus == 143 || p.terminationStatus == 130 { + throw ClaudeCodeCLIError.failed("Ответ прерван: процесс claude остановили снаружи. Отправь сообщение ещё раз.") + } let last = stderr.split(separator: "\n").last.map(String.init) ?? "код выхода \(p.terminationStatus)" throw ClaudeCodeCLIError.failed("claude: \(last)") }