control: reconnect on EOF and relax rpc text parse
This commit is contained in:
@@ -407,7 +407,10 @@ final class ControlChannel: ObservableObject {
|
|||||||
self.logger.debug("control receive error: \(error.localizedDescription, privacy: .public)")
|
self.logger.debug("control receive error: \(error.localizedDescription, privacy: .public)")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if isComplete { break }
|
if isComplete {
|
||||||
|
self.logger.debug("control receive complete")
|
||||||
|
break
|
||||||
|
}
|
||||||
guard let data else { continue }
|
guard let data else { continue }
|
||||||
self.buffer.append(data)
|
self.buffer.append(data)
|
||||||
while let range = buffer.firstRange(of: Data([0x0A])) {
|
while let range = buffer.firstRange(of: Data([0x0A])) {
|
||||||
@@ -416,6 +419,8 @@ final class ControlChannel: ObservableObject {
|
|||||||
self.handleLine(lineData)
|
self.handleLine(lineData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If we exit the loop, drop the connection so the next request reconnects.
|
||||||
|
await self.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleLine(_ data: Data) {
|
private func handleLine(_ data: Data) {
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ export async function runCommandReply(
|
|||||||
let lastStreamedAssistant: string | undefined;
|
let lastStreamedAssistant: string | undefined;
|
||||||
const streamAssistantFinal = (msg?: {
|
const streamAssistantFinal = (msg?: {
|
||||||
role?: string;
|
role?: string;
|
||||||
content?: unknown[];
|
content?: unknown;
|
||||||
}) => {
|
}) => {
|
||||||
if (!onPartialReply || msg?.role !== "assistant") return;
|
if (!onPartialReply || msg?.role !== "assistant") return;
|
||||||
const textBlocks = Array.isArray(msg.content)
|
const textBlocks = Array.isArray(msg.content)
|
||||||
|
|||||||
Reference in New Issue
Block a user