| 166 | // 中文注释:CLI 历史回放依赖 contentBlocks 的时序;只要出现计划/思考块, |
| 167 | // 就同步保留后续正文 text block,避免 UI 使用 blocks 渲染时丢失最终回答。 |
| 168 | const appendTextBlock = (text: string) => { |
| 169 | if (!text) return |
| 170 | const lastBlock = contentBlocks[contentBlocks.length - 1] |
| 171 | if (lastBlock?.type === 'text') { |
| 172 | lastBlock.text += text |
| 173 | } else { |
| 174 | contentBlocks.push({ type: 'text', text }) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | const appendThinkBlock = (text: string, tag = 'thinking', durationMs?: number) => { |
| 179 | if (!text && durationMs === undefined) return |