feat(routing): ô định tuyến chỉ còn Auto và Manual

Bỏ hai chế độ Off và Fallback ở ô định tuyến cạnh khung chat và ở mục Định
tuyến trong Cài đặt. Mặc định chuyển sang Auto.

- USER_ROUTING_MODES = ("auto", "manual"); giá trị off/fallback/lạ còn lưu trong
  config hay project đều được hiểu là Auto (routing_mode_for,
  project_routing_mode, set_*). Engine vẫn hiểu "off" khi truyền mode_override
  tường minh.
- RoutingScheduler: định tuyến giờ luôn bật nên việc chấm điểm model định kỳ
  luôn chạy; muốn tắt thì đặt reassess_interval_hours = 0.
- Cập nhật các test đang ghim hành vi "mặc định off".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
minhanhpkpro
2026-09-25 14:40:05 +09:00
co-authored by Claude Opus 5.5
parent fefc9f94db
commit 0b6b220bd9
10 changed files with 126 additions and 67 deletions
+42
View File
@@ -0,0 +1,42 @@
"""Ô định tuyến chỉ còn Auto và Manual; giá trị off/fallback cũ hiện thành Auto."""
from __future__ import annotations
import os
import pytest
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
pytest.importorskip("PySide6")
@pytest.fixture(scope="module")
def qt_app():
from PySide6.QtWidgets import QApplication
return QApplication.instance() or QApplication([])
def _toggle(stored: str):
from cowork_local.ui.routing_toggle import RoutingToggle
saved = []
t = RoutingToggle(None, "cowork", get_mode=lambda: stored, set_mode=saved.append)
return t, saved
def test_only_auto_and_manual_are_offered(qt_app):
t, _ = _toggle("auto")
items = [t._combo.itemData(i) for i in range(t._combo.count())]
assert items == ["auto", "manual"]
@pytest.mark.parametrize("stored", ["off", "fallback", "", "turbo"])
def test_legacy_values_show_as_auto(qt_app, stored):
t, _ = _toggle(stored)
assert t.current_mode() == "auto"
def test_choosing_manual_persists_it(qt_app):
t, saved = _toggle("auto")
t._combo.setCurrentIndex(t._combo.findData("manual"))
assert saved == ["manual"]