* fix(reading): fit original filenames within the UTF-8 limit
* fix(reading): shorten the temp upload name the same way
The upload is first written to a temp file named after the upload. A
100-character Chinese name is 300 UTF-8 bytes, so on Linux the request
failed with "File name too long" before the stored-name limit added
here was ever reached.
* chore(api): refresh router index for the reading upload change
---------
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
Ground formatted Markdown quotes and context using the existing selection projection, require a grounded quote for browser-only positions, and reject fabricated selections (90 passed). Rendered math that cannot be verified remains conservatively rejected.
Vocabulary help no longer rejects the whole card when one returned term
is absent from the selection: grounded terms are kept and unmatched
siblings are dropped. The ValueError is now raised only when every term
fails the grounding check, and the message lists the rejected terms so
503 bodies are diagnosable.
Uploaded Markdown materials are rendered before display, and the browser
measures TextPositionSelectors against that rendered text — a coordinate
space the raw unit cannot reproduce (**bold** loses its asterisks, $x^2$
becomes KaTeX markup). Slicing the raw Markdown with those offsets made
save_annotation reject almost any selection after inline formatting with
"text quote and position selectors describe different text".
For web_markdown units, store positions as sent (the reader re-anchors
them against the same rendered text via quote plus prefix/suffix) and
validate the quote by occurrence in the raw unit, falling back to the
rendered wording when a selection crosses formatting or math. Plain-text
validation is unchanged, and the selector span ceiling still applies.
Validation: ruff check/format passed; pytest tests/reading passed
(477 passed, 1 pre-existing skip).
Immersive Reading extracts documents synchronously — an EPUB walks its whole
spine and a PDF renders every page through PyMuPDF — but the router called that
work directly from its async handlers. The API runs one event loop per worker,
so a document being opened or uploaded parked every other request: the session
title and transcript of the conversation being switched to, progress polling
and cancellation all waited behind the parse (#2054).
Run the upload extraction and the material detail build through
asyncio.to_thread, matching how the rest of this router and
capabilities/reading/tools.py already call the same store API.
Also load the outline once. _detail() read it, then render_outline() read it
again; for an EPUB whose stored rows still lack publisher anchors each read can
re-parse the whole package through _upgrade_epub_outline. Rendering is split
into format_outline(manifest, entries) so the rows already loaded are reused,
and render_outline() keeps its signature for existing callers.
Regenerated the router index fingerprint for the changed router source.
Uploaded .md / .markdown files were stored as plain_text, so immersive
reading showed their literal source and every formula stayed raw LaTeX.
Record them as web_markdown so they take the existing safe rich renderer
(KaTeX, no raw HTML). Images stay off for uploads, since their links can
point at any host; web snapshots keep their localized images.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chat attachments base64-inline every harvested image into one provider
request, and the byte budgets did not bound what a *page-sized* raster costs
there: a scanned A4 page arrives at ~2900x4032 (~600 KB), so a seven-page scan
rode along as ~4.2 MB of body / ~5.6 MB encoded even though the model is served
a raster scaled toward ~1.5k on the long edge anyway.
Fit a candidate to MAX_INLINE_IMAGE_EDGE (1600) before the byte budgets weigh
it, so the budgets measure what will actually ship. An image already within the
bound keeps its bytes and its format; re-encoding is reserved for rasters past
it, at the same jpg_quality (82) the reading viewport's whole-page render
already uses. Every failure path returns the original bytes, and a pixel count
past MAX_INLINE_FIT_PIXELS is refused before Pillow allocates for it.
The reading-area ingest keeps source resolution (max_inline_edge=0) because
those images are written to disk for the reader pane. The PPTX and DOCX
ingests were still on the chat-attachment budget by default, so they now pass
the reading budget like the PDF ingest already did.
Ship original-source visual practice, recoverable indexing, unified video
Reading, scientific research tools, managed plugins, and a learning journal
as summarized in assets/releases/ver1-6-14.md.
Improve provider setup and protocol-aware endpoints. Restore missing
localized setup and Ukrainian UI text, keep plugin loading in the plugin
layer, harden research XML parsing, and repair isolated test fixtures and
type-checking errors found by the release gate.
Sync README prose and all eleven translations, bump the package version,
and update the stable release announcement.
Validation: 10180 Python tests and 8 subtests passed (28 skipped); 1303
Node tests passed on Node 22; 24 provider UI tests passed. All pre-commit
hooks, ruff, translation checks, documentation checks, and docs build passed.
Adapt the Phase 1 foundation from PR #1309 and complete scoped API lifecycle, pre-import approval, artifact-bound revocation, recovery, bounded workers and frontend isolation. Keep the stronger ecosystem roadmap explicit in the RFC.
Co-authored-by: XZH <cto@xzh.ai>
Adapted the migration foundation from PR #1384 while preserving current workspace, caption and turn-admission safeguards.
Co-authored-by: XZH <cto@xzh.ai>
split_markdown_by_headings remembered only the fence character, so any
line starting with that character toggled the fence. A ```` fence showing
a ``` example closed at the inner ```, and a "```py" line inside a block
also closed it, so "#" lines inside code became outline sections, or the
rest of the document was swallowed and the outline fell back to flat.
Remember the whole opening run and close only on a bare run of the same
character that is at least as long, as CommonMark does. A backtick line
whose info string contains a backtick no longer opens a fence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The interface ships in French and Ukrainian alongside English and
Chinese, and /language pins a reply language for one conversation.
Immersive reading organizes collections as colored folders, adds a
fullscreen learning mode, and turns Explain / Translate / Guide me on a
selection into ordinary messages in the reading chat; "Quiz me on this
page" runs one quiz turn without changing the conversation's mode, which
retires the reading-openers endpoint and its task model. Images embedded
in DOCX, PPTX and PDF are extracted in place and reach vision models.
Office files preview as paged PDFs through LibreOffice (now in the Docker
image), falling back to the in-browser renderers without it. Web sources
re-sync on a durable schedule, linked folders sync on demand, .bib files
index, and a zotero_search tool queries Zotero. Settings gains Learning
progress and credential-free presets; admins import users from CSV;
split deployments can hand a session to a public device. Grok CLI joins
the subagents, Unifically the providers, ChatGPT exports the importers.
Gate cleanup: mypy/bandit findings in the new launcher, audio-overview,
web-source, reading-store and textbook modules; the task-model copy test
follows the retired reading_openers kind.
See assets/releases/ver1-6-11.md for the full notes, and the README
Releases row plus its eleven translations.
Collections vs workspaces: a workspace holds many collections, and a
collection's files and reading conversations live in the workspace it
was created in. The library now shows collections as folders grouped
under their workspace, and creating one asks which workspace it goes
into.
- Folder page at /learning/reading/folders/[folderId]: breadcrumb,
files, the collection's conversations, and "Start reading" that opens
the whole folder in the reader. The reader's back link returns to it.
- Collections carry a user-picked color (new `color` column, migrated);
tones are --folder-* tokens with dark variants.
- One shared "New collection" / "Edit collection" dialog with consistent
type sizes.
- Selection popover gains AI actions; results land as cards at the foot
of the companion. Read-aloud is a single header toggle.
- The three ⋯ menus (collection, document, conversation) merge into one.
- Outline toggle moves to the left and starts closed; navigator has
Outline / Annotations tabs.
- Reading conversations live in the main sidebar (with a page-shaped idle
mark) instead of a history dropdown in the companion.
- Fix sidebar rows never showing a selected state
(bg-[var(--background)]/60 compiled to nothing).
- Composer floats over the conversation (no divider, bottom fade); the
toolbar wraps by content instead of splitting under 420px.
- Strip PDF margin line numbers before verifying a selection, so explain
and guide no longer fail with "Select text from the visible unit first".
- Quiz, vocabulary and study guidance go through
json_with_reasoning_retry with a larger token budget; reasoning models
exhausting max_tokens returned an empty answer that surfaced as
"This reading action is temporarily unavailable" (503).
- Renaming or deleting a reading conversation from the main sidebar
updates the reading catalog too.
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>
The session layer held both the decision ("is this page worth rendering?") and
the injection, and the reading capability had no way to ask the same question
without importing session internals. The predicate and the render record now
live in deeptutor/reading/page_render.py, the session helpers delegate to it,
and the viewport seed says when a rendered page is attached — a model told the
attached image is the page it is being asked about reads it instead of
guessing. With no render the seed is byte-for-byte what it was.
The extraction fix only helps material ingested after it lands, and the retry
endpoint covers web sources and media — an uploaded document cannot be
re-imported at all. scripts/reading_refresh_figures.py closes that gap:
--material/--all picks the PDFs, store.refresh_document re-extracts them in
place, and the same run can caption what the refresh produced.
--dry-run is strictly read-only (it works even when the store API is missing,
because the new calls are imported lazily), and any real run asks for
confirmation unless --yes is passed.
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.
The reading chain only pulled embedded images out of Office files; the PDF
branch produced text alone, so a slide deck uploaded as PDF reported
media_count 0 and no [图片 N] markers at all. The chat-attachment path already
had the missing half (extract_pdf_images + per-page markers), so the reader
now reuses it: each page's figures are pinned to that page's locator and the
marker lines are appended at the END of the page text, leaving every existing
character offset — and therefore every saved annotation anchor — untouched.
Budgets differ by path. Chat attachments inflate images into one request, so
they keep the 12-image/12MB document cap; the reader stores bytes on disk and
only ever sends the open page, so reading_image_budget() allows 120 images /
60MB per document while capping each page at 4 — the same ceiling the viewport
injection applies per turn, which keeps one dense figure page from eating the
document budget. extract_pdf_images/extract_docx_rich/extract_pptx_rich now
accept an explicit ImageBudget, defaulting to the previous behaviour.
Measured on the physics decks: day03_GaussLaw.pdf goes from 0 to 63 media rows
across 23 of its 42 pages (66 candidates, 3 dropped by the per-page cap).
Re-uploading the same content mints a second catalog row with an
rm_-prefixed material id (upsert_material), and the store resolves both
shapes to the same content directory — but the turn-protocol validator
still required a bare content hash, so the viewport image injection (and
reading references) silently dropped the material and vision models
answered without the figures. Accept the same id shape the store
accepts.
Add resolution field to Annotation, migrate selectors on revision upgrade,
preserve old annotations for audit, and surface unresolved/ambiguous badges.