MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / createStreamChunkHandler

Function createStreamChunkHandler

cli/src/utils/sdk-event-handlers.ts:493–525  ·  view source on GitHub ↗
(state: EventHandlerState)

Source from the content-addressed store, hash-verified

491
492export const createStreamChunkHandler =
493 (state: EventHandlerState) => (event: StreamChunkEvent) => {
494 const destination = destinationFromChunkEvent(event)
495 let text: string | undefined
496 if (typeof event === 'string') {
497 text = event
498 } else {
499 text = event.chunk
500 }
501
502 if (!destination) {
503 state.logger.warn({ event }, 'Unhandled stream chunk event')
504 return
505 }
506
507 if (!text) {
508 return
509 }
510
511 ensureStreaming(state)
512
513 if (destination.type === 'root') {
514 if (destination.textType === 'text') {
515 state.streaming.streamRefs.setters.appendRootStreamBuffer(text)
516 }
517 state.streaming.streamRefs.setters.setRootStreamSeen(true)
518 appendRootChunk(state, { type: destination.textType, text })
519 return
520 }
521
522 state.message.updater.updateAiMessageBlocks((blocks) =>
523 processTextChunk(blocks, destination, text),
524 )
525 }
526
527export const createEventHandler =
528 (state: EventHandlerState) => (event: SDKEvent) => {

Callers 2

createRunConfigFunction · 0.90

Calls 4

processTextChunkFunction · 0.90
ensureStreamingFunction · 0.85
appendRootChunkFunction · 0.85

Tested by

no test coverage detected