mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 07:00:26 +08:00
The paths underneath the providers. A batch upload that stalled every other
request, a knowledge-base list that rescanned every index, a tool call
dispatched with no arguments and retried until the budget ran out — plus two
things that were quietly missing.
- Every account can sign in to its own Codex. The token authorizes one
person's ChatGPT plan so the profile was correctly never grantable, but the
OAuth endpoints were admin-only too, leaving ordinary users no route at all.
A sign-in now publishes into the OWNER's catalog
(data/users/<uid>/settings/model_catalog.json), keyed by the same owner
resolution as the credential store; redacted_model_access gains those
personal rows for the caller's own id only, so the option list, capability
gate and selection validation cannot disagree. Partners are refused.
- Model output language is its own setting. Settings -> Appearance carries two
independent toggles; resolve_languages() in interface_settings.py owns the
legacy migration (a pre-split file inherits its single `language` into both),
and both readers go through it. GET /settings/ui is public so /login and
/register can bootstrap before a session, projected down to theme+language.
- A tool call with empty `arguments` is rejected in front of dispatch instead
of run. The tool used to do the rejecting ("requires a non-empty command",
"Unknown mode ''"), which does not read as a missing argument, so the model
re-emitted the same call until the loop budget ran out. The guard names the
missing arguments and their accepted values, enums included.
- Batch uploads move off the event loop (the chunked write, zip extraction and
per-file PocketBase upload ran inline; the staging pass sat in an async
BackgroundTasks entry, which starlette awaits ON the loop). KB listing reuses
one reconciled snapshot instead of reloading config and rescanning every
index per item.
- Deep Research mounts the read-only Obsidian tools instead of rag for a linked
vault, injects the vault path server-side, and treats their evidence as
citable.
- The server-side backend address is the IPv4 loopback on all three paths
(launcher, Docker entrypoint, web/proxy.ts default): `localhost` resolves to
::1 first on a dual-stack host while uvicorn binds 0.0.0.0.
- Escape stops a streaming Partner reply and bails while any dialog overlay is
mounted; vision overrides match `claude-` by vendor prefix and recognize Kimi
K3 and Qwen3.8-Max; Codex context-window metadata survives the catalog round
trip; editing a message no longer races its refresh; the deeptutor-cli wheel
ships the agents' prompt YAML again and prompt misses are no longer cached.
Also fixes the `ruff format --check` failure red on dev since 6cd55939, and
syncs the README prose, all ten translations, and the release-notes archive.
60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
"""M1 regression — interface_settings.py must resolve per-user, not at import."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from deeptutor.services.settings.interface_settings import (
|
|
get_response_language,
|
|
get_ui_language,
|
|
get_ui_settings,
|
|
)
|
|
|
|
|
|
def test_get_ui_language_reads_per_user_interface_json(mu_isolated_root, as_user):
|
|
# Admin's interface.json says English…
|
|
admin_settings = mu_isolated_root / "data" / "user" / "settings" / "interface.json"
|
|
admin_settings.parent.mkdir(parents=True, exist_ok=True)
|
|
admin_settings.write_text(json.dumps({"theme": "light", "language": "en"}))
|
|
|
|
# …while alice has chosen Chinese in her own scope.
|
|
alice_settings = (
|
|
mu_isolated_root / "data" / "users" / "u_alice" / "user" / "settings" / "interface.json"
|
|
)
|
|
alice_settings.parent.mkdir(parents=True, exist_ok=True)
|
|
alice_settings.write_text(json.dumps({"theme": "dark", "language": "zh"}))
|
|
|
|
with as_user("u_admin", role="admin"):
|
|
assert get_ui_language() == "en"
|
|
assert get_ui_settings()["theme"] == "light"
|
|
|
|
with as_user("u_alice", role="user"):
|
|
assert get_ui_language() == "zh"
|
|
assert get_ui_settings()["theme"] == "dark"
|
|
|
|
|
|
def test_get_ui_language_defaults_when_no_file(mu_isolated_root, as_user):
|
|
with as_user("u_alice", role="user"):
|
|
# Bob has nothing on disk yet — falls back to the default "en".
|
|
assert get_ui_language() == "en"
|
|
|
|
|
|
def test_response_language_is_scoped_independently_per_user(mu_isolated_root, as_user):
|
|
admin_settings = mu_isolated_root / "data" / "user" / "settings" / "interface.json"
|
|
admin_settings.parent.mkdir(parents=True, exist_ok=True)
|
|
admin_settings.write_text(json.dumps({"language": "en", "response_language": "zh"}))
|
|
|
|
alice_settings = (
|
|
mu_isolated_root / "data" / "users" / "u_alice" / "user" / "settings" / "interface.json"
|
|
)
|
|
alice_settings.parent.mkdir(parents=True, exist_ok=True)
|
|
alice_settings.write_text(json.dumps({"language": "zh", "response_language": "en"}))
|
|
|
|
with as_user("u_admin", role="admin"):
|
|
assert get_ui_language() == "en"
|
|
assert get_response_language() == "zh"
|
|
|
|
with as_user("u_alice", role="user"):
|
|
assert get_ui_language() == "zh"
|
|
assert get_response_language() == "en"
|