MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / segmentAssistantStreamingText

Function segmentAssistantStreamingText

apps/web/lib/chat-segmentation.ts:104–128  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

102}
103
104export function segmentAssistantStreamingText(text: string): AssistantStreamingSegments {
105 const { blocks, endsAtBoundary, hasOpenFence } = collectAssistantBlocks(text);
106 if (blocks.length === 0) {
107 return {
108 committed: [],
109 draft: null,
110 };
111 }
112 if (hasOpenFence || !endsAtBoundary) {
113 if (blocks.length === 1) {
114 return {
115 committed: [],
116 draft: blocks[0],
117 };
118 }
119 return {
120 committed: blocks.slice(0, -1),
121 draft: blocks[blocks.length - 1] ?? null,
122 };
123 }
124 return {
125 committed: blocks,
126 draft: null,
127 };
128}

Callers

nothing calls this directly

Calls 1

collectAssistantBlocksFunction · 0.85

Tested by

no test coverage detected