mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 03:00:52 +08:00
Immersive Reading extracts documents synchronously — an EPUB walks its whole spine and a PDF renders every page through PyMuPDF — but the router called that work directly from its async handlers. The API runs one event loop per worker, so a document being opened or uploaded parked every other request: the session title and transcript of the conversation being switched to, progress polling and cancellation all waited behind the parse (#2054). Run the upload extraction and the material detail build through asyncio.to_thread, matching how the rest of this router and capabilities/reading/tools.py already call the same store API. Also load the outline once. _detail() read it, then render_outline() read it again; for an EPUB whose stored rows still lack publisher anchors each read can re-parse the whole package through _upgrade_epub_outline. Rendering is split into format_outline(manifest, entries) so the rows already loaded are reused, and render_outline() keeps its signature for existing callers. Regenerated the router index fingerprint for the changed router source.