修复: 主面板刷新后流式恢复(restoreGeneratingState 加 fromMainPanel 绕过 localStorage 快照)

This commit is contained in:
2026-06-17 18:52:46 +08:00
parent aa75454878
commit 3055b06734
2 changed files with 78 additions and 30 deletions

View File

@@ -2179,10 +2179,20 @@ onMounted(async () => {
})
// F-15 阶段2: 注册上下文管理事件监听器(清空/压缩生命周期事件 → toast/刷新)
await initContextEventListeners()
// 分离模式:接管主窗口当前对话(含生成中态),保持正在进行的对话
// 恢复生成中态(刷新后/分离窗口接管):
// - 分离模式(detached=true):resumeInDetached 接管主窗口当前对话
// - 主面板模式(detached=false):restoreGeneratingState 恢复主面板自身的生成态
// (UX-260617-13: 主面板刷新后无等价恢复链 → streaming=false + 无占位气泡 + 后端
// 事件不进流式分支,退化为非流式。现对齐 resumeInDetached 同款恢复链)。
// 两者互斥(detached 三元决定),不会双重恢复;restoreGeneratingState 内幂等守卫(state.streaming 已 true 则跳过)。
// 在 startListener(L0 ai-client-ready 握手)之后调用,握手仍先于恢复逻辑生效。
if (props.detached) {
const params = new URLSearchParams(location.hash.split('?')[1] || '')
await store.resumeInDetached(params.get('conv'))
} else {
// fromMainPanel=true: 主面板刷新无 df-ai-gen 快照(detachPanel 未触发),
// 用 activeConversationId + ai_is_generating 真值守卫恢复(绕过 localStorage 路径)
await store.restoreGeneratingState({ fromMainPanel: true })
}
console.debug(`[启动] AiChat IPC 完成: ${(performance.now() - t0).toFixed(0)}ms`)
})