fix: restore thinking mode from personalization when session reset

This commit is contained in:
JOJO 2026-01-02 15:00:49 +08:00
parent f8683e8ebc
commit 77959226dd

View File

@ -686,7 +686,19 @@ def get_user_resources(username: Optional[str] = None) -> Tuple[Optional[WebTerm
run_mode = session.get('run_mode')
thinking_mode_flag = session.get('thinking_mode')
if run_mode not in {"fast", "thinking", "deep"}:
if thinking_mode_flag:
preferred_run_mode = None
try:
personal_config = load_personalization_config(workspace.data_dir)
candidate_mode = (personal_config or {}).get('default_run_mode')
if isinstance(candidate_mode, str) and candidate_mode.lower() in {"fast", "thinking", "deep"}:
preferred_run_mode = candidate_mode.lower()
except Exception as exc:
debug_log(f"[UserInit] 加载个性化偏好失败: {exc}")
if preferred_run_mode:
run_mode = preferred_run_mode
thinking_mode_flag = preferred_run_mode != "fast"
elif thinking_mode_flag:
run_mode = "deep"
else:
run_mode = "fast"