-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Release v0.51.279 — Release IU (stage-p3h — preserve Activity/streaming turn on mid-stream scroll #3665) #3686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1545,6 +1545,9 @@ function _messageReloadLimitForSession(sid){ | |
|
|
||
| function _syncToolCallsForLoadedMessages(messages, sessionToolCalls){ | ||
| const msgs=Array.isArray(messages)?messages:[]; | ||
| // During active streaming, skip — clearing S.toolCalls would lose Activity | ||
| // and the renderMessages fallback is blocked by S.busy=true. | ||
| if(S.busy||S.activeStreamId) return; | ||
| const hasMessageToolMetadata=msgs.some(m=>{ | ||
| if(!m) return false; | ||
| const hasTc=Array.isArray(m.tool_calls)&&m.tool_calls.length>0; | ||
|
|
@@ -1587,7 +1590,13 @@ async function _ensureMessagesLoaded(sid) { | |
| // toast on every mobile message (SSE/visibility events trigger this reload path | ||
| // more aggressively on mobile). | ||
| let msgs = (data.session.messages || []).filter(m => m && m.role); | ||
| _syncToolCallsForLoadedMessages(msgs, data.session.tool_calls); | ||
| // Skip _syncToolCalls when INFLIGHT exists — the INFLIGHT restore path | ||
| // (loadSession line ~871) will overwrite S.toolCalls from INFLIGHT[sid].toolCalls. | ||
| // Clearing here and then overwriting is wasteful, and if S.busy becomes true | ||
| // before the next render, the fallback can't re-derive from messages. | ||
| if(!(typeof INFLIGHT !== 'undefined' && INFLIGHT && INFLIGHT[sid])){ | ||
| _syncToolCallsForLoadedMessages(msgs, data.session.tool_calls); | ||
| } | ||
| clearLiveToolCards(); | ||
| // #3018: preserve client-side ephemeral turn fields (_turnUsage, _turnDuration, | ||
| // _turnTps, _gatewayRouting, _statusCard) across the loadSession replace. | ||
|
|
@@ -1603,6 +1612,11 @@ async function _ensureMessagesLoaded(sid) { | |
| } | ||
| if(typeof clearVisibleMessageRowCache==='function') clearVisibleMessageRowCache(); | ||
| S.messages = msgs; | ||
| // Expand render window to cover all loaded messages so the next | ||
| // renderMessages() doesn't hide most of them behind a tiny window. | ||
| if(typeof _messageRenderableMessageCount==='function'&&typeof _currentMessageRenderWindowSize==='function'){ | ||
| _messageRenderWindowSize=Math.max(_currentMessageRenderWindowSize(), _messageRenderableMessageCount()); | ||
| } | ||
| if(S.session&&S.session.session_id===sid){ | ||
| S.session.message_count=Number(data.session.message_count || msgs.length); | ||
| S.lastUsage={...(data.session.last_usage||S.lastUsage||{})}; | ||
|
|
@@ -2967,6 +2981,10 @@ async function refreshActiveSessionIfExternallyUpdated(reason){ | |
| if(_activeSessionExternalRefreshInFlight) return; | ||
| if(!S.session || !S.session.session_id) return; | ||
| if(S.busy || S.activeStreamId) return; | ||
| // Cooldown: don't force-reload immediately after streaming ends — the | ||
| // "done" event already delivered the final messages. Reloading here would | ||
| // clear S.toolCalls and lose Activity. | ||
| if(typeof window !== 'undefined' && window._streamJustFinished) return; | ||
|
Comment on lines
+2984
to
+2987
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if(typeof document !== 'undefined' && document.hidden) return; | ||
| const sid = S.session.session_id; | ||
| const localCount = Number(S.session.message_count || (Array.isArray(S.messages)?S.messages.length:0) || 0); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dedup_key not in seen_dedup_keyssub-expression is alwaysTruehere. By line 4272, any message whosededup_keywas already inseen_dedup_keyshas already been skipped viacontinue, so the condition can never beFalsewhen execution reaches this point. The guard is harmless but misleading — a reader might assume it provides a meaningful second check. Simplifying to just_ck in seen_content_keysmakes the intent clearer.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!