mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 03:55:09 +08:00
fix(chat): enrich stream metadata with plan/approval/browser tracking, fix thinking segment ordering
This commit is contained in:
parent
8725ecd0c7
commit
281b1efffd
@ -222,8 +222,15 @@ export function useChat(options: UseChatOptions): UseChatReturn {
|
|||||||
let thinkSeg = segs.findLast((s: MessageSegment) => s.type === 'thinking' && s.status === 'running')
|
let thinkSeg = segs.findLast((s: MessageSegment) => s.type === 'thinking' && s.status === 'running')
|
||||||
if (!thinkSeg) {
|
if (!thinkSeg) {
|
||||||
thinkSeg = { id: genSegId(), type: 'thinking', status: 'running', thinkingText: '', timestamp: Date.now() }
|
thinkSeg = { id: genSegId(), type: 'thinking', status: 'running', thinkingText: '', timestamp: Date.now() }
|
||||||
segs.push(thinkSeg)
|
// 修复:如果前面已有 content segment(模型先发 content 后发 thinking),
|
||||||
flushSegmentsToMessage() // 新 thinking segment 创建时同步一次
|
// 把 thinking 插入到第一个 content 之前,确保 thinking 在上方显示
|
||||||
|
const firstContentIdx = segs.findIndex((s: MessageSegment) => s.type === 'content')
|
||||||
|
if (firstContentIdx >= 0 && !segs.some((s: MessageSegment) => s.type === 'tool_call')) {
|
||||||
|
segs.splice(firstContentIdx, 0, thinkSeg)
|
||||||
|
} else {
|
||||||
|
segs.push(thinkSeg)
|
||||||
|
}
|
||||||
|
flushSegmentsToMessage()
|
||||||
}
|
}
|
||||||
thinkSeg.thinkingText = (thinkSeg.thinkingText || '') + (data.delta || '')
|
thinkSeg.thinkingText = (thinkSeg.thinkingText || '') + (data.delta || '')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user