The composer-hint sanitizers used lstrip("-•*# ") to drop list markers,
which also ate the sign of "-3 squared...?", the star of "*args" and
the hash of "#include". Strip a marker only when whitespace follows it.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(reading): isolate document ingestion from the API process
(cherry picked from commit f0fd1f785eb1070f689816b0977bf4c60125f95a)
* chore(api): refresh router index for the reading routes
---------
Co-authored-by: zszz3 <zszz3@users.noreply.github.com>
* 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.
Since Watching converged into Reading (#1378), the reader reports
`reading_viewport.time_seconds` with every turn on a video material, but
`ReadingViewport` forbids extra fields and only declared `locator` and
`selection`. The WebSocket rejected each such turn with `invalid_command`,
so every question asked beside a YouTube/Bilibili video stayed "Not sent".
- Declare `time_seconds` (optional, >= 0) on `ReadingViewport`.
- Keep it in `_reading_viewport` (finite, non-negative, capped at 24h) so
the reading capability's existing "Current media time" grounding
actually receives it instead of silently dropping it.
- Regenerate the frontend contracts.
- Cover protocol acceptance and normalisation in tests/reading.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.