From 0c217e32758edb1e5401f545099b2187450a2325 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 14 Apr 2026 12:33:47 +0900 Subject: [PATCH] Fix empty chat bubbles by adding error parsing in streaming APIs --- src/extension.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 027aa71..ffaf73b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -742,7 +742,10 @@ class SidebarChatProvider implements vscode.WebviewViewProvider { try { const raw = line.startsWith('data: ') ? line.slice(6) : line; const json = JSON.parse(raw); - const token = json.choices?.[0]?.delta?.content || ''; + let token = json.choices?.[0]?.delta?.content || ''; + if (json.error) { + token = `[API 오류] ${json.error.message || json.error}`; + } if (token) { aiMessage += token; this._view!.webview.postMessage({ type: 'streamChunk', value: token }); } } catch {} } @@ -775,7 +778,10 @@ class SidebarChatProvider implements vscode.WebviewViewProvider { if (!line.trim()) continue; try { const json = JSON.parse(line); - const token = json.message?.content || ''; + let token = json.message?.content || ''; + if (json.error) { + token = `[API 오류] ${json.error}`; + } if (token) { aiMessage += token; this._view!.webview.postMessage({ type: 'streamChunk', value: token }); } } catch {} } @@ -923,7 +929,9 @@ class SidebarChatProvider implements vscode.WebviewViewProvider { const raw = line.startsWith('data: ') ? line.slice(6) : line; const json = JSON.parse(raw); let token = ''; - if (isLMStudio) { + if (json.error) { + token = `[API 오류] ${json.error.message || json.error}`; + } else if (isLMStudio) { token = json.choices?.[0]?.delta?.content || ''; } else { token = json.message?.content || '';