From f16d7e6f8ff1436cbe4698cc2d00a6b64ec6e914 Mon Sep 17 00:00:00 2001 From: Nathan Esquenazi Date: Mon, 6 Jul 2026 19:41:04 -0700 Subject: [PATCH] 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. --- static/sessions.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/static/sessions.js b/static/sessions.js index 821b0e4fe..641577a7a 100644 --- a/static/sessions.js +++ b/static/sessions.js @@ -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);