feat(reader): make KOReader plugin sync non-blocking and resumable

Lifecycle handlers previously blocked on network work, so closing or suspending a book stalled the
device on slow or offline links. Persist snapshots first and drain them through a lifecycle outbox
with connected-state gates and phase-aware retries, so the UI stays responsive and pending work
survives restarts.

Move persistence behind a state manager with atomic flushes, and chunk sweeps, bulk downloads, and
annotation exchange through a background queue with checkpoints and transfer policies, so large
libraries make progress incrementally instead of restarting from scratch after an interruption.

Server side, add bulk manifest and page stats endpoints with batched queries and catalog query
filtering so the plugin can reconcile many books per round trip rather than one request per book.
This commit is contained in:
neon
2026-07-28 02:06:50 +00:00
parent 3aff8f521b
commit edc2a2ccfc
93 changed files with 12600 additions and 1458 deletions
@@ -76,6 +76,7 @@ assertEqual(hasRow(rows, "Last highlight sync"), false, "logged-out diagnostics
assertEqual(hasRow(rows, "Retry highlight sync"), false, "logged-out diagnostics hides highlight retry")
assertEqual(hasRow(rows, "Retry open-book match"), false, "logged-out diagnostics hides match retry")
assertEqual(hasRow(rows, "Test connection"), false, "logged-out diagnostics hides connection action without credentials")
assertEqual(hasRow(rows, "Recheck all book matches"), false, "logged-out diagnostics hides the match recheck")
plugin.settings.server_url = "https://bookorbit.example.com"
plugin.settings.username = "reader"
@@ -90,6 +91,9 @@ assertEqual(hasRow(rows, "Retry open-book match"), false, "file manager diagnost
assertEqual(hasRow(rows, "Test connection"), true, "file manager diagnostics keeps connection action")
assertEqual(hasRow(rows, "Open highlights"), true, "logged-in diagnostics shows sync state")
assertEqual(hasRow(rows, "Last highlight sync"), true, "logged-in diagnostics shows highlight summary")
-- "Sync all books" is incremental now, so the full rematch lives here as its
-- own explicit maintenance action.
assertEqual(hasRow(rows, "Recheck all book matches"), true, "logged-in diagnostics offers the match recheck")
plugin.ui = { document = {} }
plugin.getDocumentDigest = function()