Native LightRAG role models: extraction, keyword, query and vision each
resolve their own model, vision indexing pins a vision-capable model
instead of silently degrading, and a knowledge base records which models
and which embedding built it. A published index refuses queries after its
embedding identity changes rather than searching a foreign vector space,
and a rebuild is confirmed against the configuration it will actually
use — a stale confirmation is rejected instead of quietly rebuilding
something else. A failed publication is withdrawn, not left half-written.
PDF attachments follow the parsing engine configured for the workspace,
report the stage they are in, and a truncated answer says it was
truncated with the counters that prove it. Providers are no longer
filtered out of the embedding picker on an unverifiable capability guess:
configure the model and test it. Visualize's temperature and token budget
are settings rather than literals. Notebook evidence no longer depends on
the chat session that produced it.
See assets/releases/ver1-6-10.md for the full notes, and the README
translations for the propagated prose.
Rebased onto current main (v1.6.9 layout): _learning_surface_for_path now
lives in deeptutor/api/routers/auth.py; change content unchanged.
- map /api/mastery-paths/* to chat (learner's own per-user progress data)
- map GET/HEAD/OPTIONS /api/knowledge-bases* to reading (browse-only;
mutations still default-deny)
- pass request.method into the surface lookup
- put_guardian_restrictions: when the account has no learning_policy yet,
seed the default learner grant and flip the preset to learner, avoiding
the standard-preset+policy mix that renders the admin shell and 403-storms
- regression tests: tests/multi_user/test_learning_surface_map.py (22 tests)
Always strip dollar-sign math delimiters so the voice model never says dollar. When Math speak is on (default), also convert fractions, powers, Greek, and common operators into spoken words. Settings > Voice exposes the toggle; the server applies it on every /tts call.
Ship folder-based workspaces and data migration, daily practice, redesigned
provider and model settings, and streaming conversation improvements.
Synchronize README translations and document the archive/permanent-delete
upgrade behavior in assets/releases/ver1-6-9.md.
Reduce initial JavaScript by deduplicating English resources and loading
animation features after hydration. Keep the existing route size budgets.
Update regression fixtures and browser audits for scoped URLs and the new
settings and learning interfaces.
Route Mastery, Book, and Immersive Reading attempts through one review record so reading quizzes are server-graded, retryable, and show the learner's pick next to the reference answer.
Co-authored-by: Cursor <cursoragent@cursor.com>
A figure only reaches the model while its page is the open one: the viewport
injection carries at most four images, and read_material returns text. That
leaves a question spanning several pages of a deck (or several decks)
answered without ever seeing the figures it is about.
Ingest can now describe each stored figure once, with the active vision model,
and write the description back into media.json next to the image it belongs
to. captions.py mirrors the RAG image-description pipeline: it is gated on
supports_multimodal_images(), runs at image_description_limits() concurrency
with a per-image timeout, tolerates individual failures, and returns the
number of rows it wrote. The work is best-effort by design: the upload path
schedules it as a background task that can only log, never fail an ingest.
Off by default (document_parsing.json -> image_caption, surfaced through the
document-parsing settings API), so nothing changes until the switch is on.
store.refresh_document() lands alongside it: re-extraction of an already
ingested document that keeps annotations/positions/bookmarks/assets in place,
rewrites units/media/manifest in one atomic swap, refuses to touch anything
when the raw bytes are gone or the unit count would change, and carries
existing captions over by image name so a refresh never silently discards
descriptions the API already paid for.
Bind mastery drafts before their opening turn and preserve stored session modes.
Track chat duration from submission through terminal completion. Run async reading
extensions on their event loop and allow retries after cancellable timeouts.
Allow first uploads into empty LlamaIndex knowledge bases, preserve Telegram
thread routing, parse embedding Retry-After dates, and enforce robots rules and
host pacing during documentation crawls, including redirects.
Fixes#1461Fixes#1458Fixes#1451Fixes#1448Fixes#1392Fixes#1429
Refs #1435, #1412
Reuses contributions from PRs #1462, #1452 and #1403.
Co-authored-by: sjagadee <srini.jagadeesh@gmail.com>
Co-authored-by: AoHanBei <dongaohan21@gmail.com>
Co-authored-by: Gao-Chenkai <DevChenkai@outlook.com>
#1436 put the right question in `_invalidate_runtime_caches` — did this apply
actually change the catalog — but left every caller to answer it. Five
endpoints assembled their own `catalog_before`/`catalog_after` pair in four
different ways: two full extra `load()` calls at the codex endpoint, `current`
before secret restoration at one, `service.load()` after apply at two others.
And the kwargs are optional, so the sixth endpoint that forgets them gets the
unconditional reset #1421 was about, silently.
Whether the catalog changed is a property of the file, not of the caller.
`_runtime_catalog_write()` brackets the write and reads both sides itself, so
a caller states only what it always knew: this writes the catalog. A write
that raises leaves the block without resetting, which is what a failed write
should do — there is nothing new for the clients to read.
Behaviour is unchanged; the two skip paths #1436 tested still pass untouched.
Adds the two it did not: finishing the tour with nothing edited, which is the
cold start the report described, and applying one service that already holds
the value it is being given.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(sessions): add recycle bin for deleted chats
Implements soft-delete for chat sessions so users can restore
accidentally deleted conversations from a recycle bin.
Backend:
- Schema migration adds deleted_at REAL column to sessions
- delete_session becomes a soft-delete (sets deleted_at timestamp)
- New store methods: restore_session, purge_session, list_deleted_sessions
- Session list queries exclude soft-deleted sessions
- API endpoints: GET /sessions/recycle-bin, POST /{id}/restore,
DELETE /{id}/purge (purge triggers attachment/mastery cleanup)
Frontend:
- RecycleBinSection: collapsible sidebar section listing deleted
sessions with Restore and Delete permanently actions
- Wired into SidebarShell via recycleBinSlot prop
- API client functions for list, restore, and purge
- en/zh translations for all recycle-bin UI strings
Tests: 6 backend tests covering the soft-delete lifecycle
* style: apply ruff format to sqlite_store
* fix(sessions): preserve recycled chat artifacts
* feat(sessions): fold #1444's backend into this recycle bin
#1444 built the same feature from the other end. This PR had the SQLite
column, the routes and the sidebar UI; #1444 had the protocol declarations,
the PocketBase implementation and the CLI wording. Neither shipped alone —
this one left multi-user deployments answering AttributeError on
/recycle-bin, and #1444 built a bin nobody could see. Closes#1444; its
backend is here.
Kept from here: one `deleted_at` column. #1444 carried `is_deleted` beside it
in both backends, and `deleted_at IS NOT NULL` already says everything the
boolean did — PocketBase now derives the outward `is_deleted` field from the
timestamp instead of storing it twice.
Taken from #1444: the naming, which turns out to fix the residual both PRs
shipped with. `delete_session` keeps meaning what every existing caller
already meant by it — remove the row — so `reading.py`'s two internal
cleanups need no patch: a deleted reading workspace still takes its sessions
with it instead of depositing them in a learner's bin, where restoring one
would resurrect a session pointing at a workspace that no longer exists. The
chat surface's delete is a separate, explicitly named `soft_delete_session`,
and `hard_delete_session` empties the bin. Both backends agree, and the
protocol declares all five so a backend cannot silently lack one again.
`test_entries_cascade_on_session_purge` becomes two tests, because there are
now two deletions worth pinning: one the bin can undo, and one that skips it
and cascades immediately.
Co-Authored-By: sjagadee <srini.jagadeesh@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: XZH <cto@xzh.ai>
Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
Co-authored-by: sjagadee <srini.jagadeesh@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* feat: Persistent File Library with API router (issue #1437)
FileLibraryStore (deeptutor/services/storage/file_library.py):
- add_file: stores bytes to disk, deduplicates by SHA-256
- get_file: returns entry by id
- delete_file: soft-delete, idempotent
- hard_delete_file: permanent delete (requires prior soft-delete)
- restore_file: clears is_deleted, idempotent
- list_files: active entries, newest-first, paginated
- search_files: case-insensitive filename LIKE search
- resolve_path: returns absolute Path or None
API router (deeptutor/api/routers/file_library.py):
- GET /files/library/ — list files
- POST /files/library/ — multipart upload with SHA-256 deduplication
- GET /files/library/search — filename search
- GET /files/library/{id} — get entry
- GET /files/library/{id}/download — download file bytes
- DELETE /files/library/{id} — soft-delete
- POST /files/library/{id}/restore — restore soft-deleted
25 unit tests + 20 API integration tests, all passing.
* fix: ruff import-sort/unused-import fixes for file library
* fix: scope file library singleton per user, close upload dedup race
- get_file_library_store() was caching the FileLibraryStore under a
hardcoded key ("default") instead of the resolved per-user root, so
in multi-user deployments every user after the first shared one
library (list/get/download/delete/restore all leaked across
accounts). Now resolves get_path_service().get_user_root() on every
call and keys the cache by str(user_root), mirroring
get_attachment_store().
- _add_file_sync's SHA-256 dedup check was a plain SELECT followed by
an INSERT with no synchronization; concurrent uploads of identical
content (double-click, duplicate tabs, client retries) could both
miss the dedup lookup and each create a duplicate row/file. Added a
per-instance lock around the check-then-write-then-insert sequence,
plus a partial unique index on sha256 (active rows only) with
IntegrityError handling as a defense-in-depth backstop for
multi-process deployments.
- Fixed the test fixture in test_file_library_router.py: it patched
file_library._fl.get_file_library_store then reverted the patch
before any request ran, so the mock never actually intercepted
anything; removed the dead code and added tokens/auth_enabled
support for multi-user testing.
- Added regression tests: test_upload_and_list_are_isolated_between_users
and test_add_file_concurrent_uploads_of_same_content_do_not_duplicate,
both verified to fail against the pre-fix code.
- ruff format on the three touched files (pre-existing line-length
debt in code this change touches).
Adds `uk` alongside `en` and `zh`: a complete `web/locales/uk/app.json`
(4009 keys), a Ukrainian CLI label set (102 keys), a Ukrainian quiz-judge
prompt, and the language directive that tells the model to answer in it.
Most of the diff is not the translation — it is the six independent
places that each decided, on their own, which languages exist. Every one
of them collapsed an unknown code to English *silently*, so picking
Ukrainian in Settings produced an English UI, English AI feedback and an
English chat reply, with nothing logged anywhere:
* `services/settings/interface_settings._normalize_language` — the
canonical normalizer; `interface.json` stored `uk`, the API returned
`en`, and it looked like the setting had failed to save.
* `agents/loop/prompt_blocks` — conflated two different things in one
attribute: which prompt ASSETS exist (yaml ships `en`/`zh` only) and
which language to ANSWER in (any). Split into `language` and
`output_language`; the directive now takes the latter.
* `api/routers/quiz_judge` — the supported set is now derived from
`_JUDGE_SYSTEM_PROMPTS`, so a language cannot be advertised without a
prompt or shipped without being advertised.
* `web/i18n/init` — `normalizeLanguage`/`ensureLanguage`, plus a new
exported `APP_LANGUAGES` that every picker maps over. The Settings
toggle inlined `["en", "zh"]`, so a new locale was invisible there
even once it existed.
* `web/context/app-shell-storage` — held a second, private copy of the
`AppLanguage` union; re-exported from `i18n/init` instead.
* `runtime/banner` and `services/config/settings_spec` — the CLI wizard
labels and the Settings language list.
Tool hints stay a per-language map from the API where only `en` is
guaranteed, so `ToolsSettingsSection` falls back instead of indexing a
missing key. Backend prompt yaml is still `en`/`zh`; Ukrainian uses the
English scaffolding with a Ukrainian output directive, which is what the
directive is for.
`tests/i18n/test_ukrainian_locale.py` pins each seam — locale key parity,
placeholder integrity, judge/prompt/normalizer coverage, and that the
Settings toggle maps over `APP_LANGUAGES` rather than a literal — so the
next language fails in CI rather than quietly in the UI.
The provider redirects the browser to a loopback listener. Under Docker
that listener runs inside the container and the standard compose file
publishes only the Web and API ports, so the browser lands on a page it
cannot load while the sign-in waits until it expires. The card treated
localhost as native local execution and offered nothing else: the remote
guidance was gated behind a non-loopback hostname, so the one deployment
that most needs a way back in was the one that never saw it (#1252).
The browser can read that address even when this process cannot receive
it, so pasting it back is the recovery path. It goes to a new
authenticated endpoint on the Web origin, which resolves the caller's
*own* pending operation rather than scanning every login in the process
— the loopback route has to identify itself by OAuth state because it
arrives without a session, and this one does not.
``parse_oauth_callback_url`` is where the address is judged, once: it
must be this login's registered redirect URI down to scheme, host, port
and path, and a repeated OAuth parameter is ambiguous rather than
untidy, so it is refused instead of resolved to one of the two. The
string is parsed and dropped — never fetched, never stored, never
echoed. Past the parse it is ``receive_callback``, so the state check,
PKCE, the registered redirect URI and owner binding are the existing
ones rather than a second implementation of them.
The form now appears whenever a login is waiting, local or remote; the
SSH command stays remote-only, because that advice is.
A partner web chat runs as a synthetic user, so ``workspace_present``
writes its manifest under ``data/partners/<id>/workspace``. The download
route resolved the item against the caller's own bindings only,
``binding_by_id`` refused a workspace no human account has registered,
and the attachment the transcript was still offering 404'd on click
(#1267).
``/files/outputs`` already reaches into the caller's visible partner
workspaces for the same reason (#1012); this is the other artifact URL
shape and it had been left behind. Reading the two routers side by side
was what showed the asymmetry.
The two differ in one respect, and deliberately: an output is addressed
by a relative path that several partners could each hold, so that
endpoint serves only a unique match. A workspace id is derived from the
owning user id together with the physical root and re-derived before a
stored row is trusted, so a hit inside a partner scope is that
partner's by construction and the first one is the answer.
The reported issue named three further causes — an unmounted router and
two rejected path shapes. None of them hold: both routers are mounted,
and the partner output fallback has been there since #1012.
A knowledge-base name is three things at once: a kb_config.json key, a
directory under data/knowledge_bases, and a path segment in every per-KB API
route. `validate_knowledge_base_name` exists to keep those three uses
compatible — its docstring says so — but it was called from one of the eight
HTTP entry points that can write a name into the config. The seven connect-*
endpoints (Obsidian, MarginNote, folder, LightRAG server, WeKnora, IMA, and
the subagent connection) did `(name or "").strip()` and wrote the result.
A name holding a "/" registers fine that way and is then unreachable.
uvicorn percent-decodes the path before routing, so %2F is a real separator
by the time Starlette matches `{kb_name}` — compiled to `[^/]+`, which cannot
span it. All 29 per-KB routes 404, delete included, while the list endpoint
takes no path parameter and keeps rendering the KB. Connected KBs are also
exempt from the orphan prune, so nothing collects it either: visible, unusable,
and removable only by hand-editing kb_config.json.
Two changes, both needed. Validation moves onto the eight `register_*`
methods, which is the seam every route already goes through — no route file
changes, since they all map ValueError to 400 — and the now-unreachable
"name is required" guards go with it. And a path-free
`POST /knowledge-bases/delete` gives the entries that predate the guard a way
out; a body is never split into segments. Widening the path route to
`{kb_name:path}` would not work: it is declared ahead of the DELETE routes
for linked folders, GitHub sources and web sources, and a greedy converter
would silently swallow all three.
Two smaller fixes ride along. The delete handler's catch-all swallowed its
own HTTPException and answered 500 with "404: ... not found" in the detail;
it now re-raises. And CreateKbModal states the rule under the field instead
of letting an untranslated English 400 be the first the user hears of it.
test_marginnote4_kb's store-collision case used "My Lib" / "My/Lib"; the
slash is now refused before that guard is reached, so it uses "My.Lib" —
still a name the rule allows, still sanitized to the same My_Lib.db.