MCPcopy Create free account
hub / github.com/TanStack/ai / queueChunk

Function queueChunk

packages/ai-devtools/src/store/ai-context.tsx:362–384  ·  view source on GitHub ↗
(conversationId: string, chunk: Chunk)

Source from the content-addressed store, hash-verified

360 }
361
362 function queueChunk(conversationId: string, chunk: Chunk): void {
363 let pending = pendingConversationChunks.get(conversationId)
364 if (!pending) {
365 pending = { chunks: [], newChunkCount: 0 }
366 pendingConversationChunks.set(conversationId, pending)
367 }
368
369 const lastPending = pending.chunks[pending.chunks.length - 1]
370 if (
371 lastPending &&
372 lastPending.type === chunk.type &&
373 isMergeableChunkType(chunk.type) &&
374 lastPending.messageId === chunk.messageId
375 ) {
376 lastPending.content = chunk.content || lastPending.content
377 lastPending.delta = chunk.delta
378 lastPending.chunkCount += chunk.chunkCount
379 } else {
380 pending.chunks.push(chunk)
381 }
382 pending.newChunkCount += chunk.chunkCount
383 scheduleBatchFlush()
384 }
385
386 function queueMessageChunk(
387 conversationId: string,

Callers 1

addChunkFunction · 0.85

Calls 5

isMergeableChunkTypeFunction · 0.85
scheduleBatchFlushFunction · 0.85
getMethod · 0.65
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected