Skip to content

Xteink readers: CrossInk reading stats, a CrossPoint plugin, account import (experimental) - #325

Merged
bndct-devops merged 16 commits into
mainfrom
feat/crossink-stats
Nov 22, 2026
Merged

bndct-devops merged 16 commits into
mainfrom
feat/crossink-stats

Conversation

@bndct-devops

@bndct-devops bndct-devops commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

What changes for users

  • CrossInk's built-in sync. An Xteink reader on CrossInk 2.0 or newer sends its reading to Tome over its KOReader Sync account: sessions, pages per session from the reader's page counter, clippings, finished books, and reading from before the first sync (shown as "before sync" totals and reader days in the streak and Calendar).
  • A plugin for CrossPoint 2.0 and CrossInk. The reader sends each reading session by itself when it goes to sleep: reading time and progress, no pages. It is connected by scanning a code from the reader's screen and confirming it in Tome. The download holds only the server's address.
  • Books without a file. A book the reader reports that is not in the library gets a record of its own, marked "No file" in the Library, so its reading has somewhere to land.
  • One book on two devices. A sideloaded book read on a CrossInk reader and on a KOReader device with the TomeSync plugin is one book in Tome, with one position.
  • Import of a CrossPoint Sync account export, under Settings > Import reading history.
  • Settings > Xteink readers, a new section with both ways and the connected readers. A new docs page "Xteink readers" compares the two and says which to use.

Everything here is marked experimental.

How a reader is connected (plugin)

The reader asks Tome for a code and shows it with a QR code. The signed-in user confirms the code on /link-reader. The reader then collects a key of its own, listed under Settings > Access as "CrossPoint reader" and revocable there. A reader key opens only the reader's routes; KOReader plugin keys do not open them, and reader keys do not open the TomeSync routes.

API

All under /api:

  • CrossInk's sync: /api/v1/api/v1/stats/{summary,global,sessions,books} and /clippings/{document} (the firmware adds its own /api/v1 to the KOSync address).
  • Plugin: /api/v1/crosspoint/device/code, device/token, device/{code}, device/approve, sessions, catalog, status, plugin.zip.
  • GET /api/books takes include_no_file (off by default).

Changes that reach KOReader plugin users

backend/api/tome_sync.py changes in three ways:

  • Position, rating, session, annotation and status routes accept the user's own book without a file, not only library books.
  • resolve can return the book a KOSync reader linked the same file to.
  • GET position leaves out a locator that only names a chapter start, so the plugin goes by percentage.

Schema change and upgrade

Additive only. New tables are created at startup. Guarded ALTER TABLEs add api_keys.kind, reading_sessions.pages_attributed, kosync_document_map.guessed and columns on the reader stats tables; each step checks first. An older version ignores all of it: going from the tester's image to this one and back was run on one data volume.

Tested

  • pytest tests/ -q: 2,304 passed on this branch merged with v3.1.0 (three telemetry tests need the telemetry switch at its default; they pass then)
  • npm run build passes, message catalogs re-extracted, docs site builds
  • CrossInk's desktop simulator at v2.0.0-rc, which is the firmware's own code: built-in sync, and for the plugin connecting by code, reading, sleep, delivery and the list on the reader
  • CrossPoint 2.0.0's delivery code for the plugin, compiled on a computer
  • KOReader emulator with the current TomeSync plugin (build 55) against this branch: a position stored and restored by its exact place, a reader's chapter-only position restored by percentage (62%), a sideloaded file matched to the book the reader reported, opened at the reader's 37% and synced back
  • An Xteink X3 on CrossInk for the built-in sync, the import and reading one book on a Kindle and the Xteink, by @gabrieledettorre

Known limits

  • The plugin has not run on a physical reader.
  • On official CrossPoint only the delivery code was run, not a whole reading session.
  • The plugin's queue on the reader holds about 14 sessions; a reader offline for longer loses the oldest.

CrossInk 2.0 sends reading sessions, daily counters and totals next to
KOSync progress. Tome now answers its stats probe and stores each sitting
as a reading session, with a receipt of what the reader last reported so a
trim or delete in Tome survives a re-send.

Three new tables, no change to existing ones. Clippings answer 501 on
purpose: a 404 would make the reader drop stats for the whole server.

Also: per-book pace divides only by time from sessions with pages, the
KOSync link endpoint checks book visibility, and the account export
includes the new data.
…imental)

A sideloaded file is only a hash to Tome, so its progress and uploaded
reading sessions had no book. A reader that sends document metadata with
its progress push (CrossInk: Send Document Metadata) now names the book:

- one library book that is the same book: the document is linked to it
- none: a book record without a file (status "no_file") is created, so the
  reading shows on Home, in the stats, the calendar and the session list
- several: left to the manual link, which now shows the reader's title

Matching is exact, never by similarity: same title and authors (any
order), no disagreement about the volume, an ISBN only with the title or
author agreeing, and never a title without an author.

A file-less book is private to its owner and stays out of everything that
lists or serves files, including duplicate detection. Linking the document
to the real book hands over sessions, read status, finish date, rating and
review, and removes the file-less record. Deleting one stops tracking that
file. One new table (kosync_document_meta); no existing table changes.
…CrossPoint Sync import (experimental)

Four additions on top of the stats sync and the file-less books:

- Library: a user's own file-less books appear in the web Library and in
  library search with a "No file" badge (opt-in query parameter, so the
  iOS app, the KOReader plugin and OPDS keep getting books with files
  only), never go into a library, and get a "Missing: File" filter.
- Clippings: the reader's saved passages sync both ways over its extended
  API (upload, cursor download, deletion markers, revisions that never go
  back) and show read-only on the Highlights page, the book page and the
  Home spotlight, in the viewer's time zone. Never sent to KOReader devices.
- Per-book pages: the reader's lifetime snapshot per book is kept
  (kosync_book_stats) and fills a book's all-time Pages and Pace, and the
  all-time per-book table and pages total, with pace over the reader's own
  time. Nothing dated changes.
- Import: Settings > Import reading history takes a CrossPoint Sync account
  export. Preview and import run the same code in a savepoint; the preview
  writes nothing and releases the lock. Sessions, statuses (Tome's own win),
  progress, clippings, per-book snapshots and daily counters come over
  through the same matching as the live sync. Idempotent, all or nothing,
  20 MiB limit, tracker documents skipped.

Two new tables (kosync_clippings, kosync_book_stats); no existing table
changes. Verified with the firmware simulator on both firmware versions,
a Docker round trip 3.0.0 -> branch -> 3.0.0 and the full suite.
…tal)

The reader's per-book page counter only grows and is sent whenever it
changed, so its growth between two snapshots is exactly the pages turned
in between. That growth is now shared out over the reader's sessions
received between the two snapshots, by reading time, and written onto
them as attributed pages (reading_sessions.pages_attributed, added by an
idempotent startup migration; v3.0.0 still reads and writes such rows).

Windows use the time Tome received each session, not the reader's clock.
Growth that arrives before its sessions waits for the next snapshot and
is then split over all of them; every window is closed, a lower counter
starts a new base and takes nothing back, and a sitting that spans a sync
takes its share of the next growth. reader_pages returns only the part of
a counter no existing session carries, so a book's all-time pages equal
the reader's counter, also after a trim, a delete or a re-send; trimmed
sessions keep the reader's pace. Imported history stays time only.

Daily charts, the calendar, session rows, page goals and pace per session
now include CrossInk reading; the session log shows pages for every
source, with a mark on attributed ones.
Every KOSync progress push has been logged in reading_history since the
feature existed, but nothing read it for stats. The book page's progress
line now takes the furthest position of each reading day from those pushes
and merges it with the per-session progress by max, so books read on a
CrossInk reader get the line; a push on a day without reading carries
forward to the next reading day. Pushes logged before the document was
linked to a book follow the link (attach_history at every link site; the
CrossPoint Sync import links them all in one statement). A composite
index on reading_history (user_id, book_id) is added by an idempotent
startup migration.
…imental)

The Pages total of a series' reading stats summed session pages only, so a
series read on a CrossInk reader showed the attributed part and missed the
counter's rest. It now adds the per-book reader pages past what sessions
carry, and a counter-attributed session that imported KOReader page-stats
supersede adds nothing, so the counter is counted exactly once.
…position log

On a book with KOReader page-stats the line only used sessions that still
counted for time, which dropped every plugin sitting the page-stats covered,
the only rows carrying progress_end. A Kindle book got a line from the few
uncovered sittings (ending at 63% on a finished book) or none at all.

Every session's position counts now; position_history merges in per day the
way reading_history does for KOSync pushes, with the rows before a restore
that lie above the restored position left out. Verified on a copy of the prod
database: 9 more books get a line, 11 finished books now end at 100%, no
other field changed.
…rimental)

A book Tome only knows from a KOSync reader, without a file, can be read
on a TomeSync plugin device too. The plugin's reading routes (position,
session, rating, status, highlights) accept the user's own book without
a file. The plugin's lookup follows the reader's document link by
content id or by the MD5 of the file name, then falls back to the title
in the file name; a link that was only a guess (new nullable column
kosync_document_map.guessed) is never followed. For such a book the
reader's position is served to the plugin without
TOME_KOSYNC_POSITION_BRIDGE, and a locator that only names the chapter
is dropped so the plugin jumps by percentage.
…first sync, the reader's finished flag (experimental)

The reader's lifetime snapshot holds totals and a calendar of read days from
before it first synced to Tome. The days now count for streaks and are marked
on the Calendar; the Stats page set to All includes the earlier time, sessions
and pages.

The first page counter of a book that is new to the reader and to Tome is
given to the sessions sent with it, also for a base stored earlier, at the
book's next sync. A book the reader reports as finished is marked as read.
@bndct-devops
bndct-devops merged commit 8cd9d97 into main Nov 22, 2026
8 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.

1 participant