fix(desktop): keep model runtime state per session#43702
Merged
Conversation
added 5 commits
June 10, 2026 13:05
(cherry picked from commit f72ee87d99ee38cb7b5badeb9a8af869bb92073a)
(cherry picked from commit d91942ebd4671ff857b5c8526dbf133f04782ecb)
(cherry picked from commit 32b3793418257617b8da57e26151f079c2620d00)
(cherry picked from commit c58467779436dcef44a80ad55b52664752dc0837)
Contributor
🔎 Lint report:
|
The salvaged commits on this branch preserve @pinguarmy's authorship (郝鹏宇 / peterhao@Peters-MacBook-Air.local). Add the mapping so the check-attribution CI gate resolves the email to the GitHub username.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvages and supersedes #40163 (by @pinguarmy / 郝鹏宇). Cherry-picked onto current
mainwith authorship preserved; all review feedback from that thread was already addressed by the author's latest commits, verified here against a clean rebase.Summary
base_url+api_modeinmodel_configon resume (rawapi_keydeliberately not stored in the session DB).providerinsession.infoand emitsession.infoafter reasoning/fast/model changes.Root cause
Desktop had three stale-state paths:
session.resumerebuilt the backend agent from current global config rather than the stored session row, so an older chat whose DB row saidgpt-5.4+ high reasoning could resume as the latest globalgpt-5.5+ medium reasoning.Review feedback addressed (from #40163)
_apply_model_switchkeeps the two-arg_restart_slash_worker(sid, session)and adds_persist_live_session_runtime(session).use-session-state-cache.tsadds the per-session runtime setters alongside thesameMessageList(...)reference-equality guard, not in place of it.update_session_meta(..., model)DB write (update_session_modelonly as a legacy fallback).base_url/api_modepersisted/restored inmodel_config.session["model_override"]repopulated after a DB-restored resume so a later/newrebuilds from the same restored source of truth.Test plan
scripts/run_tests.sh tests/test_tui_gateway_server.py→ 255 passed, 1 failed. The failure (test_browser_manage_connect_default_local_reports_launch_hint) reproduces identically on cleanmainin this local macOS env (a Chromium browser is installed, so the "not found" hint never fires) and is unrelated to this diff.npm run typecheck --workspace apps/desktop→ passed.apps/desktopvitest:use-model-controls.test.tsx,model-status-label.test.ts,store/session.test.ts→ 24 passed.Closes #40163.