The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): preserve bot composer selections on resume
Nagisa-3000865fea806181
diff --git a/tests/tui_gateway/test_tui_gateway_server.py b/tests/tui_gateway/test_tui_gateway_server.pyindex 20e06ba5c9e..d57f63adc84 100644--- a/tests/tui_gateway/test_tui_gateway_server.py+++ b/tests/tui_gateway/test_tui_gateway_server.py@@ -22860,3 +22860,26 @@ def test_named_profile_without_backend_stays_local_under_ssh_launch(monkeypatch,monkeypatch.setattr(server, "_profile_home", lambda name: home if name == "plain" else None)assert server._completion_cwd({"profile": "plain", "cwd": launch, "cwd_explicit": False}) == launch+++def test_session_create_records_bot_composer_profile_marker(monkeypatch):+ """A Bot Chat's initial composer pick records the profile default it diverged from."""+ monkeypatch.setattr(server, "_enable_gateway_prompts", lambda: None)+ monkeypatch.setattr(server, "_start_agent_build", lambda *a, **k: None)+ monkeypatch.setattr(server, "_config_model_target", lambda: ("profile/default", "nous"))+ try:+ resp = server._methods["session.create"](+ "bot-r1",+ {+ "cols": 80,+ "model": "zai/glm-5.1",+ "provider": "zai",+ "follow_profile_config": True,+ },+ )+ session = server._sessions[resp["result"]["session_id"]]+ assert session["follow_profile_config"] is True+ assert session["model_override"] == {"model": "zai/glm-5.1", "provider": "zai"}+ assert session["composer_override_profile"] == {"model": "profile/default", "provider": "nous"}+ finally:+ server._sessions.clear()diff --git a/tui_gateway/methods_session.py b/tui_gateway/methods_session.pyindex ba926978167..882dd0bcdea 100644--- a/tui_gateway/methods_session.py+++ b/tui_gateway/methods_session.py@@ -381,6 +381,15 @@ def _create_session(rid, params: dict, *, copy_parent_history: bool = False) ->explicit_cwd = bool(raw_cwd) and (remote_cwd or os.path.isdir(os.path.abspath(os.path.expanduser(raw_cwd))))_enable_gateway_prompts()session_model_override, create_reasoning_override, create_service_tier_override = _create_overrides(params)+ composer_override_profile = None+ if session_model_override and _flag(params, "follow_profile_config"):+ # A composer pick on a Bot Chat must remember the profile model it+ # diverged from. Without this marker, resume treats the row as an+ # unmarked profile-following chat and silently falls back to the+ # profile default instead of restoring the pick.+ with _profile_build_scope(profile_home):+ profile_model, profile_provider = _config_model_target()+ composer_override_profile = {"model": profile_model, "provider": profile_provider}now = time.time()with _sessions_lock:_sessions[sid] = {@@ -393,6 +402,7 @@ def _create_session(rid, params: dict, *, copy_parent_history: bool = False) ->"seeded": bool(history), # gates _persist_branch_seed: only create-time history is unpersisted"cwd": _completion_cwd(params), "inflight_turn": None, "last_active": now,"model_override": session_model_override,+ "composer_override_profile": composer_override_profile,"create_reasoning_override": create_reasoning_override,"create_service_tier_override": create_service_tier_override,"parent_session_id": parent_session_id, "pending_title": _str_param(params, "title") or None,