* fix: ignore code fences inside <think> reasoning when parsing JSON
A fence drafted inside a <think> block was picked as the payload before
the reasoning was stripped, so the real JSON after the block was lost.
* fix: decode fence-in-string JSON from the chosen block's offset
The fence-in-string fallback searched the response for the truncated
block text, which can also appear inside a <think> draft, so the draft
was decoded instead of the payload. Keep the chosen fence match's start
offset and decode from there, allowing raw newlines in string values.
* 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.
@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.
Local dev repairs for #2132, #2133.
Turkish UI prefers Windows-1254 after UTF-8; strict explicit encoding is available for mixed legacy collections. Tested both upload bytes and file reads, short Turkish strings, GBK, GB18030 and Windows-1252. Encoding and memory suite: 398 passed.
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
parse_json_response extracted only the first fenced block, so a reply
that shows a code snippet (for example a ```python block) before the
fenced JSON payload lost the payload: it returned a list literal from the
snippet or the fallback. Prefer the first fenced block that holds a JSON
object or array, and keep the first block otherwise.
td/th were missing from _EPUB_BLOCK_TAGS, and nothing else emits a
separator between table cells. Both EPUB text renderers (_epub_render_text
and the _EpubHTMLTextParser fallback) only break on block tags, so they
relied on source whitespace between cells. Commercially produced EPUBs
often ship minified, whitespace-free XHTML, where a row like
<tr><td>Revenue</td><td>100</td><td>Q1</td></tr> extracts as the single
glued token "Revenue100Q1" — unreadable data fed to the model.
Add td and th to _EPUB_BLOCK_TAGS so each cell is separated, the same way
li/dd/dt already are. One constant fixes both renderers.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
On a case-insensitive filesystem, week2/readme.md flattens onto the
README.md that week1/README.md already wrote in the same call. Since
members are created with "xb", that raised FileExistsError and the
upload router rejected the whole archive with a 400 naming the server
path. Before "xb", the later member silently replaced the earlier one.
Treat it like any other flattening collision: when the destination is
the same file as a member this call already wrote, skip it as a
duplicate. A pre-existing file with a case-only name match is still
refused, and case-sensitive filesystems keep both names as before.
Use worksheet cell coordinates to retain missing leading and interior cells. Bound padding to Excel columns A through XFD and keep sequential fallback for missing or malformed references.
AI-assisted: implemented and validated with OpenAI Codex; real saved openpyxl workbooks provide independent row oracles.
Keep valid empty presentation lists empty even if orphan slide parts remain. Only missing or unreadable metadata permits filename fallback; external relationships stay excluded.
Resolve presentation slide IDs through their relationships instead of sorting part filenames. Share ordering across both OOXML extraction paths and preserve metadata-free extraction.
AI-assisted: implemented and validated with OpenAI Codex; actual generated decks checked against python-pptx.
Use an incremental UTF-8 decoder to complete only a code point split by the 8192-byte sample while still rejecting invalid bytes and incomplete input at EOF.
AI-assisted: implementation and regression tests prepared and validated with OpenAI Codex. Maintainer review is pending.
Count parentheses as outer entry delimiters only for parenthesized entries and outside braced field values, so half-open intervals do not discard valid references.
AI-assisted: implementation and regression tests prepared and validated with OpenAI Codex. Maintainer review is pending.
safe_extract_zip writes members one by one into the KB raw/ directory.
When a later member tripped a zip-bomb guard or failed its CRC check, the
upload was rejected with HTTP 400 but every member written before it, and
for a CRC failure the corrupt member itself, stayed on disk.
Delete the files this call wrote before the error propagates, and drop a
member's partial output when it fails mid-read.
In a quoted BibTeX value a double quote is written inside braces, as in
title = "The {"}Quoted{"} Paper". The converter ended the value at the
first quote, so the title became "The" and the entry lost its remaining
fields. Only end a quoted value at a quote outside braces.
Authors were split on every " and " after braces were removed, so a
braced corporate name such as {Food and Agriculture Organization} became
two people, and "King, Jr., Martin Luther" came out as "Jr., Martin Luther
King". Split names and name parts only outside braces, and order the
three-part "Last, Jr, First" form as "First Last Jr".
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.
decode_escaped_unicode_for_display repairs double-encoded \uXXXX runs
(#973) with the unicode_escape codec, which turns a surrogate-pair escape
for an emoji into two lone surrogates instead of one emoji. The
result cannot be encoded as UTF-8, so an ask_user card or mastery question
whose escaped text contains an emoji fails when the event is persisted to
SQLite or sent over the WebSocket.
Decode each run as a JSON string instead, matching the web decoder's
JSON.parse, and leave runs with an unpaired surrogate escaped.
_scan_entry treated every double quote as the start of a quoted value,
even inside a braced one. An accent such as {\"u} in
author = {M{\"u}ller, Hans} therefore opened a "quoted" run that swallowed
the entry's closing brace, and the whole entry was silently dropped from
the converted bibliography. Only treat a double quote as a delimiter at
the entry's top level, as BibTeX does.