修复: 切会话残片覆盖回复与收尾工具卡丢失
- flushCurrentText 加非流式守卫,非流式只清不写 - 后台会话终止即清流式态,残片不跨轮引爆 - 异常收尾尾部工具气泡折进轨迹卡不再蒸发 - 停止与看门狗超时先保文再复位
This commit is contained in:
@@ -382,6 +382,7 @@ export const switchingConvs = new Set<string>()
|
||||
// 本模块函数运行时惰性取最新 state。
|
||||
export interface AiStateShape {
|
||||
currentText: string
|
||||
streaming: boolean
|
||||
messages: AiMessage[]
|
||||
activeConversationId: string | null
|
||||
}
|
||||
@@ -434,6 +435,15 @@ export function flushCurrentText(): void {
|
||||
resetDelta()
|
||||
return
|
||||
}
|
||||
// 非流式守卫:currentText 仅在流式进行中有意义。终态收尾后的迟到 delta、后台会话
|
||||
// 完成后切回残留的缓冲,都会让 streaming=false 时 currentText 仍非空;此刻回填会把
|
||||
// 上一轮已完成回复整条覆盖为残片(用户实测「空白内容覆盖了之前一大堆内容」),
|
||||
// 故非流式一律只清不写。合法回填点(收尾/新轮/停止/超时)均在 streaming 翻 false 前调用。
|
||||
if (!s.streaming) {
|
||||
s.currentText = ''
|
||||
resetDelta()
|
||||
return
|
||||
}
|
||||
// 从末尾向前找最后一个非 isError assistant 气泡写入(跳过重试错误气泡,保留部分回复)
|
||||
for (let i = s.messages.length - 1; i >= 0; i--) {
|
||||
const m = s.messages[i]
|
||||
|
||||
Reference in New Issue
Block a user