Skip to content

BookOrbit: no Grimmory work in the background (speed check) - #360

Merged
9retirement6irk merged 31 commits into
mainfrom
fix/bookorbit-no-grimmory-work
Nov 23, 2026
Merged

9retirement6irk merged 31 commits into
mainfrom
fix/bookorbit-no-grimmory-work

Conversation

@9retirement6irk

Copy link
Copy Markdown
Owner

Speed check with BookOrbit, and the two Grimmory leftovers it found. Built on #359 (merge #347 to #359 first, in number order).

What changes for the user

Signed in to BookOrbit, GZreader no longer starts a background process to refresh a Grimmory login before every download and library refresh. BookOrbit has no such login, so the process did nothing, but starting one costs time and memory on an old Kindle. Grimmory's bookmark module is also no longer loaded when the server is BookOrbit. Nothing changes with Grimmory.

What I measured

Kindle 3 in the emulator, the same EPUB opened, read for 20 page turns and closed, twice signed in to nothing and twice signed in to BookOrbit (the book matched, so progress, highlights, bookmarks and reading time all sync). CPU seconds in GZreader's own process, after the fix:

open 20 page turns close
signed in to nothing 1.63, 0.95 2.48, 3.23 1.48, 1.00
BookOrbit 0.85, 1.19 3.46, 1.63 0.79, 0.46

The runs vary more between themselves than between the two cases: no cost from BookOrbit shows up in the reading itself. The syncing happens in background processes, six per book session (pull, bookmarks, highlights, progress, reading time, reading stats).

  • Requests made over both BookOrbit sessions: 12 kinds, every one a BookOrbit route (koreader/users/auth, plugin/version, match-check, progress, the two exchanges, page-stats, catalog/...). No Grimmory route was called.
  • Grimmory-only modules loaded with BookOrbit: none (gzreader_bookmarks, gzreader_annotations, gzreader_cfi, gzreader_copy, gzreader_migrate all not loaded). Before the fix gzreader_bookmarks was.
  • Before the fix a seventh job, "refresh login", ran in the first session.

This is the emulator, not a real Kindle, and not a real server: network time on a real BookOrbit isn't in these numbers.

How

  • gzreader_async.lua: Async.ensureToken answers at once for a server without tokens.
  • main.lua: the bookmarks module is required where it's chosen, not at the top.
  • gzreader_grimstats.lua: its job is tagged "reading stats" (was "grimmory stats").
  • tools/gzreader/emulator/bookorbit_speed.lua: the measurement above, repeatable.

Tested

Full suite: 0 suites failed. Plugin harness 2851 passed.

To try on a device

On the Kindle 3 or DX signed in to BookOrbit: open a downloaded book, turn 20 pages, close it, then send the diagnostic log. The book open: line gives the time to compare with Grimmory's on the same book, and there should be no refresh login line.

Not labelled beta, as asked for the BookOrbit PRs.


Generated by Claude Code

The stand-in the BookOrbit work is tested against: the KOReader sign-in,
version and capabilities, catalog, covers, downloads, match-check, progress
(plugin and KOSync), and the main API's key, audiobook manifest, audio files
and listening position. Written from BookOrbit's routes and field names at
commit e60ab43; none of its code is copied.

tools/gzreader/bookorbit-probe.py asks a real server the same questions and
prints status codes and field names only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
A second client with the Grimmory client's methods (gzreader_bookorbit.lua),
answering in the shapes the Catalog, the index, covers and downloads already
read. plugin.api stays the same table; its class changes with the sign-in
(store.backend). Sign-in is BookOrbit's KOReader sync user: only the
password's MD5 is kept (with the other secrets, off the USB drive).

Nothing is sent to BookOrbit yet (books_only): progress, highlights,
bookmarks, statistics, shelves and audiobooks come in their own steps.

Each server has its own book ids: the other server's list of downloads is
put aside (the files stay), and covers are kept in separate folders.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Grimmory, BookOrbit, or on its own (books sent from a browser). The page
after it offers what fits the answer: the setup page with that server picked,
typing its sign-in, or the Send books page. The guide's sync page says what
is true for the answer. The answer is kept (store.book_source) as the guide's
default; it switches nothing off.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…g, emulator check)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
… guide's first question

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
run.sh's sections are rewritten by #321, so a new suite there kept this out
of the test build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
… of run_tests.lua

Other open PRs add their blocks at the end of the file, which kept this out
of the test build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…icates when Python has none

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…er's does

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
A real server (v3.9.0) lists a book's main file as "primary", not "content":
with only "content" accepted, no book would have downloaded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…rprint

Progress goes out by the file's fingerprint (KOReader's partial MD5) with
KOReader's own percentage and XPointer, and comes back from the book's
catalog record in the shape gzreader_sync.lua already reads. Books in the
folder that aren't tied to a BookOrbit book are matched with match-check.

What the server takes is in the client's `supports` (main's serverCan);
one sentence built from it says what is and isn't synced, wherever shown.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
gzreader_bo_annotations.lua speaks BookOrbit's exchange: the keys of every
highlight in the book, the ones new or changed since the last exchange, and
back what this Kindle lacks (add, edit, delete), acknowledged once applied.
Same interface as the Grimmory module; main picks by book server.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
gzreader_bo_bookmarks.lua speaks BookOrbit's bookmark exchange (keys of the
book's bookmarks, the new ones, and back what to add and remove; a bookmark
BookOrbit gives is dated here and acknowledged with its key). Only when the
server advertises bookmarkSync. Same interface as the Grimmory module.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
List (books/query), details and chapters (the manifest), download with
resume (asset content, Range), and the listening position both ways
(playback-state, with its revisions and a fresh operation id), all in the
shapes gzreader_audiobook.lua reads Grimmory's in. An audiobook's id here is
"a<id>": a BookOrbit book can be an ebook and an audiobook under one id.

The key is checked at entry (auth/me), kept with the other secrets, never
shown back or logged. The probe now also checks whether the e-reader sign-in
alone can download audio.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Reading time: the page rows of KOReader's statistics database since the last
upload, per BookOrbit book (by fingerprint), to /koreader/plugin/page-stats,
read and sent in a background process a moment after a book closes
(gzreader_bo_stats.lua). Ratings: the client's putRating and the record's
rating, through the existing rating sync.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
A book's menu can change your BookOrbit collections through the main API
(GET collections, POST/DELETE collections/:id/books) when the API key is
saved. Only collections that are yours are offered. Without the key the
menu says where to enter it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
The Catalog's BookOrbit card gets Request a book (title, author, book or
audiobook) and My book requests (state, the decision's note, cancel),
through BookOrbit's book-requests routes with the API key. The key's
setting is now "BookOrbit API key", since collections and requests use
it as well as audiobooks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
The setup page can sign in to BookOrbit with its address and an API key.
The key (with the KOReader sync permission) reads the account's sync user
name and, from the server's preconfigured-plugin zip, its sync key; the
Kindle then signs in as usual. With no sync sign-in on the account, one
is made under the account's name with a random password. Nothing in the
zip is kept or run, and neither key is logged or shown back.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
… may do

Step 8 groundwork. The probe now sends the browser's preflight and a
signed-in request as the sync page's origin and says whether the server
(its reverse proxy) answers it, and reports what the API key is allowed
to do: the KOReader sync sign-in, collections, book requests. The mock
can stand behind a proxy that lets one origin in.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Home's reading stats widget takes its numbers from the server signed in
to: Grimmory's user stats as before, or BookOrbit's catalog dashboard
(streak, goal, minutes per day for a year, badges). A tap opens a page
with charts drawn from those numbers. The mock gets the dashboard route,
and one comment line in its stand-in zip that matched BookOrbit's source
is reworded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Async.ensureToken forked a do-nothing "refresh login" process for every
download and index run with BookOrbit (it has no access token to check).
It now answers at once. Grimmory's bookmarks module is required only when
Grimmory is the server. The stats job is tagged "reading stats". A new
emulator tour compares a book session signed in to nothing and to
BookOrbit and lists the requests made.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
@9retirement6irk 9retirement6irk added the beta Include in the beta branch (test builds over Wi-Fi) label Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request is labelled beta but couldn't be combined into the beta branch (with main and the other beta pull requests before it): these files clash:

  • plugins/gzreader.koplugin/gzreader_changelog.lua
  • plugins/gzreader.koplugin/gzreader_gzip.lua
  • plugins/gzreader.koplugin/main.lua

It stays out of the test builds until that is settled (rebase onto main, or onto the pull request it clashes with).

#338 gives Gzip.inflate a second argument of its own (a size limit), so
changing its signature here kept this PR and everything built on it out
of the test build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
github-actions Bot added a commit that referenced this pull request Nov 23, 2026
# Conflicts:
#	plugins/gzreader.koplugin/gzreader_changelog.lua
github-actions Bot added a commit that referenced this pull request Nov 23, 2026
# Conflicts:
#	plugins/gzreader.koplugin/gzreader_changelog.lua
github-actions Bot added a commit that referenced this pull request Nov 23, 2026
# Conflicts:
#	plugins/gzreader.koplugin/gzreader_changelog.lua
github-actions Bot added a commit that referenced this pull request Nov 23, 2026
# Conflicts:
#	plugins/gzreader.koplugin/gzreader_changelog.lua
@9retirement6irk
9retirement6irk merged commit 22c3983 into main Nov 23, 2026
1 check passed
@9retirement6irk
9retirement6irk deleted the fix/bookorbit-no-grimmory-work branch November 23, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta Include in the beta branch (test builds over Wi-Fi)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants