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:
+11
-6
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user