diff --git a/static/boot.js b/static/boot.js index d041548c..2497df69 100644 --- a/static/boot.js +++ b/static/boot.js @@ -1654,6 +1654,12 @@ function applyBotName(){ return; } await loadSession(saved); + // Hard refresh starts from the static HTML model list. Hydrate the live + // catalog after the saved session is known, then re-apply that session's + // model before S._bootReady lets syncModelChip reveal the composer label. + // Otherwise the chip can display the static default (e.g. GPT-5.4 Mini) + // even though S.session already points at the Codex/current model. + if(S.session) await _startBootModelDropdown(); // If the restored session has no messages it is an ephemeral scratch pad — // treat the page as a fresh start rather than resuming a blank conversation. // loadSession() already ran, so loadDir() has populated the workspace file tree. diff --git a/tests/test_new_chat_default_model_frontend.py b/tests/test_new_chat_default_model_frontend.py index 121df78f..43e1bd32 100644 --- a/tests/test_new_chat_default_model_frontend.py +++ b/tests/test_new_chat_default_model_frontend.py @@ -56,6 +56,18 @@ def test_boot_model_hydration_prefers_active_session_over_persisted_model(): ) +def test_hard_refresh_hydrates_saved_session_model_before_revealing_model_chip(): + boot_js = Path("static/boot.js").read_text(encoding="utf-8") + load_marker = "await loadSession(saved);" + assert load_marker in boot_js + saved_restore = boot_js[boot_js.index(load_marker) : boot_js.index("await checkInflightOnBoot(saved);return;", boot_js.index(load_marker))] + assert "await _startBootModelDropdown();" in saved_restore + assert saved_restore.index("await _startBootModelDropdown();") > saved_restore.index(load_marker) + assert saved_restore.index("await _startBootModelDropdown();") < saved_restore.index("S._bootReady=true;"), ( + "hard refresh must hydrate/re-apply the active session model before S._bootReady lets syncModelChip display stale static HTML defaults" + ) + + def test_new_chat_does_not_send_stale_dropdown_model_when_session_has_default_model(): assert "model:S.session.model||$('modelSelect').value" in MESSAGES_JS assert "model_provider:S.session.model_provider||null" in MESSAGES_JS