MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / appendThinkBlock

Function appendThinkBlock

apps/cli/src/ai/chat-command.ts:178–205  ·  view source on GitHub ↗
(text: string, tag = 'thinking', durationMs?: number)

Source from the content-addressed store, hash-verified

176 }
177
178 const appendThinkBlock = (text: string, tag = 'thinking', durationMs?: number) => {
179 if (!text && durationMs === undefined) return
180 const lastBlock = contentBlocks[contentBlocks.length - 1]
181 let targetBlock: ContentBlock | undefined
182
183 if (lastBlock?.type === 'think' && lastBlock.tag === tag) {
184 lastBlock.text += text
185 targetBlock = lastBlock
186 } else if (text.trim().length > 0) {
187 targetBlock = { type: 'think', tag, text }
188 contentBlocks.push(targetBlock)
189 } else if (durationMs !== undefined) {
190 for (let index = contentBlocks.length - 1; index >= 0; index--) {
191 const block = contentBlocks[index]
192 if (block.type === 'think' && block.tag === tag) {
193 targetBlock = block
194 break
195 }
196 }
197 }
198
199 if (durationMs !== undefined && targetBlock?.type === 'think') {
200 targetBlock.durationMs = durationMs
201 }
202 if (targetBlock?.type === 'think') {
203 hasReplayContentBlocks = true
204 }
205 }
206
207 const appendChartBlocks = (charts: ChartPayload[]) => {
208 if (charts.length === 0) return

Callers 1

runChatTurnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected