* fix(chat): isolate PDF attachment extraction
Run PDF-bearing chat attachment extraction outside the API process and reuse the single PDF image pass for both page markers and embedded attachments. Addresses the chat attachment reproduction in #2865.
* perf(pdf): skip decoding images after the count cap
Keep lookups for previously accepted image references ahead of the quota check so repeated pictures are still mapped to each page.
* perf(chat): reuse native PDF markdown for text-only parsing
Match the stored attachment bytes and preserve the configured parser path for other engines and incomplete native results.
Mimic mode never parsed a paper uploaded from the web composer. The turn
executor stores every upload in the attachment store and then clears the
inline base64 of each document it has extracted, so the PDF attachment
reached DeepQuestionCapability with an empty base64. The upload branch was
skipped and the turn fell back to the plain-text "[Attached Documents]"
hint: no exam parsing, no question extraction and no templates.
When the attachment carries no inline bytes, the capability now resolves
the stored file by session and attachment id, the same lookup the chat PDF
parser uses, and parses it as before. Inline base64 is still used when
present.
Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
TeachingUpdate.model_json_schema() gave knowledge_point_id, strategy and outcome no description, so models filling a preference also set strategy and the call is rejected by check_semantics. Add per-field descriptions (flat schema kept) and a test.
Batch resumable embedding checkpoints and write the BM25 sidecar once after the final checkpoint, carrying over #2903. 45 targeted tests passed with the PR applied to dev. A 19-source rebuild retrieved the last source from the persisted BM25 index.
* fix(web): keep statistics notation as inline math
plausibleMathBody judged inline math by Latin words, so $Var(N)$, $Cov(X,Y)
and $Corr(X,Y)$ fell through escapeStrayDollars and displayed as source.
Add the common statistics functions to MATH_WORDS.
Also recover control characters left by JSON tool-argument decoding
(U+0008/U+000C/U+000D followed by a letter) back into \b, \f and \r, so
formulas already stored in notes render again.
Tests: latex-normalize.test.ts.
Co-Authored-By: Claude Code <noreply@anthropic.com>
* fix(web): only restore a decoded escape that spells a KaTeX command
A form feed or carriage return in front of a word is not always a mangled
\frac or \right: text extracted from a PDF keeps a form feed between pages.
Rewriting every one of them showed a stray "\f" in front of the next word.
Restore the backslash only when the letters after it name a KaTeX command.
---------
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
* Fix quiz-attempt 500 when the Book entity has no chat_session_id
book.py's attempt sync read book.chat_session_id, an attribute that only
exists on CreateBookRequest/BookInputs (a legacy creation-time shorthand)
and is not persisted on the Book model — so every quiz attempt without a
page-bound chat session raised AttributeError after the progress was
saved, returning 500 and dropping the Focus-Check assessment sync.
Read only the persisted per-page mapping, and cover it with a regression
test whose fake mirrors the real entity (no chat_session_id attribute).
* style: apply ruff format
* chore(api): refresh router index for the book router
---------
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
* fix: parse inline math in note tables and statistics notation
BlockNote only renders `inlineMath` nodes, and two common shapes never
became one:
- `parseNoteMarkdown` converted inline `$...$` in a block's top-level
content, but table cells live under `tableContent.rows`, which the walk
never reached.
- The normaliser treated `$Var(N)$` and `$Cov(X, Y)$` as prose because the
Latin-word heuristic did not recognise statistics function names, so it
escaped the delimiters as stray dollars.
Recurse into `tableContent` cells and add the common statistics function
names to the math-word allowlist, with regression tests for both.
Co-Authored-By: Claude Code <noreply@anthropic.com>
* fix(web): count statistics names as maths only when they are called
"mean", "median", "rank", "span" and "var" are English words and a
keyword too, so with them in the word list "$52k mean, $48k median" became a
formula and a backticked `var x = 1` on a page with maths turned into KaTeX.
Keep them out of MATH_WORDS and accept them only before "(", which is how
Var(X) and Cov(X, Y) are written.
---------
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
Learner-card stems go through InlineMarkdown, which only switches to the
rich renderer for math, emphasis, code and links; a stem whose only markup
was a table reached the learner as raw pipes. Detect GFM tables and route
those stems through RichInlineMarkdown, and add markdown-table.ts (table
detection plus a blank line after each table so a trailing sentence is not
swallowed as another row).
Tests: learner-card-table.spec.tsx, markdown-table.test.ts.
Co-authored-by: Claude Code <noreply@anthropic.com>
processLatexContent now runs normalizeEditorMdInlineMath, so a stem written
as $$P=\begin{pmatrix}...\end{pmatrix}$$ gets each $$ on its own line.
remark-math otherwise parses it as inline math and KaTeX fails on the first
ampersand or row break.
Tests: latex.test.ts, learner-card-math.spec.tsx.
Co-authored-by: Claude Code <noreply@anthropic.com>
* fix(chat): open quiz settings only when the learner picks the mode
The Activity panel auto-open watched the active capability, so loading or
reloading a session that was already in Quiz / Visualize / Research mode
counted as a switch into that mode. On a phone the panel is a full-screen
sheet, so every reopened quiz session started covered by its settings.
Open the config card from handleSelectCapability instead, the only path
for an explicit mode change (composer picker, slash command, launch
intent). Session hydration no longer opens it; restored per-session
settings are untouched.
Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
* test(chat): record viewer panel props through a spy
Assigning to the hoisted fixture inside the forwardRef stub trips
react-hooks/immutability; capture the props with a mock call instead.
Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
* fix(quiz): translate question badges and the German mimic label
The quiz card header printed the raw question type (short_answer,
fill_in_blank) and difficulty ids instead of the labels the quiz
settings already use, and the German catalog left "Mimic Paper"
untranslated.
Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
---------
Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
The step body and footer capped themselves at max-w-2xl but stayed at the
left edge of the 1180px page container, leaving a wide empty column on the
right. Other partner surfaces (archives, chat) already center their
max-w-2xl column. Wrap the step header and body in a centered max-w-2xl
column and center the Back/Next row with it.
Layout-only change.
Co-authored-by: Antonio-Faure <209759495+Antonio-Faure@users.noreply.github.com>
* fix(mastery): ignore knowledge-base sources that no longer resolve
Refs #2748
* fix(mastery): filter the caller's mounted knowledge bases too
A study session left open across a deletion keeps sending the base it was
mounted with, and that list is merged verbatim with the topic's sources.
Run both through knowledge_base_ref_available so a stale name cannot reach
the tool bundles and raise AccessError.
Continues #2978 and closes#2887. Includes the original Windows file actions, integrates the changes with dev, and adds an explicit default-app action.
Co-authored-by: Botong Wu <2048400180@qq.com>
* fix: render bare scripted math in quiz prose
* fix(web): recover quiz subscripts parsed as emphasis
Adjacent bare formulas can share Markdown emphasis delimiters. Mask candidate underscores only while locating prose ranges, then wrap the original symbols for KaTeX. Cover the reported circuit options through all three rendering routes.
* 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>
* fix(settings): answer 404 for unknown connection-test run ids
* chore(api): refresh router index for the settings route change
tests/api/test_router_loader.py::test_repository_index_matches_router_sources
checks the fingerprint of router sources; regenerated with
scripts/build_router_index.py.
---------
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
* fix(config): keep a settings document that cannot be parsed instead of resetting it
* fix(config): re-warn about an unparseable settings document once a minute
The startup load runs before logging is configured, so its only record can
reach just the process output, and the permanent per-path set meant it never
appeared in the application log afterwards. Throttle per path instead, and
state in the containerization guide where the warning is written and that
the loader only preserves documents it cannot parse.
@string blocks were skipped, so a field written as journal=jname kept the bare
macro name in the generated Markdown. Collect the definitions while scanning and
expand bare words that name one; unknown words and numbers are left unchanged.
The stored name is "<attachment_id>_<filename>", so a valid 240-byte filename
exceeded the 255-byte component limit and put() raised ENAMETOOLONG. Trim the
stem by bytes, keeping a short extension, so saving and lookup stay consistent.
When the numbered page exceeded the 128k-character budget, read_file cut
the text mid-page but still reported the requested range: the hint
pointed past lines that were never shown, or claimed the end of the
file. Stop at the last whole line that fits and base the continuation
offset on it.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(desktop): sync Windows menu preferences with web settings
* fix(settings): reconcile desktop preferences after updating the live baseline
* fix(desktop): guard menu zoom handlers against missing web view
* fix(mastery): keep language-course content in its target language
The reply-language directive is the last thing in every system prompt and
tells the model to write quiz stems and options in the reply language and
never switch. For a course whose subject is itself a language, the model
obeyed literally: an "Antonyms" objective in an English course, studied with
Chinese as the reply language, was drafted as 反义词 and taught in a later
session as Chinese antonyms.
- language_directive now says the reply language governs the explanation,
not the subject: a studied language keeps its own words, sentences and
exercise items.
- Route generation and the tutor's outline drafting name the target
language in every module and knowledge point ("English antonyms").
- The tutor playbook keeps an existing language course on its target
language even when an objective name does not repeat it.
Closes#2933
Co-Authored-By: Claude <noreply@anthropic.com>
* test(mastery): check the composed prompts keep a language course's target language
The strict reply-language directive is appended last, after the route and
tutor instructions. Assert the carve-out survives in the prompts the model
actually receives: zh route generation, and the zh tutor playbook rendered
with a fixed reply language.
Related to #2933
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
The fold prompt lets memory entries cite previously retained archive IDs,
but covered_archive_ids had to equal the newly supplied set exactly. A
model that also lists retained IDs as covered failed every fold, so the
watermark never moved and the session stayed on degraded raw history.
Accept covered IDs that are the newly supplied ones plus IDs the prior
memory already covered or cited. Still reject omitted, invented or unseen
IDs, and store only the newly folded IDs as covered.
Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
Mastery Path preparation looked up a knowledge base's index by the global embedding signature. PageIndex, GraphRAG and LightRAG versions carry a provider signature instead, and a LlamaIndex knowledge base can be bound to another embedding, so a ready index was rejected with 'no compatible completed index'. Preparation now resolves the index the way the provider reads it: the KB's bound embedding for LlamaIndex, the newest provider-ready version otherwise. Fixes#2895.
Bare 'model', 'engine', 'embedding' and 'vector' are everyday words in a tutoring product (physical models, ML models, word embeddings). A learning question such as '把理想气体模型换成范德瓦尔斯模型,熵的表达式要怎么调整' matched an action word plus one of them, mounted the setup capability, and rewrote the system prompt and tool list mid-conversation. Only qualified forms (language/chat/embedding model, parsing/search engine) now count as a configuration object.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(mastery): name the recovery step when assessment evidence is mis-scoped
The focused-teaching refusal that blocks mastery_assess said only to prepare
assessment-bound evidence, so a session that had only ever prepared focused
packets retried the same call and the learner stayed stuck. Point the refusal
at the preparation that actually clears the gate.
* fix(mastery): avoid misleading recovery for incomplete evidence
Split focus-scoped and incomplete objective-scoped assessment refusals so
only focused packets are told to prepare without a focus. Surface missing
coverage for incomplete objective packets and pin the diagnostic with a
regression test.
---------
Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
* fix(video): align scene narration and fit diagrams
- Refine bilingual prompts for scene-by-scene narration and visuals
- Fit and center SVG diagrams with their labels and strokes
- Improve geometry coordinate guidance and preserve layout retries
* fix(video): do not report a fitted scene graphic as overflow
The kit scales a graphic with a transform on its full-size frame, so the
scaled frame box and the SVG canvas can exceed the region while the drawing
fits. Measure HTML overflow without that transform and canvas.
---------
Co-authored-by: zzzworm <15828873+zzzworm86@user.noreply.gitee.com>
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
* fix: 将预读附件全文放在来源清单之前
* fix(explore): tell the model the preloaded text needs no read_source
Without the note the model re-reads the preloaded lecture with read_source on
the upload turn, sending the whole text a second time.
---------
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>