重构部分会话消息处理逻辑,优化会话消息渲染

This commit is contained in:
xintaofei
2026-03-10 23:24:27 +08:00
parent a048a4cae2
commit 380f430d5a
15 changed files with 92 additions and 568 deletions

View File

@@ -306,6 +306,22 @@ function reducer(
const current =
state.byConversationId.get(action.conversationId) ??
createEmptySession(action.conversationId)
// Guard: prevent stale liveMessage from ACP reconnects overriding
// persisted data. When a session has no active liveMessage and no
// pending interaction (idle or reconciling without a live turn),
// a SET_LIVE_MESSAGE from a reconnected ACP connection carries
// the completed response that is already in persistedTurns.
// Accepting it would cause duplicate assistant text in the timeline.
if (
action.liveMessage !== null &&
current.liveMessage === null &&
current.syncState !== "awaiting_persist" &&
current.persistedTurns.length > 0
) {
return state
}
const nextSession: ConversationRuntimeSession = {
...current,
liveMessage: action.liveMessage,