fix(chat): preserve fresh compaction state across reconnect history
This commit is contained in:
@@ -1025,7 +1025,7 @@ async function resyncOpenChat() {
|
||||
const page = await repo.chatHistory(id);
|
||||
state.chatThreads.set(id, historyResync(state.chatThreads.get(id), page, { preserveActivity: true }));
|
||||
} catch {
|
||||
// The history refresh failed; the settled thread stands and the badge is honest.
|
||||
// Keep fresh replayed activity if any; otherwise the settled reset stands.
|
||||
}
|
||||
await loadChatShells(id);
|
||||
renderContent();
|
||||
@@ -1382,6 +1382,9 @@ function refreshChatComposerState(sessionId) {
|
||||
function onChatFrame(message) {
|
||||
const frame = message?.chat_event;
|
||||
if (!frame || !frame.session_id) return;
|
||||
// onChatEvent already folded this session activity with native identity
|
||||
// checks and refreshed the composer. Do not reapply an ignored stale start.
|
||||
if (frame.kind === "compaction") return;
|
||||
rt.touchView?.("chat");
|
||||
const sessionId = frame.session_id;
|
||||
const thread = state.chatThreads.get(sessionId);
|
||||
@@ -4330,7 +4333,8 @@ function updateChatIndicator(now) {
|
||||
}
|
||||
const phase = [...document.querySelectorAll("#chatTranscript .chat-activity-phase")].at(-1);
|
||||
if (phase) {
|
||||
phase.textContent = turnPhaseLabel(threadPhase(thread, now) ?? TURN_PHASE_WAITING);
|
||||
const label = turnPhaseLabel(threadPhase(thread, now) ?? TURN_PHASE_WAITING);
|
||||
if (phase.textContent !== label) phase.textContent = label;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user