From ec1ff52dfbd0ba1958336cf5cbbc564af93858a8 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 9 Dec 2025 00:29:20 +0000 Subject: [PATCH] control: reconnect on EOF and relax rpc text parse --- apps/macos/Sources/Clawdis/ControlChannel.swift | 7 ++++++- src/auto-reply/command-reply.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/macos/Sources/Clawdis/ControlChannel.swift b/apps/macos/Sources/Clawdis/ControlChannel.swift index 457bfa805..3aae36b3e 100644 --- a/apps/macos/Sources/Clawdis/ControlChannel.swift +++ b/apps/macos/Sources/Clawdis/ControlChannel.swift @@ -407,7 +407,10 @@ final class ControlChannel: ObservableObject { self.logger.debug("control receive error: \(error.localizedDescription, privacy: .public)") break } - if isComplete { break } + if isComplete { + self.logger.debug("control receive complete") + break + } guard let data else { continue } self.buffer.append(data) while let range = buffer.firstRange(of: Data([0x0A])) { @@ -416,6 +419,8 @@ final class ControlChannel: ObservableObject { self.handleLine(lineData) } } + // If we exit the loop, drop the connection so the next request reconnects. + await self.disconnect() } private func handleLine(_ data: Data) { diff --git a/src/auto-reply/command-reply.ts b/src/auto-reply/command-reply.ts index 6bf7adbed..795d71349 100644 --- a/src/auto-reply/command-reply.ts +++ b/src/auto-reply/command-reply.ts @@ -535,7 +535,7 @@ export async function runCommandReply( let lastStreamedAssistant: string | undefined; const streamAssistantFinal = (msg?: { role?: string; - content?: unknown[]; + content?: unknown; }) => { if (!onPartialReply || msg?.role !== "assistant") return; const textBlocks = Array.isArray(msg.content)