fix(chat): hydrate restored session model on boot

This commit is contained in:
ai-ag2026
2026-05-22 08:29:34 +02:00
committed by nesquena-hermes
parent 6bcc9689aa
commit 765e5aa091
2 changed files with 18 additions and 0 deletions
+6
View File
@@ -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.
@@ -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