Complete full-stack activation of Traditional Chinese (zh-tw) on top of #3064 and #3065:
- Review and refine 683 app.json entries and 9 common.json entries in web/locales/zh-tw/ for Taiwan Traditional Chinese terminology (fixing OpenCC s2twp artifacts and mainland variants such as 許可權→權限, 賬號/賬戶→帳號/帳戶, 回撥→回呼, 自定義→自訂, 閘道器→閘道, 例項→實例, 只讀→唯讀, 憑據→憑證, 服務端→伺服器端, 配置檔案→設定檔, 地址→位址, 埠→連接埠, 映象→映像/鏡像, and curly quotes→「」) while keeping every key, placeholder, code span, and URL intact.
- Add language.chinese_traditional ("繁體中文") across all 14 web locale catalogs (and portuguese_unchanged_ui.json).
- Register zh-tw in web/i18n/languages.ts (preserving zh-tw/zh-hk/zh-mo/zh-hant before zh), dynamic loader web/i18n/init.ts, and web/lib/datetime.ts (zh-TW).
- Add complete Traditional Chinese Desktop shell copy in apps/desktop/src/i18n.mjs and register zh-tw in apps/desktop/src/main.mjs with zh-tw/zh-hant normalization.
- Wire zh-tw into backend deterministic copy and settings: settings_spec.py, runtime/banner.py, services/i18n.py, book/overview_copy.py, book/export.py, book/language.py, api/routers/quiz_judge.py (+ router_index.json), and zh-hk/zh-mo/zh-hant/繁體中文 handling in interface_languages.py and interface_settings.py (_normalize_response_language).
- Add full-stack regression coverage in tests/i18n/test_traditional_chinese_locale.py, apps/desktop/test/i18n.test.mjs, web/tests/language-preferences.test.ts, web/tests/account-role.test.ts, and tests/book/test_overview_copy.py.
Related to #2933
Related to #684
* feat(workspace): manage workspace files from the web UI behind an explicit grant
Files inside a workspace (question banks, notes, source material) could only
be placed there over SSH/scp, which locks non-technical users out of the very
folder the app is built around. This adds a file manager to
Settings -> Personal -> Workspace: browse, create folders, upload, rename, and
soft-delete, with a trash view to restore.
The write path is deliberately narrow, because a workspace folder also holds
DeepTutor's own state:
* ``ContentWorkspaceService.resolve(write=True)`` already confined writes to
``outputs/`` and demanded "an explicit user grant" for anything else. That
sentence had no implementation; this adds it rather than widening the rule.
``file_grants`` records one grant per workspace id in the caller's own
account settings tree, so granting one folder never opens another.
* ``.deeptutor/`` (session store, learning progress, caches), ``skills/`` and
SQLite files are refused for reads and writes alike. The tree holds data
whose loss is not "file management".
* Deletes move entries into ``.deeptutor/trash/<batch>/`` keeping their
relative path, so a mis-click on a question bank is reversible without shell
access. Oldest batches are pruned past 30.
* Uploads are bounded at 50 MB and names are validated for separators,
reserved names and the protected extensions.
* Every mutating service call re-checks the grant itself. The router check is
defence in depth, not the only gate: a future caller that imports ``files``
directly cannot skip it.
The router is mounted from ``server.json`` with ``auth: "admin"``, so the
module loader's ``require_admin`` policy covers every endpoint. A learner
account, or a workspace id belonging to another account, cannot reach it:
``binding_by_id`` re-derives the id from the caller's own bindings.
A missing grant now answers 403 with the prompt the UI needs. Without that
translation FastAPI turned the synchronous ``FileGrantError`` into a 500 and
the panel could not tell "grant this workspace" from a real fault.
Front end: a ``WorkspaceFileManager`` dialog (file list, breadcrumb, upload,
rename, trash/restore, Markdown preview) plus a client in
``lib/workspace-files-api.ts``. Strings go through ``t()`` with en/zh entries;
the panel is reachable from the workspace row in settings.
Tests: 16 service-level cases over grant scoping, path confinement, protected
paths, upload limits and the trash round trip; 3 router cases covering the
manifest's admin policy, the full create/upload/rename/trash/restore cycle and
the 403 mapping; 5 client cases for URL shape, verbs and error surfacing.
Verified locally: pytest 19 passed, ruff clean, tsc clean, eslint clean,
i18n parity OK, dependency-cruiser clean, vitest 5 passed.
* fix(workspace): root uploads, folder-aware trash, bounded uploads
Reviewing the file manager against real use surfaced four correctness bugs
that the original 19 tests missed because they never exercised the root
destination or a deleted folder.
Root destination (#1). ``_normalise_relative`` rejects ``"."`` because a
workspace-relative *file* path may never be empty, but the workspace root is a
legitimate *destination directory* — it is the default upload target and the
default restore target. Both went through the same normalisation and failed
with "cannot leave the workspace" (HTTP 400) on the root. ``_resolve_target_dir``
handles ``""``/``"."`` as the root and leaves every other path on the existing
guard; ``create_folder``/``rename_entry``/``trash_entry`` keep rejecting ``"."``
because those name an entry, not a directory to write into.
Trash structure (#2). Deleting a folder used to scatter its children into
``files/<relative path>`` while ``rglob`` skipped the directory rows, so an
empty folder vanished from the trash entirely and restoring a child of a
deleted folder failed with "The restore folder does not exist." Each delete now
gets its own slot: ``<batch>/entries/<uuid>/<name>`` plus a ``manifest.json``
holding ``original``, so a folder is one restorable row and comes back whole. A
parent removed by the same delete is recreated on restore.
Restore names (#3). With slots carrying identity the trash never appends
``.1``/``.2`` any more, so ``_strip_collision_suffix`` only did harm: a file
legitimately named ``report.1`` or ``v1.10`` came back as ``report`` or ``v1``.
Removed; the recorded name is restored verbatim.
Uploads (#4). The route read the whole body with ``file.read()`` before
``save_upload`` checked the 50 MB cap, so a multi-GB upload would exhaust memory
first. It now streams in 1 MB chunks and answers 413 as soon as the limit is
passed, with an early check on the declared size.
Also: preview now refuses database suffixes like the listing and the write
paths do; ``trash_entry`` no longer resolves a symlink before moving it, so a
link is trashed as a link instead of taking its target with it.
Tests: 19 -> 37. New cases cover root upload/restore, empty and non-empty
folder round trips, parent recreation, same-name entries in one batch, and
names that merely look like collision suffixes.
* fix(workspace): adapt the panel to the slot contract, i18n and input polish
Companion to the backend fix in this same PR. This cannot ship on its own:
the restore contract moved from ``{batch, name, destination, trashed_path}``
to ``{batch, slot, destination}`` and ``list_trash`` now returns one row per
delete operation, so the previously committed client would break the trash
view against the new server.
Contract adaptation:
* ``workspace-files-api.ts`` — ``WorkspaceTrashItem`` carries ``slot``,
``restoreWorkspaceEntry`` posts ``{batch, slot, destination}``. An empty
destination means "put it back where it came from".
* ``WorkspaceFileManager`` — the restore action passes the slot, and the row
key uses ``${batch}:${item.slot}``. The old ``${batch}:${item.name}``
collided when two same-named files from different folders were deleted within
the same second.
Experience fixes:
* Notices went through ``t()`` with en/zh entries. Nine ``setNotice`` calls were
hard-coded English, so a Chinese UI still showed "Created …", "moved to
trash", and so on.
* Preview opens ``.MD``/``.TXT`` too — the suffix test was case-sensitive.
* The new-folder and rename inputs submit on Enter, matching every other dialog
in the app.
* ``Dialog`` gained an optional ``closeTooltip`` (default ``true``) so a dialog
whose close control sits next to other labelled controls can drop the hover
bubble. All four file-manager dialogs turn it off; every other dialog in the
app is untouched.
Also wraps the four dialogs in a fragment: the grant, new-folder and rename
modals were nested inside the manager's children, which trapped their backdrop
and stacked two modals at once when an ungranted write opened the grant prompt.
Those actions now close their own dialog before requesting the grant.
* chore(contracts): regenerate the frontend OpenAPI contract
The `export_frontend_contracts.py --check` job compares
`web/contracts/schema/openapi.json` against what the FastAPI app renders, so
adding a router without regenerating the artifact fails CI.
Regenerated with the documented command:
python scripts/export_frontend_contracts.py
A deep comparison of the two documents before and after reports 13 differing
leaves, all of them additions: eight `/api/settings/workspace/files*` paths and
five request-body schemas (CreateFolderBody, DeleteBody, RenameBody,
RestoreBody, and the upload multipart body). Nothing was removed or modified;
the large line delta is the JSON being re-serialised with sorted keys.
* chore(contracts): regenerate the generated TypeScript API types
`npm run contracts:check` diffs `web/contracts/generated/api.ts` against a fresh
run of openapi-typescript, so the regenerated schema alone leaves this artifact
stale and fails the check.
Regenerated with:
npm run contracts:generate
Pure addition: +611 lines, no deletions. It exposes the eight
`/api/settings/workspace/files*` operations and the five request-body types.
* i18n: translate the file-manager copy into all eleven other locales
The English catalog is the source of truth and every first-class locale is
expected to have no missing keys, so a feature that adds 25 keys to `en` and
`zh` leaves ten locales falling back to English. Recent feature commits update
every locale in the same change for this reason.
Translated the 25 file-manager keys into de, fr, hu, it, ja, ko, pl, pt, tr,
uk and vi, inserted at the same position as in the English catalog. Missing
keys per locale drop from 25 to 0; `npm run i18n:check` passes.
* fix(workspace): resume the upload after a first grant and ask before overwriting
Two upload defects found in browser verification.
**The selected file was lost when the grant was pending.** Choosing a file in a
workspace without a grant opened the grant dialog and stashed the action, but
the handler cleared the file input before `withGrant` ran. By the time the user
approved, the `FileList` was empty, so nothing was sent and the file had to be
picked again. The handler now snapshots the files into a plain array and resets
the input up front, and the confirm dialog no longer closes on Escape while a
pending action would be dropped with it.
**A same-named upload replaced the file without asking.** The client always
posted overwrite, and the service always wrote through. Uploads now default to
`overwrite=false` and the service creates the target exclusively, so a conflict
is reported even when the browser's listing is stale rather than being detected
by a racy pre-check. A conflict surfaces as 409 and the panel asks before
retrying with `overwrite=true`; declining keeps the original file and the rest
of the batch continues.
Also adds `UploadConflictBody` to the contract, the `Replace the existing file
"{{name}}"?` key in all thirteen locales, and tests: a router test asserting the
file survives a 409 and is replaced on the retry, an API-client test for the
overwrite flag and conflict error, and a component test covering both the
resumed upload and the declined/accepted replacement paths.
* chore(api): regenerate the router index for the workspace files router
`tests/api/test_router_loader.py::test_repository_index_matches_router_sources`
asserts that `deeptutor/api/router_index.json` carries the fingerprint of the
current router sources. Registering `workspace_files:router` in the module
manifest changed that fingerprint without regenerating the index, so the
assertion failed on every Python leg:
AssertionError: Run scripts/build_router_index.py
assert '89681f8f...' == 'cb9ea964...'
Regenerated with `python scripts/build_router_index.py` (56 routers, 742
routes). The diff is the fingerprint plus the eleven `/api/settings/workspace/
files*` operations; no existing entry changed.
---------
Co-authored-by: Qiuner <wdst3635@163.com>
* fix(i18n): accept Korean as a backend interface language
The web picker offers Korean (added in #2359), but the backend UiLanguage
contract, its normalizers and the settings spec never learned "ko". Choosing
Korean and applying settings therefore fails with HTTP 422 on
PUT /api/settings/ui, and the saved language falls back to English on the
next load.
Register "ko" in the same seams Japanese used in #2213: UiLanguage and
_normalize_language() in interface_settings.py, the launch-settings
normalizer, and _LANGUAGE_CHOICES in settings_spec.py, then regenerate the
frontend API contracts. Add Korean to the existing router and launch-settings
tests, and add a registry test that fails whenever a web APP_LANGUAGES code
is missing from the backend contract.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* style: apply ruff format
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(rag): support local rerankers for LightRAG queries
Allow administrators to select a cross-encoder alongside the native LightRAG role models. Run scoring in a reusable worker and partition cached answers by reranker so model changes take effect on existing indexes.
Refs #2701
* fix(api): refresh the router index for LightRAG settings
* fix(rag): run LightRAG reranking in the shared reranker worker
anyio's process pool re-runs the server's __main__ file by path. When the
backend runs as `python -m deeptutor_cli.main serve` (the desktop app),
that file's relative imports fail, so every rerank call failed with
'Error during worker process initialization' and LightRAG silently kept
the original chunk order. Reuse the python -m reranker worker that the
LlamaIndex pipeline already uses.
---------
Co-authored-by: lipeih <lipeihan@eazytec.com>
Co-authored-by: zszz3 <zszz3@users.noreply.github.com>
Persian can now be chosen as the language the model replies in, reusing
the same response-language seam that ar/ru/es/ms/hi already use: the
shared SUPPORTED_RESPONSE_LANGUAGES set, the settings router Literal,
the prompt language directive, the normalize aliases, and the web
response-language options/union.
This is reply-only: the UI locale stays English, and no Persian
translation pack or RTL dashboard is introduced. That broader
localization is a separate, design-level follow-up.
Regenerated the contracts (openapi.json + api.ts) to reflect the router
enum change so contracts:check stays green.
Combine Hungarian with Italian UI and Hindi reply-language registries; translate 49 newly integrated keys and add the Hungarian endonym to Italian. Regenerate router and frontend contracts. 33 Python locale tests, full Node suite and locale parity pass.
Make Italian quality tests compatible with CommonJS Node test compiler; accept Italiano as reply-language alias; translate 48 keys added by other integrated PRs; regenerate router index and format i18n. 26 Python locale tests and full Node suite pass.
Carry the #958 service-layer reasoning_effort override through the whole
turn contract: the core TurnRequest LLMSelection accepts the field
(validated against VALID_REASONING_EFFORTS, old two-ID payloads unchanged),
the generated web contracts are regenerated, and ChatStateAdapter's
asLLMSelection restores a legal override instead of dropping it.
The composer gains a selector beside the model picker, offering only the
levels the selected model supports (live supported_reasoning_efforts or
the provider/model tables) narrowed to the wire vocabulary, hidden when
the model has none. The choice persists on the conversation's
llm_selection, so the next send uses it without a backend restart and
other conversations are unaffected; switching models resets the override.
Precedence stays conversation override -> profile/model default ->
provider default, and the context-budget readout reports the effective
effort beside the model when one was used.
Addresses Air R1/R2 review blockers on top of the opened PR head:
Settings GET/PUT /api/settings/web-fetch with UI control; DeepSeek fetch
uses identity encoding, raw bytes, and capacity checks before buffer extend;
provider-branding treats `local` as generic.
Air Codex R3 on MacBook Air: READY.
Add Hindi (hi, हिन्दी) to the reply-language contract, following step 4
of docs-for-dev/I18N.md and the earlier Malay change (550268e1):
- SUPPORTED_RESPONSE_LANGUAGES, the settings router's ResponseLanguage,
the prompt-language label and the settings-spec reply choices;
- "hindi", "हिन्दी" and "हिंदी" aliases in the backend and web
normalizers (hi-IN and hi_IN resolve through the base code);
- the web ResponseLanguage type, isResponseLanguage() and
RESPONSE_LANGUAGE_OPTIONS, which the partner picker shares;
- regenerated frontend contracts, and tests mirroring the Malay change.
The interface language is unchanged: no web catalog or picker entry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds a complete Hungarian (hu) locale alongside the existing catalogs, wired
through every seam a language has to pass so none of them silently serves
English to a Hungarian reader.
Frontend: the hu catalog covers all 6,584 English keys with matching
interpolation placeholders, registered in the locale registry, the lazy bundle
loader, Intl date/number formatting (hu-HU) and the reply-language picker.
`language.hungarian` ("Magyar") is added to every existing catalog so the
endonym is shown whatever the current interface language is.
Backend: "hu" is accepted by the launch, interface and reply-language
normalizers and offered in both settings choice lists, named in the prompt
language labels, and carries the Hungarian copy of the CLI-app, MCP and
sandbox messages, the quiz-judge prompt, the book export labels, the book
overview front page and the voice language list.
Scope: the CLI installer banner (`deeptutor/runtime/banner.py`) keeps its
English text for hu and falls back through `_pick_language`; it is terminal
setup copy unused in server deployments and is left for a follow-up.
Evidence:
- `python -m pytest tests/i18n/test_hungarian_locale.py` — 33 passed
- `npm run test:node` — 1353 passed (adds hungarian-locale-quality.test.ts)
- `npm run typecheck` — clean
- `node scripts/i18n_parity.mjs` — OK
- `node scripts/i18n_audit.mjs` — hu: 4529/4529 used keys (100.0%), strict
- `node scripts/generate-contracts.mjs --check` — no drift
- `ruff format --check` / `ruff check` on the touched Python files — clean
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a complete Japanese web catalog (web/locales/ja/app.json, every key
of the English catalog) and register "ja" wherever the other interface
languages are listed: the web language registry and loader, date
formatting, the backend UI-language setting and launch settings, and the
generated API contracts. Each existing catalog gains language.japanese.
Japanese was already a reply language; this makes it an interface
language too, following the Polish integration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quoted_message_id now follows the create_target rule: the key's presence
is authoritative. A value moves the thread, an explicit null clears it,
and omitting the key leaves the stored anchor untouched. A new selection
moves the thread to the passage just asked about.
The message-level popover gains a detach action that clears the anchor
through the organization PATCH without deleting the conversation, and a
deliberate clear also stops the legacy backfill from re-attaching it.
After each reply the chat composer shows a predicted next line as its
placeholder, and Tab accepts it. When the assistant has just asked a
question, such as a quiz in chat, the likeliest next line is the answer,
so the hint gives it away. There was no way to turn it off.
Add an `ask_hint_enabled` switch to the per-user starter settings
(Settings -> Conversation -> Composer), on by default. When it is off,
`get_ask_hint` returns an empty hint before reading the session or the
cache, so no LLM call is made and no line cached while it was on leaks
through.
A PUT that omits the field keeps the stored value, so an older client or
a settings draft saved before this change cannot turn the hint back on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Registers tr in every list that decides which languages exist: the reply-language whitelist and labels, the interface and launcher normalizers, the Settings choices, the web registry and lazy loader, the date locale, the response-language store and the API contract.
The first visit stored the detected palette and never listened for
prefers-color-scheme changes, so the theme stopped tracking the OS and
Settings had no System choice.
Do not write that fallback. Subscribe while the preference is missing or
"system", and add a System option in Appearance. New accounts default to
system so Apply does not freeze the snow palette.
Add a tab-separated Anki import from a note page and from the review
queue so learners can File -> Import cards into a deck named after the
note. Re-importing uses stable card GUIDs and does not include review
scheduling.