Skip to content

Commit 20e2246

Browse files
icecrasher321waleedlatif1
authored andcommitted
move streaming fix to right level
1 parent 5fa2641 commit 20e2246

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

apps/sim/app/chat/hooks/use-chat-streaming.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -314,22 +314,9 @@ export function useChatStreaming() {
314314
let finalContent = accumulatedText
315315

316316
if (formattedOutputs.length > 0) {
317-
const trimmedStreamingContent = accumulatedText.trim()
318-
319-
const uniqueOutputs = formattedOutputs.filter((output) => {
320-
const trimmedOutput = output.trim()
321-
if (!trimmedOutput) return false
322-
323-
// Skip outputs that are already in the streamed content to avoid duplication
324-
if (trimmedStreamingContent?.includes(trimmedOutput)) {
325-
return false
326-
}
327-
328-
return true
329-
})
330-
331-
if (uniqueOutputs.length > 0) {
332-
const combinedOutputs = uniqueOutputs.join('\n\n')
317+
const nonEmptyOutputs = formattedOutputs.filter((output) => output.trim())
318+
if (nonEmptyOutputs.length > 0) {
319+
const combinedOutputs = nonEmptyOutputs.join('\n\n')
333320
finalContent = finalContent
334321
? `${finalContent.trim()}\n\n${combinedOutputs}`
335322
: combinedOutputs

apps/sim/lib/workflows/streaming/streaming.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ export async function createStreamingResponse(
203203

204204
for (const outputId of streamConfig.selectedOutputs) {
205205
const blockId = extractBlockIdFromOutputId(outputId)
206+
if (streamedContent.has(blockId)) {
207+
continue
208+
}
209+
206210
const path = extractPathFromOutputId(outputId, blockId)
207211

208212
if (result.logs) {

0 commit comments

Comments
 (0)