Commit Graph

836 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
47ae8a27e4 Merge PR #2515: feat(i18n): add Hungarian as an interface and reply language
Combine Hungarian with Italian UI and Hindi reply-language registries; translate 49 newly integrated keys and add the Hungarian endonym to Italian. Regenerate router and frontend contracts. 33 Python locale tests, full Node suite and locale parity pass.
2026-11-14 23:36:26 +08:00
Bingxi Zhao (Frank)
95aa81d624 Merge PR #2544: feat(i18n): add Italian (it) localization
Make Italian quality tests compatible with CommonJS Node test compiler; accept Italiano as reply-language alias; translate 48 keys added by other integrated PRs; regenerate router index and format i18n. 26 Python locale tests and full Node suite pass.
2026-11-14 23:34:48 +08:00
Bingxi Zhao (Frank)
3b267f2b8d Merge PR #2500: feat(reading): fit the page to its text, step zoom, and open a picture inside a PDF
Reconcile PDF zoom with cached text layers and 150 ms final repaint; let text gaps reach image hotspots; keep pointer-captured pan clicks from dismissing image preview. 97 PDF unit tests and 7 Chromium zoom/resize audits pass; real mouse image hotspot click verified.
2026-11-14 23:31:59 +08:00
Bingxi Zhao (Frank)
af403550ce Merge PR #2639: fix: explain missing LLM access in chat
Retain admission error text and localized model-access guidance; allow explicit retry to revalidate access instead of permanently blocking stored messages. No automatic retry on reload. Backend tests and both manual retry paths passed.
2026-11-14 23:19:09 +08:00
Bingxi Zhao (Frank)
2d493edb84 Merge PR #2521: feat(i18n): add Hindi as a reply language
Regenerate the lazy route index after the reply-language contract changes; targeted tests passed.
2026-11-14 23:16:33 +08:00
Bingxi Zhao (Frank)
bbdb77fd0f test(reading): exercise question help without exposing answer keys 2026-11-14 23:03:04 +08:00
Bingxi Zhao (Frank)
a3dde93ffa Merge PR #2664: fix: admission rejections carry the server's text into the submission banner 2026-11-14 23:01:20 +08:00
Bingxi Zhao (Frank)
23fe37894a Merge PR #2596: fix(web): keep widget KaTeX's $$ delimiter and render math written after load 2026-11-14 23:01:20 +08:00
Bingxi Zhao (Frank)
43dbf6eaba Merge PR #2597: fix(book): render math in callouts, key takeaways and flash cards 2026-11-14 23:01:19 +08:00
Bingxi Zhao (Frank)
b8f629ac02 Merge PR #2599: fix(web): tighten a loose $ formula before wrapping bare LaTeX 2026-11-14 23:01:19 +08:00
Bingxi Zhao (Frank)
47eaab3c3c Merge PR #2648: perf(web): optimize PDF page rendering 2026-11-14 23:01:19 +08:00
Bingxi Zhao (Frank)
af41eaa01e Merge PR #2490: fix: render and resume book page chat questions
Combine resumed question state with the existing scroll-follow hook; do not restore unconditional scroll-to-bottom on every message.
2026-11-14 23:01:19 +08:00
Bingxi Zhao (Frank)
f7306b6091 Merge PR #2489: fix: preserve book chat scroll position while streaming 2026-11-14 23:00:46 +08:00
Bingxi Zhao (Frank)
04324a9fec Merge PR #2508: test(reading): restore live EPUB browser audits 2026-11-14 23:00:46 +08:00
Bingxi Zhao (Frank)
3fc9d2ce18 Merge PR #2534: feat(web_fetch): pluggable fetch backend with DeepSeek Fetch as first alternative
Combine independent locale additions and regenerate integrated route index.
2026-11-14 23:00:23 +08:00
Bingxi Zhao (Frank)
e6897249be Merge PR #2541: fix(web): language-aware CJK font stacks for chat prose 2026-11-14 23:00:05 +08:00
Bingxi Zhao (Frank)
5c7dbb2a7e Merge PR #2547: fix(web): move settings nav copy into locale catalogs (#2134) 2026-11-14 23:00:04 +08:00
Bingxi Zhao (Frank)
16cc590b63 Merge PR #2564: feat(chat): per-conversation reasoning-effort selector in the composer (#641) 2026-11-14 23:00:04 +08:00
Bingxi Zhao (Frank)
83f18f1be2 Merge PR #2577: feat(sidebar): group a practice session's questions into one Learning Records row 2026-11-14 23:00:04 +08:00
Bingxi Zhao (Frank)
68220257af Merge PR #2568: feat(guardian): show scoped Reading progress and quiz records
Combine independent locale additions and regenerate integrated route index.
2026-11-14 23:00:03 +08:00
Bingxi Zhao (Frank)
c60e0e0331 Merge PR #2576: feat(reading): record question-linked help without replacing the quiz
Keep server-only quiz answer keys before persisting help results; retain relationship and extension-policy revalidation.
2026-11-14 22:59:16 +08:00
Bingxi Zhao (Frank)
fa3debf4b4 Merge PR #2560: fix(reading): keep quiz answer keys on the server 2026-11-14 22:58:53 +08:00
Bingxi Zhao (Frank)
21e9878b59 Merge PR #2556: fix: sync and index MDX documentation in knowledge bases 2026-11-14 22:57:42 +08:00
Bingxi Zhao (Frank)
5d7843251e Merge PR #2643: fix(learning): load each source kind independently in the picker 2026-11-14 22:57:42 +08:00
Bingxi Zhao (Frank)
70607d8a05 Merge PR #2590: fix(mcp): offer an OAuth opt-in for servers added by URL 2026-11-14 22:57:41 +08:00
mpichini1
33b7763e44 fix: keep favorite headings inside fenced code blocks 2026-11-13 20:10:11 +01:00
dach-a
09f2de1b1f fix: admission rejections carry the server's text into the submission banner
A start_turn_rejected terminal error already carries the server's own
explanation ("No LLM model is assigned to your account. Please contact
an administrator.", #2637; "This learning account cannot use this
mode...", the mastery case in #2638). The client toasted it for ten
seconds and then dispatched STREAM_END without it, so the persistent
composer-adjacent banner — the text users actually read — hardcoded the
transport copy "Couldn't reach the server..." for every rejection.

Carry the server text onto the flagged unsent row
(failedSubmissionMessage) and render it in the banner, falling back to
the connection copy only when the server provided no text. The toast
stays; the unsent row + Resend semantics from #1594 are unchanged.

Not persisted across reload: a reloaded unsent row shows the generic
fallback (its durable record keeps the exact request for retry); a
follow-up can extend the durable record if wanted.
2026-11-13 11:20:50 +00:00
zrj
9427c7543d perf(web): optimize PDF page rendering 2026-11-12 21:41:40 +08:00
ZQR1101
062eca80c0 fix(learning): load each source kind independently in the picker
The knowledge source picker fired all six source-library requests inside
one Promise.all and only rendered after every kind settled. A large
question bank (tens of thousands of practice entries accumulated
server-side) kept the whole panel on a spinner, so a ready knowledge base
could not be selected even after its own request had returned.

Land each kind in its own slice as its request settles, and gate each
consumer on the active kind's readiness instead of the aggregate. A ready
KB is now selectable while the question bank is still loading or has
failed; per-kind error alerts no longer paint a failure on a ready tab.
The aggregate loading flag still clears once everything settles.

Refs #2641
2026-11-12 19:55:50 +08:00
Junlin Li
560a80a17f fix: explain missing LLM access in chat 2026-11-12 16:58:52 +08:00
LaiYongqiang
5b3feff863 feat(reading): open a picture inside a PDF
A PDF page is one bitmap by the time it reaches the DOM, so a picture inside it
has no element to click and no way to be read at its own size. A thumbnail in a
600-page scan could not be opened at all.

The operator list still knows where each picture was placed: `paintImageXObject`
draws the unit square through the current transformation matrix, so replaying
save/restore/transform/form-object pairing recovers the rectangle each picture
covers. Those rectangles become hotspots; clicking one opens the picture whole in
a preview with pan and zoom.

Four things that only show up once this meets real documents:

- **Hotspots sit UNDER the text layer, not over it.** They were DOM siblings
  after the text layer, so they stacked above it — and on an OCR scan, where one
  image covers the whole page, a single button sat over every word: selection,
  highlighting and clicking an existing annotation all stopped responding. A box
  covering most of the page is dropped in the geometry layer (it is the page
  bitmap, not a picture in it), the hotspots render before the text layer, and
  the mouseup guard that swallowed a selection ending on a picture is gone.
- **Only the active page is measured.** `getOperatorList` runs its own rendering
  intent, cached separately from the display one, so measuring the whole retained
  window parsed and decoded thirteen pages of images twice — full-resolution
  bitmaps kept on the main thread, past the canvas budget the visible ones obey.
- **Pictures inside annotation streams are skipped.** A stamp or signature is
  painted into the annotation's own canvas after the renderer resets the
  transform, so replaying its matrix as page space put the hotspot near the page
  origin, over whatever happened to be there.
- **The preview is a real modal.** It declared itself one but never took focus,
  so ⌘+/− acted on the page behind it and closing dropped focus on `<body>`. It
  focuses itself on open, restores the previous element on close, and stops
  Escape from also reaching the Guided Learning handler — both listeners sit on
  `window`, so `preventDefault` was never going to work. The stage no longer
  swallows every click either: a click on the empty area closes the overlay, a
  click on the picture does not.

The preview also sizes the canvas from the picture's box rather than its width
alone: a scanned page — one full-page hotspot — opened at 2.7x showing its middle
third, with zoom clamped at 1 and no way out.
2026-11-11 19:51:06 +08:00
LaiYongqiang
1e9e615fe2 feat(reading): fit the page to its text, and step zoom continuously
A PDF page was drawn at the pane's width, so the document's own white margins
sat on screen twice over — the page's margins plus the pane's padding. On a
1440px window that is roughly 735px of page inside a ~1165px pane, and the type
was about a fifth smaller than the pane could show. Zooming fixed the size but
cost horizontal scrolling: past Fit, reading meant dragging the page left and
right on every line.

**Fit text** trims the page's white margins by measuring where the ink actually
stops, then draws the page wider than the pane and clips it to the text block —
so the type fills the column without horizontal scrolling. **Fit page** is the
old behaviour, kept as its own mode. The zoom step became continuous (a factor
rather than a ladder), so a pinch settles anywhere and the next press starts
from what is on screen.

The measurement is the part that is easy to get wrong. It renders the page into
a 200px-wide scratch canvas rather than reading the operator list, because a page
that paints a white rectangle behind its text — which most do — would report a
full-page box from the operators alone, while the pixels show where the text
actually stops. Two consequences are handled here: a page whose render promise
never settles (some embedded browsers paint but never resolve) is given a
one-second bound and drawn uncropped, and a timed-out answer is not cached, so a
remount measures again instead of inheriting "nothing to crop" from a browser
that never replied.

Marks and paints are stored and converted in page space, not strip space: the
annotation layer paints on the full page while the visible strip is a crop of it,
so a rect normalised against the strip was stretched and shifted — a rect at
100px rendered at 62px.

A step is measured against the width that actually landed, and past the canvas
budget's ceiling the control disables rather than asking for a size below what is
drawn: a small page in a wide pane, trimmed to a half-width text block, can be
drawn above 400%, and clamping the ratio then stepping made "zoom in" shrink it.
A zoom that lands on the committed width drops its scroll anchor instead of
leaving one behind for the next pane resize to consume.

The crop ratio is state rather than a ref: the toolbar's enablement is derived
from it, and a ref write does not re-render — so the button stayed live until
something else happened to render.
2026-11-11 19:50:33 +08:00
LaiYongqiang
d28e06effb test(reading): pin the zoom arithmetic, and drive the bar in a real browser
Three layers, each covering what the others cannot.

The node tests pin the arithmetic directly: the fit width formula is unchanged
from before the feature, 100% is the page's real size rather than its `scale: 1`
size, the canvas budget clamps per page and not only for page one, a step walks
past the stops the budget has flattened, and a wheel notch changes the page even
when the stored request is already at the ceiling — multiplying the request
instead of the landed width left the first notches of a zoom-out doing nothing.

The shortcut cases cover the gap the old signature hid: it had no field for "the
event is going into a field", so no test could describe the case. Both readers'
matchers are checked with `editableTarget: true` for every combination they bind.

The jsdom specs drive the component: stepping from the ratio actually on screen,
holding the page still when the pane resizes in fixed mode, keeping the pointer's
line and column in place through ctrl+wheel, the bitmap budget per page, the menu
lifecycle, a row printing the size it will actually produce, and the percentage
being announced.

The browser audit is the one that found something. jsdom has no layout and no
real tab order, so it cannot answer whether the hidden bar is reachable, whether
`focus-within` actually reveals it, or which of two `window` Escape listeners
wins. It steps the page size, tabs into the hidden bar, walks the real tab order
until focus reaches the bar, drives the menu from the keyboard, closes it with
Escape without leaving the reading mode, and requires a step at the ceiling
either to change the width or to disable its control.

That audit caught a defect the jsdom test could not: the arrow-key handler was
attached to the menu element, but when the menu opens focus is still on the
trigger — a sibling of the menu — so the keydown never reached the handler and
the menu could not be driven from the keyboard at all. The unit test passed
because it dispatched the key on the menu node directly, bypassing the real
event path.

Both keyboard cases are verified by reverting the code they cover.
2026-11-11 18:31:38 +08:00
riccardo-algorime
c55776f680 fix(web): tighten a loose $ formula before wrapping bare LaTeX
A formula closed with a space before the dollar (`$\lim a_n = $ ____`, the
usual shape of a fill-in-the-blank question) is no MATH_SPAN_RE match, so
the bare-LaTeX pass wrapped its body again and produced `$$\lim a_n =$ $`:
a display block that never closes, with the rest of the text raw.
Pairing the dollars before that pass tightens it first; the final pass
still runs as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:56:10 +00:00
riccardo-algorime
89c92e7395 fix(book): render math in callouts, key takeaways and flash cards
These blocks printed their text as is, so the LaTeX the book writer puts
in them showed raw (`$q^n \to \infty$`). They now go through
MarkdownRenderer like section bodies, the way #1364 fixed Mastery
question cards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:44:05 +00:00
riccardo-algorime
1f82e309e8 fix(web): keep widget KaTeX's $$ delimiter and render math written after load
injectKaTeX inserted its init script with a string replacement, where "$$"
means "$". The display delimiter became "$", so `$$...$$` stayed raw and
every `$...$` rendered as display math. Replacer functions keep the script
as written.

Widgets often write math after load (step-by-step reveals, slider
readouts), which auto-render never saw. A throttled MutationObserver now
renders it, skipping math already rendered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:37:01 +00:00
evan188199-tech
03821f3646 fix(mcp): offer an OAuth opt-in for servers added by URL (#2585)
The add/edit form had no control for MCPServerConfig.auth, so a custom
OAuth-only remote server connected with no credentials, got 401, and never
showed the Connect button. Add an Authentication select (None / OAuth) to the
remote block, thread it through buildMcpServerConfig as an explicit draft field
that keeps the stored value when unset, and cover the new-URL-server,
header-only, and catalog-edit paths in tests.

Signed-off-by: evan188199-tech <238371241+evan188199-tech@users.noreply.github.com>
2026-11-10 15:48:43 +08:00
evan188199-tech
a074bcfcb9 feat(sidebar): collapse one practice session's questions into a single Learning Records row
Practice notebook entries recorded in one session now share a single
sidebar row, titled by that session with its question count, expandable
to each question's own practice link. Entries without a session (and
sessions that produced one question) keep individual rows, and the
Question Bank, answers and review links are unchanged.

The learning index navigation read gains the existing session id and
title (no new persisted field); grouping happens in the projection.
Sidebar strings added to every locale.
2026-11-10 00:33:52 +08:00
Yin
627d15fb2c feat(guardians): show durable question help separately from attempts 2026-11-10 00:31:22 +08:00
Yin
054769a139 feat(reading): keep recorded help inside each quiz question 2026-11-10 00:23:38 +08:00
Yin
a420707623 feat(guardian): show scoped reading progress and quiz records 2026-11-09 23:07:32 +08:00
evan188199-tech
e837f0a1d9 fix(chat): never forward an unsupported reasoning-effort override (#641)
A persisted override the selected model no longer supports (e.g. a saved
xhigh after the catalog restricts the model to low/high) could reach the
provider: the selector re-listed the stale value, and the send path
forwarded the restored llm_selection.reasoning_effort unchecked.

- lib/reasoning-effort.ts: supportedReasoningEffortValues() returns the
  model's supported wire values (catalog list, else provider/model tables
  honouring declared_reasoning) without ever re-adding the stored value;
  effectiveReasoningEffort() resolves an override to null when the model
  does not support it; dropUnvalidatedReasoningEffort() strips it from an
  outgoing llm_selection — including when the option is unresolved, where
  the override is omitted (falls back to the configured default) rather
  than forwarded unvalidated.
- ReasoningEffortSelector: computeReasoningOptions uses the helper; a
  stale value is not offered and Auto renders as selected instead.
- ChatComposer: once the model options are loaded, a detected-unsupported
  persisted override is reset through the selector's onChange persist
  path; nothing is cleared while the option is still unresolved.
- ChatStateAdapter: outgoing llm_selection (live send and failed-turn
  resend) is sanitized via the last-known option catalog, which
  listLLMOptions now records (readLastKnownLLMOptions, synchronous).
- tests: helper/selector/restore-path coverage in
  reasoning-effort.test.ts, reasoning-effort-selector.spec.tsx and the
  new reasoning-effort-restore.spec.ts.
2026-11-09 22:36:10 +08:00
Yin
5d16a6a2f0 fix(reading): keep quiz answer keys on the server 2026-11-09 22:17:03 +08:00
markxu
fdae1dfdf0 fix: sync and index MDX documentation in knowledge bases
GitHub source sync kept only .md and .markdown, so a docs glob of *.mdx
reported success with zero files and left raw/ empty. Re-index then failed
because no supported source files were present. Treat .mdx as text next to
Markdown in the sync filter, the knowledge-base file router, and the chat
attachment list that mirrors it.

Fixes #2552
2026-11-09 14:09:57 +00:00
evan188199-tech
3b1730d758 feat(chat): per-conversation reasoning-effort selector in the composer (#641)
Carry the #958 service-layer reasoning_effort override through the whole
turn contract: the core TurnRequest LLMSelection accepts the field
(validated against VALID_REASONING_EFFORTS, old two-ID payloads unchanged),
the generated web contracts are regenerated, and ChatStateAdapter's
asLLMSelection restores a legal override instead of dropping it.

The composer gains a selector beside the model picker, offering only the
levels the selected model supports (live supported_reasoning_efforts or
the provider/model tables) narrowed to the wire vocabulary, hidden when
the model has none. The choice persists on the conversation's
llm_selection, so the next send uses it without a backend restart and
other conversations are unaffected; switching models resets the override.
Precedence stays conversation override -> profile/model default ->
provider default, and the context-budget readout reports the effective
effort beside the model when one was used.
2026-11-09 20:47:08 +08:00
evan188199-tech
da65a29e54 fix(web): dedicated voice nav key and bilingual settings search (#2134) 2026-11-09 17:46:38 +08:00
evan188199-tech
a312b26515 fix(web): move settings nav copy into locale catalogs (#2134) 2026-11-09 17:17:41 +08:00
Daniele Lucarelli
377bf10fa9 feat(i18n): add Italian (it) localization 2026-11-09 08:48:31 +00:00
evan188199-tech
91104d9a3f fix(web_fetch): settings UI for backend + harden DeepSeek fetch cap (#2448)
Addresses Air R1/R2 review blockers on top of the opened PR head:
Settings GET/PUT /api/settings/web-fetch with UI control; DeepSeek fetch
uses identity encoding, raw bytes, and capacity checks before buffer extend;
provider-branding treats `local` as generic.
Air Codex R3 on MacBook Air: READY.
2026-11-09 16:23:50 +08:00
evan188199-tech
a7df05f739 fix(web): tag assistant prose with the turn's recorded language (#2143)
AssistantMessage derived its lang attribute from the session-wide
language prop, so switching the reply language re-tagged every past
reply (zh->ja gave old Chinese replies Japanese fonts). Derive the
per-message language from the turn's request snapshot, recorded when
the turn was sent, and fall back to the session language only for
legacy messages without one. Add a behavior test covering two replies
with different recorded languages and the legacy fallback.
2026-11-09 14:53:24 +08:00