85 Commits

Author SHA1 Message Date
Leoy
8b2448e293 fix(knowledge): fit uploaded names and folder segments into the 255-byte limit (#3140)
Byte-fit KB upload filenames and folder segments to NAME_MAX, and share fit_filename_bytes with attachment/reading stores.
2026-12-01 17:00:42 +08:00
PP1
9744bad61b fix: reject empty normalized quiz evidence (#2769) 2026-12-01 00:25:11 +08:00
Rudy Mizrahi Celekli
df2d6f0b0b fix(reading): preserve original extensions on long multilingual filenames (#2780)
* 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>
2026-11-28 20:26:37 +08:00
Bingxi Zhao (Frank)
2dcb44c6ed Merge PR #2574: fix(reading): anchor Markdown highlights in rendered-text space
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.
2026-11-14 23:15:17 +08:00
evan188199-tech
45b1a7e036 fix(reading): keep grounded vocabulary terms when siblings miss the selection (#2579)
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.
2026-11-10 07:31:43 +08:00
evan188199-tech
046a8eeb77 fix(reading): anchor web_markdown highlights in rendered-text space
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).
2026-11-09 23:57:44 +08:00
AleFlyX
34c404228a fix(reading): keep document extraction off the API event loop
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.
2026-11-01 00:58:00 +08:00
Bingxi Zhao
6b971d89e6 Merge pull request #2225 from kevin9327/fix/reading-long-name-keeps-extension
fix(reading): keep the extension when a long material name is cut
2026-10-31 17:14:59 +08:00
Rimcat-JA
f75d44eb03 fix(reading): render uploaded Markdown files, including math
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>
2026-10-31 14:12:08 +09:00
kevin9327
e65408d8c4 fix(reading): keep the extension when a long material name is cut 2026-10-31 12:14:46 +09:00
Bingxi Zhao
06443db9bc Merge pull request #1822 from dajiaohuang/fix/cron-connection-lifetime
fix(storage): close short-lived SQLite connections deterministically
2026-10-19 00:19:44 +08:00
Fancie-Personal
e7c909ec94 perf(documents): bound an inlined raster's long edge before admission
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.
2026-10-18 23:36:28 +08:00
dajiaohuang
149343c414 fix(storage): close SQLite connections after helper operations 2026-10-15 12:08:30 +08:00
Bingxi Zhao (Frank)
6cf793bd86 release: v1.6.14
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.
2026-10-08 11:34:42 +08:00
Bingxi Zhao (Frank)
7885daa98a feat(plugins): add reviewed managed lifecycle and revocable runtime gates (#1307)
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>
2026-10-08 08:50:05 +08:00
Bingxi Zhao (Frank)
8986c31580 feat(reading): complete Watching convergence with safe legacy migration (#1378)
Adapted the migration foundation from PR #1384 while preserving current workspace, caption and turn-admission safeguards.

Co-authored-by: XZH <cto@xzh.ai>
2026-10-08 02:48:50 +08:00
Bingxi Zhao (Frank)
895c41999c Merge dev into PR #1665 and preserve integrated behavior 2026-10-04 14:47:52 +08:00
Bingxi Zhao (Frank)
2700105923 Merge dev into PR #1664 and preserve integrated behavior 2026-10-04 14:41:40 +08:00
Bingxi Zhao
891493b7b1 Merge pull request #1686 from evan188199-tech/codex/fix/epub-toc-anchors
fix(reading): preserve EPUB outline anchors (#1673)
2026-10-04 14:20:41 +08:00
XZH
95e913a787 fix(reading): preserve EPUB outline anchors 2026-10-01 17:26:44 -07:00
ZyPulse
1c07ef4e44 perf(parsing): cache image descriptions per workspace 2026-09-30 00:15:20 +08:00
ZyPulse
cbb742a141 feat(parsing): select an independent image description model 2026-09-30 00:01:29 +08:00
Hui
6dd4542a0b fix(reading): close a Markdown fence only on a matching bare run
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>
2026-09-28 20:44:31 -04:00
NoxsMedia
b08833ed62 chore: merge upstream dev into markdown outline fix 2026-09-24 05:28:08 +00:00
Bingxi Zhao (Frank)
a053fecf6e release: v1.6.11
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.
2026-09-24 09:59:56 +08:00
NoxsMedia
4738ead451 fix: derive uploaded markdown outlines from headings 2026-09-24 01:49:16 +00:00
Bingxi Zhao (Frank)
53436f8190 feat(reading): collections as colored folders; rework reader interactions
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.
2026-09-23 18:59:17 +08:00
Bingxi Zhao (Frank)
66ba712172 fix(reading): make selection actions reliable and sync reading sessions
- 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.
2026-09-23 18:59:02 +08:00
Bingxi Zhao (Frank)
8880529c65 Merge PR batch with local follow-up fixes
Preserve precise learner KB route guards, combine UI and response language domains, carry normalized EPUB extraction, and regenerate frontend contracts.

Update locale fallback coverage for the completed Ukrainian translation bundle.
2026-09-23 12:01:14 +08:00
Bingxi Zhao (Frank)
55e96e429e style: satisfy repository lint and format gates 2026-09-23 11:28:41 +08:00
Bingxi Zhao (Frank)
21b9307031 fix(reading): enforce current learner grants on saved sources and tabs 2026-09-23 11:27:03 +08:00
Bingxi Zhao (Frank)
0b3d5be873 style(reading): format combined extraction and store changes 2026-09-23 10:59:12 +08:00
Bingxi Zhao (Frank)
705e9bf9d5 Merge branch 'codex/reading-learning-prs-20260923' into codex/pr-batch-root
# Conflicts:
#	deeptutor/reading/extract.py
#	deeptutor/reading/store.py
#	web/components/notebook/NotebookRecordRow.tsx
#	web/locales/en/app.json
#	web/locales/zh/app.json
2026-09-23 10:58:38 +08:00
Bingxi Zhao (Frank)
ce590620d7 Preserve reading source fidelity and resilient activity tracking 2026-09-23 10:54:37 +08:00
Bingxi Zhao (Frank)
1829ae23f0 Fix PDF image mapping, caption refresh, and Grok detection 2026-09-23 10:48:36 +08:00
Bingxi Zhao (Frank)
7d330f043c Merge remote-tracking branch 'origin/pr-1503' into codex/merge-pr-1503
# Conflicts:
#	deeptutor/services/session/turns/executor.py
2026-09-23 10:32:28 +08:00
Bingxi Zhao (Frank)
125dfaf037 Merge PR #1472: normalize packaged EPUB archives 2026-09-23 10:31:31 +08:00
Bingxi Zhao (Frank)
ae8a811353 Merge PR #1379: provider-aware reading media ingestion 2026-09-23 10:28:48 +08:00
Bingxi Zhao (Frank)
4225013330 Merge PR #1376: reanchor reading annotations across revisions 2026-09-23 10:28:35 +08:00
Bingxi Zhao (Frank)
da856ad670 release: v1.6.9
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.
2026-09-21 02:30:40 +08:00
Gao-Chenkai
3eb831d108 feat(learning): persist cross-surface Focus-Check in Question Bank
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>
2026-09-17 21:21:15 +08:00
flower-moon
0b0e693eb7 refactor(reading): own the page-render predicate in the reading layer
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.
2026-09-17 19:22:11 +08:00
flower-moon
465a49222b feat(reading): refresh figures on already-ingested materials
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.
2026-09-17 18:46:28 +08:00
flower-moon
8c718530b2 feat(reading): caption embedded figures at ingest
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.
2026-09-17 18:46:28 +08:00
flower-moon
8999c0d3e4 feat(reading): extract PDF figures so the reader can send them to the model
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).
2026-09-17 18:46:28 +08:00
flower-moon
481cb54537 fix(reading): accept catalog-minted rm_ material ids in the turn protocol
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.
2026-09-17 18:46:28 +08:00
flower-moon
e1b4954a23 feat(documents): Office/PDF 嵌入图片全链路支持 — 提取、显示、喂视觉模型
- 新增 utils/document_images.py:docx(OOXML单遍扫描)/pptx(python-pptx+OOXML兜底)/pdf(pymupdf, xref去重)
  嵌入图片提取,统一 [图片 N: name] 正文标记 + ImageBudget 预算(单文档12张/12MB,单回合16张/12MB)
- 聊天附件:extract_documents_from_records 产出嵌入图片 image 记录(embedded 标记),
  turn_runtime 托管附件库后经现有多模态注入管道发给视觉模型,UI 零改动渲染图片附件
- 阅读区:Extraction.media + 标记→locator 映射,入库 media/ + media.json,
  新增 GET /materials/{id}/media(/{name}) API,TextUnitView 图片条(article 外侧,不动逐字锚定),
  immersive_reading 回合注入当前页图片(≤4张),read_material 结果附图片清单
- docx 富提取顺带补齐 python-docx 一直丢掉的表格文本;EMF/WMF 矢量图计数尾注不静默丢弃
- MaterialManifest 新增 media_count(向后兼容);media_path 索引校验防路径穿越
- tests: test_document_images.py 8 用例;utils 51 + 阅读区全套 + session 209 通过

详细文档: docs/文档图片支持_提取显示与视觉模型_2026-09-07.md (gitignored)
2026-09-17 18:46:28 +08:00
XZH
28aa40ff45 fix(reading): normalize packaged EPUB archives 2026-09-15 02:11:01 -07:00
XZH
fbd29c65b9 feat(reading): add provider-aware media ingestion 2026-09-10 14:20:54 -07:00
XZH
f526d693bf feat(reading): reanchor selectors across revisions
Add resolution field to Annotation, migrate selectors on revision upgrade,
preserve old annotations for audit, and surface unresolved/ambiguous badges.
2026-09-10 13:11:36 -07:00