fix(review): keep the #5567 load-repair inside the #4490 source window

The call-site comment block in loadSession() pushed S._pendingSessionToolsets
=null past the 400-char window the #4490 guard asserts after
S.session=data.session (same static-guard class as the #4755/#5170 boot.js
incident). Move the repair call below the toolsets clear -- semantically
identical placement: _clearEmptyComposerModelOverride() only nulls a host
field and the toolsets line reads nothing from the session; the first
model_provider reader (populateModelDropdown / the send path) still runs
after the repair. Trim the call-site comment to a pointer at the full
rationale on _repairContaminatedSessionModelProvider in ui.js.

14/14 across the #4490 + #5567 guard families.
This commit is contained in:
Nathan Esquenazi
2026-07-06 19:41:04 -07:00
committed by t
parent 7e84137665
commit f16d7e6f8f
+4 -5
View File
@@ -1538,15 +1538,14 @@ async function loadSession(sid){
return loadSession(continuationSid,{...opts,skipLineageResolve:true,skipContinuationResolve:true,force:true});
}
S.session=data.session;
// #5567: repair a session whose stored model_provider was contaminated with a
// foreign provider (frontend tab/profile-switch race). Runs before the model
// dropdown / send path reads S.session.model_provider, so a poisoned session
// stops re-sending the wrong provider from its very next turn.
if(typeof _repairContaminatedSessionModelProvider==='function') _repairContaminatedSessionModelProvider(S.session);
if(typeof _clearEmptyComposerModelOverride==='function') _clearEmptyComposerModelOverride();
// Loading a real existing session abandons any pre-session toolset override
// staged on the empty composer before any deferred refresh work runs.
S._pendingSessionToolsets=null;
// #5567: drop a contaminated stored model_provider before the first reader
// (populateModelDropdown / the send path). Full rationale on
// _repairContaminatedSessionModelProvider in ui.js.
if(typeof _repairContaminatedSessionModelProvider==='function') _repairContaminatedSessionModelProvider(S.session);
if(typeof populateModelDropdown==='function'){
const modelRefreshSid=sid;
const isActiveModelRefreshSession=()=>!!(S.session&&S.session.session_id===modelRefreshSid);