web: fold background chat safely and harden notify mode
Limit live chat paints and history syncs to the open conversation; initialize the per-run notify map lazily.
This commit is contained in:
@@ -189,6 +189,9 @@ func (r *runner) setNotifyMode(id int64, mode string) {
|
||||
mode = "auto"
|
||||
}
|
||||
r.notifyMu.Lock()
|
||||
if r.notifyModes == nil {
|
||||
r.notifyModes = map[int64]string{}
|
||||
}
|
||||
r.notifyModes[id] = mode
|
||||
r.notifyMu.Unlock()
|
||||
}
|
||||
|
||||
@@ -765,7 +765,9 @@ function onChatEvent(frame) {
|
||||
// missed) appears without a manual refresh.
|
||||
const knownTurn = messageId !== "" && (thread.messages ?? []).some((m) => m?.id === messageId);
|
||||
state.chatThreads.set(sessionId, applyChatEvent(thread, frame, Date.now()));
|
||||
scheduleChatRender("transcript");
|
||||
if (state.view === "chat" && sessionId === state.chatActiveId) {
|
||||
scheduleChatRender("transcript");
|
||||
}
|
||||
if (!knownTurn) scheduleHistorySync(sessionId, messageId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user