fix: honor personalized default run mode
This commit is contained in:
parent
8cc3a24abf
commit
c1e9f33208
@ -366,7 +366,10 @@ def get_user_resources(username: Optional[str] = None) -> Tuple[Optional[WebTerm
|
|||||||
run_mode = session.get('run_mode')
|
run_mode = session.get('run_mode')
|
||||||
thinking_mode_flag = session.get('thinking_mode')
|
thinking_mode_flag = session.get('thinking_mode')
|
||||||
if run_mode not in {"fast", "thinking", "deep"}:
|
if run_mode not in {"fast", "thinking", "deep"}:
|
||||||
run_mode = "thinking" if thinking_mode_flag else "fast"
|
if thinking_mode_flag:
|
||||||
|
run_mode = "deep"
|
||||||
|
else:
|
||||||
|
run_mode = "fast"
|
||||||
thinking_mode = run_mode != "fast"
|
thinking_mode = run_mode != "fast"
|
||||||
terminal = WebTerminal(
|
terminal = WebTerminal(
|
||||||
project_path=str(workspace.project_path),
|
project_path=str(workspace.project_path),
|
||||||
@ -382,6 +385,8 @@ def get_user_resources(username: Optional[str] = None) -> Tuple[Optional[WebTerm
|
|||||||
user_terminals[username] = terminal
|
user_terminals[username] = terminal
|
||||||
terminal.username = username
|
terminal.username = username
|
||||||
terminal.quota_update_callback = lambda metric=None: emit_user_quota_update(username)
|
terminal.quota_update_callback = lambda metric=None: emit_user_quota_update(username)
|
||||||
|
session['run_mode'] = terminal.run_mode
|
||||||
|
session['thinking_mode'] = terminal.thinking_mode
|
||||||
else:
|
else:
|
||||||
terminal.update_container_session(container_handle)
|
terminal.update_container_session(container_handle)
|
||||||
attach_user_broadcast(terminal, username)
|
attach_user_broadcast(terminal, username)
|
||||||
@ -799,14 +804,28 @@ def login():
|
|||||||
status_code = 429
|
status_code = 429
|
||||||
return jsonify(error_payload), status_code
|
return jsonify(error_payload), status_code
|
||||||
|
|
||||||
|
workspace = user_manager.ensure_user_workspace(record.username)
|
||||||
|
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):
|
||||||
|
normalized_mode = candidate_mode.lower()
|
||||||
|
if normalized_mode in {"fast", "thinking", "deep"}:
|
||||||
|
preferred_run_mode = normalized_mode
|
||||||
|
except Exception as exc:
|
||||||
|
debug_log(f"加载个性化偏好失败: {exc}")
|
||||||
|
|
||||||
session['logged_in'] = True
|
session['logged_in'] = True
|
||||||
session['username'] = record.username
|
session['username'] = record.username
|
||||||
default_thinking = app.config.get('DEFAULT_THINKING_MODE', False)
|
default_thinking = app.config.get('DEFAULT_THINKING_MODE', False)
|
||||||
session['thinking_mode'] = default_thinking
|
session['thinking_mode'] = default_thinking
|
||||||
session['run_mode'] = app.config.get('DEFAULT_RUN_MODE', "thinking" if default_thinking else "fast")
|
session['run_mode'] = app.config.get('DEFAULT_RUN_MODE', "deep" if default_thinking else "fast")
|
||||||
|
if preferred_run_mode:
|
||||||
|
session['run_mode'] = preferred_run_mode
|
||||||
|
session['thinking_mode'] = preferred_run_mode != 'fast'
|
||||||
session.permanent = True
|
session.permanent = True
|
||||||
clear_failures("login", identifier=client_ip)
|
clear_failures("login", identifier=client_ip)
|
||||||
workspace = user_manager.ensure_user_workspace(record.username)
|
|
||||||
try:
|
try:
|
||||||
container_manager.ensure_container(record.username, str(workspace.project_path))
|
container_manager.ensure_container(record.username, str(workspace.project_path))
|
||||||
except RuntimeError as exc:
|
except RuntimeError as exc:
|
||||||
@ -1093,6 +1112,26 @@ def update_personalization_settings(terminal: WebTerminal, workspace: UserWorksp
|
|||||||
config = save_personalization_config(workspace.data_dir, payload)
|
config = save_personalization_config(workspace.data_dir, payload)
|
||||||
try:
|
try:
|
||||||
terminal.apply_personalization_preferences(config)
|
terminal.apply_personalization_preferences(config)
|
||||||
|
session['run_mode'] = terminal.run_mode
|
||||||
|
session['thinking_mode'] = terminal.thinking_mode
|
||||||
|
ctx = getattr(terminal, 'context_manager', None)
|
||||||
|
if ctx and getattr(ctx, 'current_conversation_id', None):
|
||||||
|
try:
|
||||||
|
ctx.conversation_manager.save_conversation(
|
||||||
|
conversation_id=ctx.current_conversation_id,
|
||||||
|
messages=ctx.conversation_history,
|
||||||
|
project_path=str(ctx.project_path),
|
||||||
|
todo_list=ctx.todo_list,
|
||||||
|
thinking_mode=terminal.thinking_mode,
|
||||||
|
run_mode=terminal.run_mode
|
||||||
|
)
|
||||||
|
except Exception as meta_exc:
|
||||||
|
debug_log(f"应用个性化偏好失败: 同步对话元数据异常 {meta_exc}")
|
||||||
|
try:
|
||||||
|
status = terminal.get_status()
|
||||||
|
socketio.emit('status_update', status, room=f"user_{username}")
|
||||||
|
except Exception as status_exc:
|
||||||
|
debug_log(f"广播个性化状态失败: {status_exc}")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
debug_log(f"应用个性化偏好失败: {exc}")
|
debug_log(f"应用个性化偏好失败: {exc}")
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user