Skip to content

Commit 595b415

Browse files
committed
Fix chat not stopping responding on errors
1 parent 758f5d4 commit 595b415

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

Core/Sources/ChatPlugins/ShortcutChatPlugin/ShortcutInputChatPlugin.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,17 @@ public actor ShortcutInputChatPlugin: ChatPlugin {
9090
if let text = String(data: data, encoding: .utf8) {
9191
if text.isEmpty { return }
9292
let stream = try await chatGPTService.send(content: text, summary: nil)
93-
for try await _ in stream {}
93+
do {
94+
for try await _ in stream {}
95+
} catch {}
9496
} else {
9597
let text = """
9698
[View File](\(temporaryOutputFileURL))
9799
"""
98100
let stream = try await chatGPTService.send(content: text, summary: nil)
99-
for try await _ in stream {}
101+
do {
102+
for try await _ in stream {}
103+
} catch {}
100104
}
101105

102106
return

Core/Sources/ChatService/ChatService.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ public final class ChatService: ObservableObject {
4040

4141
let stream = try await chatGPTService.send(content: content, summary: nil)
4242
isReceivingMessage = true
43-
for try await _ in stream {}
44-
isReceivingMessage = false
43+
do {
44+
for try await _ in stream {}
45+
isReceivingMessage = false
46+
} catch {
47+
isReceivingMessage = false
48+
}
4549
}
4650

4751
public func stopReceivingMessage() async {

0 commit comments

Comments
 (0)