Skip to content

Fix reader hanging on PDFs with no extractable content - #41

Merged
arphen merged 2 commits into
mainfrom
fix/reader-infinite-loading-no-content
Aug 20, 2026
Merged

arphen merged 2 commits into
mainfrom
fix/reader-infinite-loading-no-content

Conversation

@tomazzinko

Copy link
Copy Markdown
Collaborator

Summary

  • Reader no longer spins on "Loading book..." forever when ingestion finishes without producing any readable chapter — it now shows a clear error instead.
  • Fixed the underlying cause for PDFs: since a PDF is ingested as one giant "chapter," a genuine table of contents near the start could trip the TOC classifier and get the entire document excluded, not just the TOC. Chapters are now only classified as TOC-and-excluded when they're actually TOC-sized.

Test plan

  • npx tsc --noEmit
  • Full test suite (800 tests) passes
  • Verified end-to-end against a real 145-page PDF with a front-matter TOC: word count went from 0 to 35,858

When background ingestion finishes without producing any readable
chapter (e.g. a scanned/image-only PDF with no usable OCR text), the
reader was left spinning on "Loading book..." indefinitely with no
error, since errors from processChaptersInBackground were silently
swallowed. Now it surfaces a clear error state instead.
PDFs are ingested as a single chapter, so a legitimate table of
contents near the start could trip the TOC heuristic and exclude
the whole document, not just the TOC. Only fully exclude a chapter
as TOC when it's actually TOC-sized; also bound the TOC scan window
so unrelated numbered lists deep in a large document can't
accumulate false-positive matches.
@arphen
arphen merged commit 0132321 into main Aug 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants