From b3ba3d55ee2fc5b730cd7b2bbb7a738e775c7286 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 24 May 2025 14:24:17 +0200 Subject: [PATCH] auto-git: [change] main.js --- main.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 6f74f8b..6c9bfe0 100644 --- a/main.js +++ b/main.js @@ -247,11 +247,22 @@ async function streamLLMCommitMessages(prompt, onDataChunk) { done = streamDone; if (value) { const chunk = decoder.decode(value, { stream: true }); - if (onDataChunk) onDataChunk(chunk); - fullOutput += chunk; + for (const line of chunk.split('\n')) { + if (!line.trim()) continue; + try { + const obj = JSON.parse(line); + if (obj.response) { + fullOutput += obj.response; + if (onDataChunk) onDataChunk(obj.response); + } + if (obj.done) break; + } catch (e) { + // ignore malformed chunk + } + } } } - return fullOutput.trim(); + return fullOutput; } async function squashCommitMessages(repoPath, commitMessage, hashes) {