readest/apps
Huang Xin bef3debcd1
feat(xray): give X-Ray its own Maximum Output Tokens setting (#8020) (#8066)
X-Ray sent no max_tokens, so a server with a low default output cap
(2048 tokens on the reporter's llama.cpp) cut each batch's JSON reply
short, and every entity past the cut was lost. The Context Dictionary's
Maximum Output Tokens applied only to dictionary lookups.

X-Ray now has its own Maximum Output Tokens row under Manage
Dictionaries > X-Ray. It is separate from the dictionary's, because
one X-Ray reply covers a whole batch of text and needs many times the
tokens of a dictionary entry. Blank keeps the provider's default, as
before. The value persists and syncs with the other dictionary
settings. The row reuses the existing "Maximum Output Tokens" and
"Provider Default" strings, so nothing new needs translating.

Tests that fail without the change (run before the implementation):
- xray.test.ts "asks for the output limit set for X-Ray, and the
  provider default without one": expected [undefined, undefined] to
  deeply equal [undefined, 8192]
- CustomDictionaries.test.tsx "saves an X-Ray output limit of its own":
  no spinbutton named "X-Ray: Maximum Output Tokens"
- custom-dictionary-store.test.ts and settings.test.ts (sync): the
  value was dropped on load and not packed for sync
All pass with the change.

Checks run: related suites (xray, dictionaries, custom-dictionary-store,
sync settings adapter, CustomDictionaries, XRayView): 37 files, 471
tests passed. pnpm lint and pnpm format:check passed.

Real use on dev-web (Chromium, Alice in Wonderland EPUB), against a
stub OpenAI-compatible server that caps replies at 2048 tokens when the
request has no max_tokens, like the reporter's server:
- origin/main sources: request max_tokens null, reply cut at 2048
  tokens (finish_reason length), X-Ray kept 24 of 80 characters.
- this branch, 8192 typed into the new field: request max_tokens 8192,
  full reply (finish_reason stop), X-Ray kept all 80. The dictionary's
  field stayed blank. The value survived a reload.
- The settings row was checked in light, dark, e-ink, RTL and at
  390x844.
Not run: a real llama.cpp server (none installed here), and the on-device
Apple Intelligence path, which receives the same limit.

Reported by noideaforeal on GitHub.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 14:28:32 +01:00
..
readest-app feat(xray): give X-Ray its own Maximum Output Tokens setting (#8020) (#8066) 2026-11-28 14:28:32 +01:00
readest-calibre-plugin feat(calibre): add multi-language support (#6768) 2026-10-13 18:46:06 +02:00
readest-crosspoint-plugin feat(crosspoint): sign in with a code through /api/auth/device (owner: "use a more generic path for /api/crosspoint/device/code") (#7859) 2026-11-24 04:21:00 +01:00
readest.koplugin feat(kosync): match file names across readers with a format or a book's own name (#7864) (#7873) 2026-11-24 08:32:36 +01:00