web: keep one chat clock across streaming re-renders

Every streamed delta re-rendered the conversation and restarted the indicator's
one-second ticker, so a busy turn cleared the timer before it fired and the chat
sat at "Thinking… · 0s" for the whole turn. The ticker is now kept while a turn
is in flight; a simulated silent turn ticks 0s→4s and clears on step end.
This commit is contained in:
2026-10-20 00:24:05 +01:00
parent 5bb96cd4dc
commit ca28d08269
+11 -6
View File
@@ -3210,16 +3210,21 @@ function updateChatJump(el) {
* per-tool `· long` marks in place (never a full re-render).
*/
function refreshChatClock() {
stopChatClock();
chatNow = Date.now();
const thread = state.chatActiveId ? state.chatThreads.get(state.chatActiveId) : null;
const awaiting = approvalCard(thread?.permission, thread?.permissionAnswer)?.actionable === true;
if (state.view === "chat" && thread?.running && !awaiting) {
chatClock = setInterval(() => {
chatNow = Date.now();
updateChatIndicator(chatNow);
}, 1000);
if (state.view !== "chat" || !thread?.running || awaiting) {
stopChatClock();
return;
}
// Keep the one ticker. A streaming turn re-renders on every delta, and a clock
// restarted on each render would be cleared before its first second elapsed, so
// the indicator's elapsed time sat at 0s for the whole turn.
if (chatClock) return;
chatClock = setInterval(() => {
chatNow = Date.now();
updateChatIndicator(chatNow);
}, 1000);
}
function stopChatClock() {