Commit Graph

4242 Commits

Author SHA1 Message Date
Qiuner
fae4639f4c fix(book): use the active clock for standalone chapter retries 2026-11-30 06:22:07 -03:00
Leveling
9bed004617 test(parsing): stop racing interpreter startup in the MinerU lifecycle checks (#3089)
* test(parsing): stop racing interpreter startup in the MinerU lifecycle checks

The Windows `import-check` job flakes on `dev`. It failed at 2026-11-30 03:12
and 03:32 on `79a66cb3` and `6b00f010`, passed on the same step 90 minutes
later in another run, and passed on `218dbe31` the evening before. Nothing
between those runs touched `.github/`, `tests/services/parsing/`,
`tests/runtime/` or the MinerU engine, so the workflow and the code under test
were identical in the green and red runs.

Reproduced, and the cause is a timing premise in the tests, not the runner.

The race
--------

`test_deadline_and_cancellation_settle_the_owned_tree[True]` sets
`timeout=0.8` and only cancels once the fixture child has spawned a grandchild
and written `child.pid`:

    def check():
        if cancelled and list(...glob(".../child.pid")):
            raise IndexingCancelled(...)

`local.py` starts its clock before `cli_process()`, which on Windows creates a
Job Object, spawns a suspended interpreter, resumes it and queries its threads.
That work plus two more interpreter startups has to fit inside the same 0.8s.
When it does not, the deadline wins before the marker exists and the assertion
reports `TIMEOUT is not CANCELLED`.

Measured on an idle machine the marker lands in 0.067-0.085s, so the margin
looked comfortable. Delaying only the child's first write, with no CPU
contention at all:

    startup delay | result    | expected  | verdict
         0.0s     | cancelled | cancelled | pass
         0.5s     | cancelled | cancelled | pass
         0.7s     | timeout   | cancelled | FAIL
         0.9s     | timeout   | cancelled | FAIL
         1.2s     | timeout   | cancelled | FAIL

CPU contention alone reproduced the same signature
`assert <LocalParseReason.TIMEOUT> is <LocalParseReason.CANCELLED>` at line 138,
plus `assert 2.087 < 2` and `assert 3.757 < 1.5` on neighbouring cases.

The production ordering is correct and is left alone: `run.check()` is
evaluated before the deadline comparison, so an available cancellation always
wins. What the tests must not do is depend on how fast the runner started a
Python interpreter.

What changed
------------

- `_await_marker()` waits for a fixture marker with a real timeout and a
  message that distinguishes "the CLI never started" from "the runner was
  slow". Bare `(path,) = glob(...)` unpacking turned both into
  `ValueError: not enough values to unpack (expected 1, got 0)`, which is what
  made these CI failures unreadable.
- The cancellation case waits for the recorded child before raising, so the
  interruption is decided by policy rather than by interpreter startup. A 3s
  startup delay now passes where 0.7s used to fail.
- Wall-clock bounds that were only guarding "did not wait for the descendant"
  were widened off the interpreter-startup budget (`elapsed < 2` -> `< 15`,
  `elapsed < 1.5` -> `< 10`, `elapsed < 2.5` -> `< 15`). The idle-threshold and
  deadline assertions that carry the actual meaning are unchanged.
- `_await_settled()` treats `psutil.AccessDenied` as "not settled yet" instead
  of raising mid-test.
- The decoy process in `test_parent_exit_does_not_wait_for_descendant_stdout`
  lives 120s instead of 10s, so a slow run cannot make it die of old age and be
  reported as "cleanup touched an unrelated process".
- `test_detached_venv_launcher_has_no_console` asserts the marker exists before
  reading it, instead of raising `FileNotFoundError` after its 15s wait.

Observability
-------------

The Windows step now runs with `-rA --durations=15`. Without them the job
reported only "Process completed with exit code 1" with no test name, which is
why these failures needed a local reproduction to attribute.

Verification
------------

- `pytest -q -rA --durations=15 tests/services/parsing/test_mineru_process_lifecycle.py tests/runtime/test_launcher.py::test_detached_venv_launcher_has_no_console`
  -> 7 passed, 10 skipped (the skips are POSIX/Darwin-only cases).
- Deliberate-startup-delay harness: 0.0/0.5/0.9/1.5/3.0s all report
  `cancelled` after the change; 0.7s+ reported `timeout` before it.
- `ruff check` and `ruff format --check` clean on both files; workflow YAML
  parses.

No production code is changed.

* test(parsing): synchronise the deadline fixtures with grandchild startup

Addresses review on #3089. Two real defects:

1. The deadline case of test_deadline_and_cancellation_settle_the_owned_tree
   still raced. Only the cancellation branch waited for `child.pid`; the
   deadline branch killed the fixture at 0.8s and then read a marker that was
   never written, so a 1.3s startup delay produced `TIMEOUT` and then a failed
   marker read. Both branches now synchronise through `check()`: it waits for
   the recorded grandchild and only then either raises (cancellation) or returns
   and lets the deadline comparison run. The timeout assertion is preserved.

   test_explicit_client_timeout_also_bounds_parent_runtime had the same shape —
   it read `deadline.txt` after a 1.2s kill. The record is written before the
   child parks, so it exists whenever the child started at all, and the read now
   reports "CLI did not start" instead of an unpacking error.

2. test_parent_exit_does_not_wait_for_descendant_stdout had lost its teeth: the
   new 10s bound exceeded the grandchild's 2s sleep, so an implementation that
   waited for inherited stdout could finish inside the bound and pass. The
   grandchild now lives 60s and the bound is 20s, derived from the fixture, so
   waiting for it fails the test again.

Verified with a 1.3s pre-startup delay (the reviewer's repro): both lifecycle
cases report the expected reason and the tree is settled. 0.0/1.3/2.0/3.0s all
pass. `7 passed, 10 skipped`; ruff clean.

* test: wait for the MinerU deadline record before enforcing the timeout

---------

Co-authored-by: Qiuner <wdst3635@163.com>
2026-11-30 05:55:09 -03:00
Frant1cc
912e8fba2d fix(pptx): resolve font fallback in PDF previews and exports (#3043)
* fix(pptx): resolve font fallback in PDF previews and exports

* test: match host path semantics in the PPTX preview fixture

---------

Co-authored-by: Qiuner <wdst3635@163.com>
2026-11-30 05:17:20 -03:00
Chen jizhou
a3173eeb0e perf: reuse the textarea sizing mirror across edits (#2700)
Co-authored-by: chen-12-03 <184723954+chen-12-03@users.noreply.github.com>
2026-11-30 15:53:03 +08:00
Yuchuan He
cdf2726feb fix(book): persist background mode when resuming generation (#3048) 2026-11-30 15:49:44 +08:00
Ding Junyao
f187580271 fix: add Source Han Fonts in font-family beside Noto Fonts (#2939) 2026-11-30 15:49:22 +08:00
Michael Chen
436ec67e2d fix(llm): resolve Moonshot K3 context windows (#3013) 2026-11-30 15:48:57 +08:00
Mohammad Hijjawi
50976926cc fix(voice): decode Mistral TTS audio_data instead of returning the JSON body (#2793) 2026-11-30 15:48:30 +08:00
Shlok Bam
6096676dc5 fix: keep a code fence inside a fenced JSON string value (#3059) 2026-11-30 15:47:55 +08:00
AleFlyX
e542e3ff0e fix(knowledge): drop visual assets on every document-delete path (#3022)
* fix(knowledge): drop visual assets on every document-delete path

Extracted figures are tracked in `visual_assets/` (manifest + image files) and
were only cleaned by the HTTP delete-file route, which called
`VisualAssetStore.remove_source` itself. `remove_raw_document` has three
callers - that route plus the GitHub and web source syncs - so the two sync
paths deleted the document and left its figures and manifest entries behind
forever. Images are capped at 5 MB each, so a sync that drops figure-heavy
documents leaks a lot of disk.

Reproduced before the fix: a KB with one raw PDF and a matching asset entry,
then `remove_raw_document(kb, doc)` (exactly what both syncs do) -> the doc was
gone while the asset file and its manifest entry both remained.

Cleanup now happens in `remove_raw_document`, the single layer all three
deletion paths share, keyed by the module's existing `_raw_hash_key` - the same
rule indexing uses to record `source_path`, so nested raw/ paths cannot be
missed. The route's now-redundant call is removed rather than left as a second
owner: it also removes a second, lexical relative-path computation, and the old
uncaught call could 500 a delete on a corrupt manifest, which contradicts the
"cleanup never fails a user's delete" contract.

Best-effort like the surrounding code: a corrupt or read-only manifest logs a
warning and never turns a delete into an error. `VisualAssetStore.__init__`
only assigns paths, and `remove_source` returns before writing when no entry
matches, so KBs that never had images are not given an empty `visual_assets/`
directory (pinned by a test).

Verified: 7 new tests; mutation check shows disabling the cleanup fails 4 of
them. Independent checks: nested `papers/2024/` asset removed while a sibling
document's asset is preserved; no `visual_assets/` created for an image-free
KB; re-running the original repro now reports no leak.
Tests: 264 passed (knowledge, visual assets, source sync, HTTP file deletion).

Note: assets for an older parser signature are deliberately kept so a rollback
to an older index version still resolves its figures; that is retention, not a
leak, and is unchanged here.

* fix(api): 更新路由索引指纹

重新生成 knowledge 路由变更后的索引。原生引擎和路由加载器的 18 个测试均已通过。

---------

Co-authored-by: zszz3 <zszz3@users.noreply.github.com>
2026-11-30 15:37:35 +08:00
Yuchuan He
a11b88f52d fix(book): persist chapter titles in reviewed edits (#3047) 2026-11-30 04:19:49 -03:00
Gaurav Dubey
8b4191b7d1 fix(rag): keep figure captions out of the chunk metadata budget (#2870)
* fix(rag): keep figure captions out of the chunk metadata budget

Figure documents carried the caption, asset ids, bbox, source locator and
absolute path in metadata that LlamaIndex counts against every chunk. A long
caption (common for CJK textbook figures) pushed the metadata past the
default 512-token chunk size, so SentenceSplitter raised "Metadata length
(...) is longer than chunk size (512)" and the whole indexing run failed.

Keep those keys on the node for citations and pixel delivery, but exclude
them from the embed and LLM metadata text. The caption is already part of
the document text, so retrieval content is unchanged.

Closes #2865

* test(rag): split sentences without NLTK in the caption budget test

The new regression test ran SentenceSplitter with its default punkt
tokenizer, which loads NLTK data. CI runners refuse that data, so the
test failed with LookupError on all Python versions. Pass a regex
sentence splitter instead. The test still fails without the loader fix.
2026-11-30 04:18:49 -03:00
cro3w
d77ad8f6c4 fix(reading): isolate document ingestion from the API process (#2988)
* 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>
2026-11-30 15:15:59 +08:00
Yuchuan He
7261bd4cd4 fix(book): export sections in outline order (#3049) 2026-11-30 04:11:28 -03:00
Udaya Vijay Anand
593bffac0e perf(session): copy stored model turns without JSON round-trip (#2803) 2026-11-30 15:10:57 +08:00
游标卡尺
9d014a27e2 fix(session): stop existence checks from re-serializing stored model turns (#2807)
Long mastery sessions froze the event loop: every existence-only probe
(history_groups, context-builder guards) ran normalize_model_turn, which
deep-copies the whole request record via a JSON round-trip. A 121-message
session re-serialized megabytes per probe, holding the GIL long enough for
health checks to time out and the worker to be declared lost.

Extract the structural acceptance checks into _is_complete_model_turn and
add has_model_turn for existence-only sites. normalize_model_turn delegates
to the same predicate, then cleans and copies as before, so replay keeps its
full isolation. Stored records are normalize's own JSON-safe outputs, so the
predicate accepts exactly what normalize accepts on stored rows; a parity
corpus pins the shared rejections.

Fixes #2788

Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
2026-11-30 15:10:40 +08:00
lipeh1
71303c0b96 fix: extract desktop bundles into the physical staging directory (#2801)
* fix: extract desktop bundles into the physical staging directory

* test(desktop): clarify Windows junction fallback coverage

---------

Co-authored-by: lipeih <lipeihan@eazytec.com>
2026-11-30 04:09:50 -03:00
Chen jizhou
58501be31a fix: allow bounded recovery after desktop readiness misses (#2696)
Co-authored-by: chen-12-03 <184723954+chen-12-03@users.noreply.github.com>
2026-11-30 14:18:43 +08:00
muhamedaldias
084d311302 fix(rag): skip CancelledError results in SmartRetriever.retrieve (#2981)
Co-authored-by: muhamedaldias <296670347+muhamedaldias@users.noreply.github.com>
2026-11-30 14:18:33 +08:00
qiuqianyi66
51265a568c fix(api): omit supported_reasoning_efforts instead of emitting null (#2845)
The admin serializer only sets the field when the catalog declares
`codex_supported_reasoning_levels`, but both non-admin serializers copied the
raw `.get(...)` result, which is `null` for every model that declares nothing.
The web composer guards with `supported_reasoning_efforts !== undefined` before
calling `.map`, so any ordinary account granted such a model crashed on
`/chat` — admins were unaffected, which is why a fresh home never reproduced
it (#2732, #2833).

Share one `declared_reasoning_levels` helper across the admin serializer,
`redacted_model_access`, `allowed_llm_options`, and the personal sign-in rows:
each now either emits a normalized list or omits the key.
2026-11-30 14:18:24 +08:00
Benjamin Schwing
48502be836 fix(llm): close pooled providers on the event loop that owns them (#2948)
* fix(llm): close an evicted pooled provider on the loop that owns it

The runtime provider pool is keyed per event loop and shared by the server
loop and synchronous callers that run asyncio.run() in a worker thread, such
as the exam question extractor. Two cross-loop problems followed:

- When a worker loop's lookup evicted a server-loop client, the client's
  aclose() was scheduled on the worker loop. It ran on the wrong thread, or
  never ran when asyncio.run() cancelled it on exit. For Claude Code this
  tears down the server loop's persistent CLI sessions from a foreign thread.
- Every finished worker loop left its entry behind. With a pool of two,
  that stale entry could push the server loop's live client out, discarding
  warm CLI sessions.

Each entry now records its loop. Evictions close on that loop: directly
when it is the running loop, otherwise through run_coroutine_threadsafe.
Entries whose loop is closed are dropped before a new client is added.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>

* fix(llm): close every retired pooled provider on its own loop

close_runtime_provider_pool() awaited aclose() of every pooled client on
the caller's loop, and reset_runtime_provider_pool() scheduled them on the
caller's loop or ran each on a fresh asyncio.run() loop. A client built on
another loop, such as a long-lived worker loop, was therefore closed on a
loop that does not own its sockets or tasks.

The bulk paths now keep each retired entry's loop. close awaits only the
clients owned by the current loop and hands the rest to their owner loop;
reset routes every client through the same owner-loop close. The final
release of a leased client also uses the entry's recorded loop.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>

* fix(llm): create a cross-loop close coroutine on the owner loop

run_coroutine_threadsafe() builds the close coroutine on the calling
thread. When the owner loop is stopped but not yet closed and never runs
again, that coroutine is dropped unawaited and Python warns "coroutine was
never awaited". Schedule a callback instead that creates the close task on
the owner loop, so a loop that never runs again leaves nothing behind. A
closed loop rejects the callback, which also replaces the separate
is_closed() check.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>

---------

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-30 14:18:16 +08:00
CyanPersica
b061e71d9b fix(loop): do not execute a tool call cut off by the output limit (#2719)
json-repair was closing the partial arguments and the tool then ran, so a
write could persist half a value and report success. A truncated round now
keeps the text and records one not-executed result per call.

Fixes #2713

Signed-off-by: fanjiahe <fanjiahe@mail.ustc.edu.cn>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-30 14:18:06 +08:00
enlightenmengt2
9ec5815df5 fix(rag): register connected engines in the preflight registry (#3027)
EngineDetail renders the readiness panel for every engine, and its check button calls /api/knowledge-bases/rag-pipelines/{provider}/preflight, which runs engine_preflight() -> _PREFLIGHTS[normalize_provider_name(provider)]().

weknora and kiwix are in KNOWN_PROVIDERS but were never registered in _PREFLIGHTS, so the lookup raised KeyError and the route answered 500 for those engine pages.

One shared _connected_preflight now reports them ready: each knowledge base supplies its own server URL and credentials, validated by the connect probe, so nothing is configured account-wide. This matches doctor.py, which already skips these providers in its preflight loop.

The new test walks KNOWN_PROVIDERS and asserts every entry returns a report, so a future provider constant cannot silently miss the registry again.

Co-authored-by: enlightenmengt2 <227120787+enlightenmengt2@users.noreply.github.com>
2026-11-30 14:17:55 +08:00
AleFlyX
5ff2627aee fix(knowledge): reclaim parse cache when a document or KB is deleted (#2941)
The parse cache is content-addressed and has no eviction of any kind: no size
cap, no TTL, no LRU, no CLI command, no settings entry. Neither deleting a raw
document nor deleting a whole knowledge base removed anything from it, and the
only cleanup that exists (clean_rag_storage) removes index storage - not the
parse cache - and is CLI-only. A deleted KB therefore kept its entire derived
parse output on disk forever.

Measured with a realistic document: a 30-page PDF with ~18 extracted images
leaves about 6.5 MB under parse_cache/. 64 such documents accumulate ~418 MB
that is never reclaimed; the directory only grows.

cache.reclaim_sources(paths, cache_root=...) removes the
<parse_cache>/<hash[:2]>/<hash>/ shard for each document being deleted - every
parser signature for that source, since the cache is derived and the next parse
recreates what it needs. It hashes the bytes while they still exist, because
the cache key is the content hash. Wired into two call sites, both before the
bytes disappear:

- remove_raw_document (single file, before unlink())
- KnowledgeBaseManager.delete_knowledge_base (every raw document, before the
  KB directory is removed)

The cache root is derived from the KB directory (a sibling of knowledge_bases/)
rather than from the ambient path service, because requests served from the
knowledge-base library run in the account workspace scope. Deriving it from the
request scope would reclaim another workspace's cache while leaking this KB's
own. KB deletion enumerates exactly what rmtree removes: dotfiles included,
symlinks skipped because only the link goes away.

Reclaiming is scoped strictly to the hashes of the files being deleted, so
nothing else under the cache root is touched. The cache is shared across all
parse consumers in the workspace (KB indexing, chat attachments, reading
figures), so a byte-identical copy loses its entry too and is re-parsed once on
next use - slower, never incorrect. Proving liveness would mean hashing every
live source on every delete, and metadata.json only records documents that
indexed successfully; that tradeoff is documented on the helper and at both
call sites. The key is a truncated 64-bit hash; a collision costs one extra
re-parse, never wrong output.

Best-effort by contract: an unreadable source, a locked shard (a stale Windows
handle is the common case) or a missing cache root is logged and skipped, and
both call sites additionally wrap the call, so no cache failure can fail a
user's delete.

Note: this reclaims on delete; it does not bound growth of the live cache. A
size cap / LRU sweeper is a separate change and should be its own issue (the
scope split is recorded on #2946).

Verified on the current dev base (14796c70f): 14 new tests; mutation checks show
disabling the helper at either call site fails its positive-reclamation test.
A workspace/library-view reproduction (real ContentWorkspaceService, account
scope, KB stored in a workspace) confirms the KB's own shard is now reclaimed
while an account-level lookalike shard is left alone. tests/knowledge: 205
passed, 6 pre-existing failures (same as dev, missing llama_index/jose). ruff
check/format clean with the pinned 0.16.0.
2026-11-30 14:17:47 +08:00
Leon Lei
9db50a7601 fix(rag): avoid NLTK regex CPU timeout in sentence splitting and clean failed version dirs (#3036)
* fix(rag): avoid NLTK regex CPU timeout during splitting and clean failed version dirs

* fix(rag): construct PunktSentenceTokenizer directly without globals_helper stopwords
2026-11-30 14:17:37 +08:00
Carl
c1ae1bbe2a fix(rag): isolate LlamaIndex cross-encoder reranker in a worker process (#3005) 2026-11-30 14:17:26 +08:00
Qiu
3e66b30aa0 fix(chat): isolate PDF attachment extraction (#3026)
* 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.
2026-11-30 13:56:01 +08:00
Marcello Pichini
6b00f0109c fix: combine adjacent minute and second duration units (#2684) 2026-11-30 11:32:40 +08:00
Chen jizhou
79a66cb3c1 perf: stop idle activity orbs and narrow theme observers (#2704) 2026-11-30 11:12:41 +08:00
bluefateludi
4277138581 perf(auth): format only the requested account for profile lookups (#3033) 2026-11-30 11:12:32 +08:00
1zrj
24aa2632d9 fix learning activity (ReadingCompanion, MasteryStudy, NoteCompanion) chat auto-follow (#2935) 2026-11-30 11:12:23 +08:00
Benjamin Schwing
15489b72cf fix(question): read an uploaded exam paper back from the attachment store (#2949)
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>
2026-11-30 11:12:14 +08:00
Alex Castillo González
218dbe31b9 fix(mastery): document observation-only fields in the teaching_updates schema (#2872)
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.
2026-11-30 01:42:44 +08:00
AleFlyX
633ca7656f Merge PR #2999: fix(embedding): keep transport retries independent of rate-limit retries
A read timeout after repeated HTTP 429s still gets a transport retry at the normal initial backoff. All 193 embedding tests passed.
2026-11-29 22:56:32 +08:00
AleFlyX
be2fe9104d Merge PR #2837: fix(rag): batch LlamaIndex rebuild checkpoints
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.
2026-11-29 16:32:15 +08:00
lytanjie
ab51601b89 fix(web): keep statistics notation as inline math (#2878)
* 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>
2026-11-29 15:29:03 +08:00
Zhuoran Wang
3ce3d47858 Fix quiz-attempt 500 when the Book entity has no chat_session_id (#2692)
* 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>
2026-11-29 15:28:55 +08:00
lytanjie
305eb7bf75 fix: parse inline math in note tables and statistics notation (#2737)
* 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>
2026-11-29 15:11:07 +08:00
lytanjie
284e06145d fix(web): render GFM tables in learner card stems (#2879)
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>
2026-11-29 14:53:07 +08:00
lytanjie
cf03cebdcb fix(web): split display fences that hug a matrix environment (#2880)
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>
2026-11-29 14:52:50 +08:00
欧八同学
a345d44aef fix: remember the selected consult partner per chat (#2775) 2026-11-29 14:52:34 +08:00
Benjamin Schwing
648443b5dd fix(chat): don't open the quiz settings sheet when a quiz session loads (#2950)
* 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>
2026-11-29 14:52:18 +08:00
mocias
23189ca690 fix(reading): keep Invidious picker controls inside its dialog (#3025) 2026-11-29 14:52:01 +08:00
Antonio-Faure
2df7cd1958 fix(web): center the new-partner wizard content (#2856)
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>
2026-11-29 14:51:44 +08:00
欧八同学
5a1bd72ca2 fix: give the glass session viewer an opaque background (#2774) 2026-11-29 14:51:27 +08:00
Leoy
566465dc42 fix(mastery): ignore knowledge-base sources that no longer resolve (#2752)
* 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.
2026-11-29 14:49:40 +08:00
Bingxi Zhao (Frank)
02b94669c7 ci(labeler): mirror requested reviewers into assignees on PRs 2026-11-28 13:01:20 -05:00
Qiu
506cea9d4f feat(desktop): finish Windows chat file actions (#3051)
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>
2026-11-28 13:09:15 -03:00
sriv144
83c98d5983 fix: isolate invalid UTF-8 partner records (#3039)
Co-authored-by: sriv144 <180610320+sriv144@users.noreply.github.com>
2026-11-28 12:29:58 -03:00
Carl
0b93ddd697 fix: use canonical npmjs.org URLs in web/package-lock.json (#3004) 2026-11-28 12:29:35 -03:00