* fix(koplugin): wait for network readiness before the wake pull
A Kindle's firmware can restore Wi-Fi after KOReader resumes without
emitting NetworkConnected. DNS readiness can already be true before a
default route exists, so the one-second wake pull fails and never retries.
Check for both an address and a default route every two seconds for up to
60 seconds before scheduling the existing pull. Reuse background_pull_task
so closing cancels the wait and other lifecycle triggers replace it.
After the limit, retain the existing pull and offline handling.
Verified on top of origin/main a1ea6a9cb:
- pnpm test:lua: 503 successes, 0 failures/errors.
- pnpm lint:lua: passed.
- pnpm test --run: 1219 files / 14539 tests passed, 4 files / 16 tests skipped.
- pnpm lint: passed; one informational suggestion outside this diff.
- git diff --check: passed.
- Restoring the old onResume call makes four new regression tests fail:
three pulls instead of zero before readiness, and 1 second instead of 61
before the bounded fallback. Restoring the fix passes all 503 tests.
- Real Kindle Voyage, KOReader v2026.07.2: power-button sleep/wake with a
controlled 12-second default-route gap reproduces Network is unreachable
without the fix and no retry when the route returns. With the fix, all
three pulls start after the route returns without NetworkConnected;
configs returns HTTP 200. Notes/stats subsequently hit wantread TLS
timeouts, so complete notes/stats sync was not verified.
- Temporary device probes removed; the clean fix remains installed.
Fixes#7159.
Reported by tramch on GitHub.
Co-Authored-By: Claude Code <noreply@anthropic.com>
* fix(koplugin): preserve the wake wait across reconnects
A reconnect can arrive once Kindle Wi-Fi has an address but before the
default route exists. Keep an existing background task rather than replace
its route-aware wait or restart its original 60-second limit. Recheck auto
sync, sign-in, and the open document before continuing each wake poll.
Four new regression tests fail on db2f5c571: a disabled wait retains one
task, route restoration pulls config/notes after auto sync is disabled,
reconnect pulls three times before a route exists, and reconnect changes
the fallback from 61 seconds to 57. All 507 Lua tests pass with the fixes.
Verification:
- pnpm test:lua: 507 successes, 0 failures/errors.
- pnpm lint:lua and git diff --check: passed.
- pnpm test --run: 1219 files / 14539 tests passed; 4 files / 16 tests skipped.
- pnpm lint: passed, one informational suggestion outside the diff.
- pnpm test:browser: aborted with route.fulfill: Route is already handled
in the Vitest Playwright provider; tracked in #7216. Not counted as a pass.
- These review edge cases were not rechecked on the Kindle: it was in the
middle of downloading a KOReader update and was left untouched. The
original route-gap device verification applies to db2f5c571 only.
Reported by tramch on GitHub (#7159).
Co-Authored-By: Claude Code <noreply@anthropic.com>
---------
Co-authored-by: Claude Code <noreply@anthropic.com>
Since KOReader #16148 (in nightlies after 2026.07.2), CoverBrowser's list
and mosaic items format authors through `menu.ui.bookinfo`. The Readest
Library menu was built without a `ui`, so with CoverBrowser enabled the
library rendered empty and turning the page crashed KOReader
(listmenu.lua:454: attempt to index field 'ui'). openLibrary now passes
the plugin's UI, and the widget hands it to its Menu. Stable KOReader
doesn't read `menu.ui` there, so nothing changes on it.
Verified: spec/main_library_spec.lua "passes the plugin's UI to the
Library widget" fails without the change (Expected objects to be equal.
Passed in: (nil)) and passes with it; all 489 koplugin specs pass under
LuaJIT + busted (ubuntu:22.04 container, installed as CI does);
luajit -bl parses the changed files. Not run on a Kindle or a KOReader
nightly build; the local emulator predates #16148.
Reported by Zayatoshi on GitHub (#6823), who traced the cause.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Readest Cloud is reached through the readest.supabase.co vanity subdomain,
and Supabase allows either a vanity subdomain or a custom domain, not both.
Point the app, the KOReader plugin and the Calibre plugin at the project's
own URL, which keeps working under either, so the vanity subdomain can later
be dropped in favour of a custom domain without breaking updated clients.
supabase-js stores the session under a key derived from the URL's first host
label, so changing the host would sign everyone out. Readest Cloud hosts keep
the original sb-readest-auth-token key; self-hosted URLs keep the derived one.
KOReader saves supabase_url with the rest of its settings, so existing
installs are moved off the vanity host on init; custom URLs are untouched.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(koreader): improve reading progress sync
* docs(koreader): document progress sync behavior and limitations
* fix(koreader): harden sync auth, conflict handling, and error reporting
* fix(koreader): keep non-auth 403 reasons and report the failed library sync step
* fix(koreader): move backward on manual pull only to an exact position
A manual pull could jump back when the remote xpointer only resolved
after trimming to a parent node (a chapter start or /body), since a
parent orders before its children. Manual pulls still go backward to an
exact page or an xpointer that resolves untrimmed; a trimmed xpointer
only ever moves forward. Automatic pulls stay forward-only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* i18n(koreader): translate sync error messages
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(koreader): report a pulled position whose chapter is missing
Trimming an unresolvable xpointer fell back to /body, which resolves in
any book, so a pull reported success for a position it could not use.
Stop trimming above /body so such positions count as unusable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Sergey Ivanov <sergejs.ivanovs@applyit.lv>
Co-authored-by: Huang Xin <chrox.huang@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
In this way, user will not tap the "Log out" accidently.
If the "Log out" item is the first menu, its position is the same as
"Readest" entry at the top level. Then user can easily log out
accidently if he taps "Readest" twice.
Nearby BookDrop is on by default, so the plugin starts it on its own at
launch, on wake and when Wi-Fi connects. When that start failed (seen on
Kobo as "could not find a free port"), the error message was shown each
time, to users who never turned the feature on.
A start the plugin makes by itself now logs the failure instead of
showing it; turning BookDrop on or sending a book still shows it.
pickPort also returns its error, which every failed start now logs, so
the cause on affected devices can be read from crash.log.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(localsend): brand the LAN transfer feature as Nearby BookDrop
Users drop books to nearby Readest devices, so the feature now carries a
Readest name instead of surfacing the LocalSend protocol as its own.
Renamed every user-facing string in the app (Settings > Integrations row,
subpage header, enable toggle, device-picker empty states, iOS
local-network permission prompt) and in the KOReader plugin (menu entry
plus its status, error and transfer messages). All 34 JSON locales and 33
.po catalogs are updated in place, so every existing translation survives
with only the brand token swapped. The brand itself stays untranslated in
every locale, the same way LocalSend, Readest and Word Lens already do.
Code identifiers are untouched: services/localsend, LocalSendManager, the
localsend_* Tauri commands and the localsend_enabled settings keys all
keep their names, so there is no migration and no behaviour change.
Strings that mean the third-party app still say LocalSend, because
Readest really does interoperate with LocalSend clients and users need to
know that. Action labels stay action-shaped rather than branded: the
multi-select "Nearby", the "Send to Nearby Device" context menu item and
the koplugin's "Send to nearby Readest devices" button are unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore(i18n): translate the missing Audiobookshelf strings
The Audiobookshelf pairing dialog and the novel-import title suggestions
shipped 15 keys that never reached the catalogs, so every locale fell
back to English. `pnpm run i18n:extract` now adds nothing.
Translated all 34 locales, reusing each file's established terminology
(Hoerbuch/Audiokapitel, luisterboek, ljudkapitel, 오디오북/챕터, 有声书)
rather than inventing new words. Audiobookshelf itself stays
untranslated, as it already was. The pluralised
"{{title}} ({{count}} chapters)" is filled per locale plural category,
six for Arabic down to one for CJK, with the noun declined correctly.
Also fixes five Romanian keys whose interpolation variable names had been
translated ({{eroare}}, {{dimensiune}}, {{fisier}}, {{formate}},
{{numar}}). i18next cannot match those against the English key, so those
strings rendered the literal braces to Romanian users.
Known gap left alone: the Tibetan catalog repeats one wrong string across
the Migration and file-copy keys and drops two placeholders. Fixing it
needs a real Tibetan pass, not a mechanical edit.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore: record the Nearby BookDrop branding decision in agent memory
Captures what stays `localsend` in code, why the brand is never
translated, and the i18n catalog findings from the same pass, so the next
session does not re-derive any of it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(i18n): apply CodeRabbit review findings on the new translations
Five findings held up against each file's own terminology:
- ja: the chapter range rendered as "第3 - 8章", an abbreviated form with an
ASCII hyphen. Now "第3章~第8章", the standard notation.
- ru: the file pairs audiobooks with сопоставить/сопоставление throughout,
but the two new unpair strings used открепить, which means "unpin".
- ka: same shape. The file links with დაკავშირება, so the unpair strings now
sever that link (კავშირი გაწყდა) instead of using გაითიშა, which also
reads as "switched off".
- id: "Toggel" is not an Indonesian word and 9 of the 12 Toggle keys already
use "Alihkan". Fixed all three that carried it, not just the flagged one.
- th: เปลี่ยน means "change"; 9 of the 12 Toggle keys already use สลับ. Same,
all three fixed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(koplugin): never bring Wi-Fi up for auto sync, rerun the pull on NetworkConnected
Fixes#5838. Also the "prompt" shape of the same mechanism, #4113 and #2137.
With Auto sync on, the pulls on book open (onReaderReady) and device wake
(onResume) went through NetworkMgr:willRerunWhenOnline. When the device is
offline that calls beforeWifiAction, which on devices where KOReader drives
the radio (Kobo, Kindle, PocketBook) is modal on the UI thread: with "Action
when Wi-Fi is off: prompt" it stacks three "Do you want to turn on Wi-Fi?"
boxes (one per pull) on every open and wake, and with "turn on" it shows an
uncancellable "Scanning for networks..." for about 30 s when no known access
point is in range. Background pushes never did this; only the pulls forced
Wi-Fi up.
Background pulls now behave like background pushes: they run when the device
is already online and skip silently otherwise. A skipped pull sets
pull_pending_offline and onNetworkConnected reruns it once the device is back
online. KOReader turns Wi-Fi off on every suspend, so on Kobo/Kindle this
rerun (after KOReader's own silent "Restore Wi-Fi connection on resume") is
the path that actually pulls on wake. Interactive pulls (menu taps, gestures)
keep going through willRerunWhenOnline like every other interactive KOReader
network action.
The close-time push drops NetworkMgr:goOnlineToRun for the same reason: with
"turn on" it blocked the UI thread on the same scan on every close, and with
"prompt" (KOReader's default) it silently did nothing anyway. When offline the
close-time push now skips. Progress reaches the server on that book's next
online page turn and stats from their push cursor; annotations edited offline
depend on the pre-existing shared notes cursor (see the PR).
The three identical open/wake/reconnect pull schedulers are folded into
scheduleBackgroundPull with one task handle and one BACKGROUND_PULL_DELAY, so
rapid events coalesce and onCloseWidget cancels whatever is pending.
Tests: spec/main_offline_pull_spec.lua covers the gate for background and
interactive pulls (including the rerun closure keeping its arguments), all
three pull entry points bailing before ensureClient when offline, the
NetworkConnected rerun (deferred, coalesced across triggers, gated on auto
sync / sign-in / open document, re-armed when the rerun still finds the
device offline), the auto sync toggle while offline, and the close-widget
cleanup; main_close_spec.lua covers the offline close-time skip and asserts
goOnlineToRun is never used. The NetworkMgr stub gains a toggleable isOnline
and call counters, and the pull-recording plugin factory shared by the open,
resume and offline specs moves into koreader_stubs. Adapted from SynVisions'
branch for #5838, minus the opt-in setting.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): keep KOReader's silent Wi-Fi action for background sync
Bypass NetworkMgr's Wi-Fi bring-up for background pulls only when KOReader's
"Action when Wi-Fi is off" would prompt. With "turn on" (what kosync forces
for its own auto sync) or "ignore" (Android) the pull keeps taking
NetworkMgr:willRerunWhenOnline exactly as before, and the close-time push
keeps NetworkMgr:goOnlineToRun for "turn on". Never bringing Wi-Fi up at all
would have left "turn on" users without "Restore Wi-Fi connection on resume"
with no sync after a wake, and exposed their offline annotations to the
shared notes cursor (a successful pull advances it, so a later push skips
them). Only "prompt" puts a dialog in front of the reader, so only "prompt"
is bypassed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): scaffold localsend-ffi crate with start config
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): port localsend identity into ffi crate
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): add localsend ffi event queue and payloads
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): fuse flaky event tests and add comprehensive wire-shape assertions
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): receive-only localsend service in ffi crate
Ports the receive side of apps/readest-app/src-tauri/src/localsend/service.rs
into the standalone localsend-ffi crate: the HTTPS server plus discovery
bind, a staging-dir file pipeline that stages uploads under
.localsend-inbox and renames them into download_dir on success, and an
event pump that feeds the Task 3 event queue instead of emitting Tauri
events.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): sanitize peer-supplied file names before writing them
handle_file_upload joined the wire-supplied file name straight into the
staging and download paths. Protocol v2 allows directory components in
that field, so a peer could send a traversal payload or an absolute path
and write outside .localsend-inbox / download_dir.
Add safe_file_name, which takes the last non-relative path segment and
sanitizes it under the crate's strictest Rules::Universal set, falling
back to received.bin when nothing safe survives (empty name, "..", or
all separators). Use it for both the staging path and the final rename
target.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): expose localsend ffi c abi with smoke test
Adds the poll-based C ABI for KOReader's LuaJIT FFI: ls_version,
ls_start, ls_stop, ls_status, ls_poll_event, ls_accept, ls_decline,
and ls_string_free, all wrapped in catch_unwind with poison-safe
locking around a process-global service handle. Adds an ignored
smoke test that binds real ports and confirms a started event
and running status.
ls_string_free is marked unsafe extern C to satisfy clippy's
not_unsafe_ptr_arg_deref lint; this only affects Rust-side callers,
the exported C symbol is unchanged. Running cargo fmt with default
settings also reformatted events.rs and identity.rs from earlier
tasks.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): serialize event-queue tests and cover ffi idempotency
Adds a test-only TEST_QUEUE_GUARD mutex in events.rs so
event_queue_contract and ffi_surface_contract cannot interleave their
clear/push/pop calls on the process-global EVENTS queue when the test
runner uses parallel threads.
Extends the ignored smoke test with assertions that a second ls_start
while already running returns OK and leaves the service running, and
that a second ls_stop after a real stop also returns OK, since neither
idempotency contract had test coverage before.
Also tightens the crate doc comment and ls_string_free's Safety doc to
call out that ls_version's return value is a static string and must
never be passed to ls_string_free.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): add localsend native lib build script
Builds the LocalSend FFI crate into apps/readest.koplugin/libs/ for the
KOReader plugin. Supports arm64-mac (plain cargo build, verified on this
host) and armv7 (Kindle, via cargo-zigbuild, wired up in Task 7).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): pin kindle glibc floor for armv7 localsend lib
Empirically verified the kindle userland glibc floor against the
koreader-kindle-v2026.07.1.zip release: every shipped .so and native
binary tops out at GLIBC_2.12 (koreader/libs/libzmq.so.5), lower than
the previously assumed 2.19, so lower KINDLE_GLIBC to match.
Also fix the cargo-zigbuild availability check, which always failed
because cargo forwards "zigbuild" as the subcommand name and that
subcommand rejects --version; probe the cargo-zigbuild binary
directly instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): localsend ffi loader with arch-keyed lib table
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): localsend receive service module with poll loop
Adds readest_localsend.lua: the module singleton that owns the native
LocalSend service lifecycle (start/stop/toggle), polls queued events on
a 0.5s UIManager loop, and routes them to per-type handlers (receive
request confirmation, file-done library registration, end-of-transfer
summary, status text for the settings row).
Also adds a ConfirmBox stub to koreader_stubs.lua and requires
spec.koreader_stubs from localsend_spec.lua so its stubs (InfoMessage,
ConfirmBox, NetworkMgr, UIManager) are registered before the new
dispatch spec requires readest_localsend, regardless of spec file load
order.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): wire localsend receive into menu and lifecycle
Adds localsend_enabled/localsend_alias settings, initializes the
readest_localsend singleton in init(), adds a toggle + status menu
entry after Pull books now, forwards network connect/disconnect and
suspend events to the service, and unschedules its poll task on
onCloseWidget.
addToReadest and _addLocalRow now take an opts table with a silent
flag that suppresses every InfoMessage on that path, so LocalSend's
onReceiveFileDone can register received files without popping
messages over the transfer dialog. The default no-opts call path is
unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): bundle localsend libs in plugin zip and release ci
Excludes native/ (Rust source) from the koplugin zip in both the local
build script and the release workflow, and adds a release CI step
that builds the armv7 LocalSend lib before zipping so libs/ ships in
published releases. build-koplugin.mjs now warns when libs/ is empty
so a local sideload build without prebuilt libs is not silent about
losing LocalSend receive.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* chore(koplugin): extract localsend i18n strings
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): build kobo hard-float localsend lib
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): offer kobo hard-float localsend lib in loader
Kobo devices are hard-float armv7 (gnueabihf), distinct from Kindle's
soft-float armv7 (gnueabi). Key libNameFor on Device:isKobo() so Kobo
loads liblocalsend-armv7hf.so instead of falling through unsupported;
Kindle and Kobo are unambiguous device classes, so no try-load
fallback is needed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* ci(koplugin): build kobo hard-float localsend lib in release
The release workflow only built the Kindle softfp LocalSend lib, so
release zips never shipped liblocalsend-armv7hf.so for Kobo devices.
Add the armv7hf rustup target and a second build-localsend-libs.mjs
invocation to the existing CI step.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): start localsend off the ui thread and fix accept race
ls_start ran identity keygen and socket bind synchronously on the
LuaJIT UI thread, freezing KOReader for several seconds on first run.
Move that work to a dedicated OS thread that owns the tokio runtime;
ls_start now returns immediately and ls_status gains a starting field
so Lua can poll for readiness. ls_stop likewise signals the worker
thread and detaches instead of blocking on shutdown.
Also fix service::accept registering the receiving session after
sending the Accept decision, which could race the first FileUpload
against its own session registration.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): close identity keygen race and stale-failed start lockout
Concurrency review of the previous commit found five reachability
issues that only became possible once ls_start stopped blocking:
- Two overlapping ls_start workers (e.g. screen sleep mid-keygen then
a quick stop/start) could both generate an identity.pem and race on
create_new(), leaving the loser stuck on a File exists error instead
of adopting the winner's cert.
- A failed start left STATE occupied by a dead LiveStatus::Failed
entry forever, since ls_start's idempotent re-attach check never
distinguished it from a genuinely running service, so retries
(e.g. onNetworkConnected) could never restart the service.
- service::start ran off the UI thread now but outside catch_unwind,
so a panic there would strand the worker with no event and
LiveStatus stuck at Starting forever.
- The started event was pushed before LiveStatus flipped to Running,
so a consumer reacting to it could still see running:false.
Also drops the now-redundant Option around Running.stop_tx (state()
already guarantees single consumption) and comments the narrow
inbox/event-queue overlap window between a detached worker's teardown
and the next ls_start.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): harden localsend lua lifecycle and add crate ci
The started/error event handlers took a first parameter named `_`,
shadowing the module-level i18n function of the same name; the error
handler crashed uncaught the first time an async ls_start failed. Also
stop client-side polling on that failure so a later toggle can retry,
restart localsend on device resume, guard the accept dialog against a
stray tap dismissing it, normalize an empty download-dir setting, and
show a "starting" status during the async keygen/bind window.
apps/readest.koplugin/native/localsend-ffi had no PR-time CI at all;
add a paths-filtered job mirroring the existing rust_lint job's
toolchain setup and update the verification rules to match.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): build arm64 linux localsend lib for remarkable
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): offer arm64 linux and remarkable localsend libs in loader
Wires liblocalsend-arm64.so and the reMarkable device class into
libNameFor: reMarkable 2 (hard-float armv7) maps to the same lib as
Kobo, reMarkable Paper Pro and other arm64 Linux e-readers map to the
new arm64 .so, and Android arm64 is excluded since its linker
namespace forbids dlopen of a plugin-bundled .so.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* ci(koplugin): build arm64 linux localsend lib in release
Extend the release workflow's LocalSend native lib build step to also
build the arm64-linux target (reMarkable Paper Pro), alongside the
existing armv7 and armv7hf targets. build-koplugin.mjs already globs
libs/ so it ships the new .so without any change.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* chore(koplugin): extract localsend arm64 and starting i18n strings
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): harden localsend against suspend resume keygen races
Three defensive fixes for the localsend suspend/resume-during-first-run
keygen edge on slow e-readers:
- identity.rs: retry the AlreadyExists recovery read a handful of times
instead of once, so a loser worker does not fail on a winner's
identity.pem write that has not finished landing yet.
- lib.rs: spawn the ls_start worker via thread::Builder instead of
thread::spawn, so an OS thread-creation failure surfaces as a queued
Event::Error and ERR_START instead of a silent ERR_PANIC.
- readest_localsend.lua: the error handler now checks ls_status before
stopping the service, so a stale error from a superseded overlapping
worker cannot tear down an already-healthy service.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): replace localsend ffi cdylib with a helper binary
Old Kindles' glibc is missing symbols the precompiled Rust std pulls in
as weak (getrandom, statx, clock_gettime64), so the cdylib segfaults on
first call. A static-musl subprocess has no glibc dependency and was
verified running on that hardware. This step replaces the C ABI with a
localsend-helper binary that speaks newline-delimited JSON over a local
TCP control socket: a start command plus accept/decline/status/stop,
and started/receive_*/error/status events streamed back. lib.rs keeps
only the reusable config/events/identity/service modules; the musl
cross build, Lua spawn/socket glue, and packaging are follow-up work.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): build static musl localsend helper binaries
Rewrite build-localsend-libs.mjs as build-localsend-bins.mjs: it now builds
the localsend-helper standalone binary (static musl for armv7/arm64, plain
cargo for macos) into apps/readest.koplugin/bin/ instead of the old FFI
cdylib into libs/. Static musl has zero glibc dependency and no
softfp/hardfloat split, so the four old glibc-pinned targets collapse into
three binary targets with the exec bit set on the copied artifact.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): spawn localsend helper binary over a local socket
Replace the FFI cdylib transport in the koplugin LocalSend integration
(ffi.load + ls_* calls), which crashed on old-glibc Kindles, with the
static-musl localsend-helper binary spawned as a background process and
driven over a local TCP control socket speaking newline-delimited JSON.
library/localsend_ffi.lua becomes library/localsend_helper.lua: pure
binaryNameFor (device to binary filename) and parseLines (socket buffer
to decoded events, no socket/os dependency) plus socket wrappers
(pickPort, spawn, connect, send, recvChunk).
readest_localsend.lua keeps its handlers/dialogs/lifecycle shape as a
process-level singleton that owns the socket across KOReader context
switches; only the FFI calls become socket sends and a non-blocking poll
that frames and dispatches decoded events, adding a status handler that
caches alias/port/localIps/multicastError for statusText().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): package static musl helper binaries in plugin zip and ci
build-koplugin.mjs and the release workflow still referenced the retired
libs/ dir and build-localsend-libs.mjs script from the FFI cdylib era.
Point both at bin/ and build-localsend-bins.mjs, and rebuild the release
CI step around the two static-musl targets (armv7, arm64) instead of the
old three-way gnueabi/gnueabihf/arm64-linux split.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): open the kindle firewall for localsend ports on start
Kindle firmware runs iptables with INPUT policy DROP and only allow-lists
explicit ports (KOReader's SSH plugin opens 2222 the same way), so
LocalSend's TCP 53317-53327 server range and UDP 53317 multicast
discovery were unreachable from other devices even though the service
was running. Add library/localsend_firewall.lua, ACCEPT the LocalSend
ports on service start and remove them on stop, matching kaikozlov's
localsend_firewall.lua and KOReader's own SSHPlugin. Gated on iptables
being present and working rather than Device:isKindle(), so it also
covers other DROP-policy devices and safely no-ops where iptables is
absent.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): keep localsend poll alive across context switches and refresh filemanager
The receive event poll belonged to the singleton service but was torn down
on a per-instance onCloseWidget, racing the next init's re-attach and
stranding the service with no live poll (incoming transfers silently
ignored). Make the poll service-lifecycle-owned. Also refresh the KOReader
FileManager on receive completion so a received book appears without leaving
and re-entering the folder.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): add send flow (list devices, send, cancel) to the helper
Ports the send side of the desktop app's LocalSend service (device_payloads,
run_send, and the cancel plumbing) onto the koplugin helper binary, which
was receive-only. Adds three control-socket commands (list_devices, send,
cancel_send) and three queued events (devices, send_progress, send_end).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(koplugin): add send with localsend file action and device picker
Adds the SEND-side UI on top of S1's helper protocol: a "Send with
LocalSend" file-menu button in FileManager (gated on supported book
formats and helper availability), a ButtonDialog device picker driven
by list_devices, and send progress/result InfoMessages driven by
send_progress/send_end. Includes Helper.deviceLabel, a pure formatter
for the picker's device rows.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* build(koplugin): pin localsend fork to 3cae1825 for best-effort SO_REUSEPORT
Older e-reader kernels (Kindle Voyage on 3.0.35) reject SO_REUSEPORT with
ENOPROTOOPT, and the fork previously propagated that error, which disabled
multicast discovery for the whole device. Bump the readest/localsend pin
to 3cae1825 (set_reuse_port made best-effort) in both the koplugin helper
crate and the src-tauri app, and drop the temporary local path override
used while testing the patch. The app lockfile also refreshes some
Windows-only transitive deps to their latest compatible versions.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(koplugin): register HTTP peers so iOS and Android appear in localsend scan
The helper no-oped ServerEventV2::Register, assuming the discovery crate
added registered peers on its own. Peers that answer a scan over HTTP
/register (iOS, which cannot multicast without the entitlement, and
Android) were therefore never added to the device list, so KOReader only
ever discovered multicast responders such as macOS.
Intercept Register in the event pump and feed the peer into the discovery
store via a ported register_peer(), skipping a device's own scan probes by
fingerprint. Mirrors the Tauri app's src-tauri/src/localsend/service.rs.
Verified on a Kindle: the Android peer now appears in list_devices.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(koplugin): send from the library menu and tag devices by platform
Add a "Send to nearby Readest devices" action to the Readest Library
long-press menu (parity with the FileManager file dialog), gated on the
book having a local copy and a helper binary being available. Show the
peer platform (e.g. macOS, Android) as a tag in the device picker label,
matching the app's device picker. Rename the FileManager actions to
"Add to Readest library" and "Send to nearby Readest devices", and
re-extract the koplugin translation catalogs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(koplugin): rename localsend-ffi crate to localsend-bin
The crate stopped being an FFI cdylib when the transport moved to a
static-musl helper binary reached over a local socket; there is no C ABI
anymore, so "ffi" is a misnomer. Rename the crate and its lib, the
directory, the build-script crate path, the koplugin_rust_lint working
directories, the verification rule, and the gitignore target path. The
produced binary is still localsend-helper, so nothing the plugin spawns
or ships changes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* i18n(koplugin): translate the LocalSend strings into all locales
Fill the 31 previously-empty LocalSend msgstr entries (send/receive menu
actions, device picker, and status/error messages) across every koplugin
translation catalog. Product names (Readest, LocalSend, KOReader, Wi-Fi)
stay in Latin script and the %1/%2/%3 placeholders are preserved verbatim.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The koplugin computed its own book fingerprint that diverged from
Readest's getMetadataHashInfo, forking a book's sync identity across
devices:
- The PDF filename salt (issue #5411) was never ported, so the same PDF
got different fingerprints on KOReader vs Readest.
- The hash was always computed locally from doc_props, ignoring the
fleet-authoritative meta_hash already pulled into the library store.
- Books uploaded from KOReader pushed no meta_hash at all.
- Identifier selection ignored scheme priority (uuid over calibre over
isbn) and depended on listing order.
- The hash source was not NFC-normalized before md5.
Follow the rule Readest itself applies since #5412: stamp the hash once
when a book enters the fleet and preserve it everywhere else.
getMetaHash now resolves library store row, then sidecar cache, then
local computation, and both upload entry points stamp meta_hash on the
row they push. Parity is enforced by shared hash-source fixtures between
spec/syncconfig_spec.lua and metadata-hash-info.test.ts.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): stop sync push crashing on JSON null in book metadata (#5006)
KOReader's require("json") is LuaJSON, whose decoder represents a JSON
null as a function sentinel (json.util.null). row_to_wire decodes the
server metadata_json into the push payload, which Spore then re-encodes
with dkjson. dkjson rejects functions with "type 'function' is not
supported by JSON", failing the entire pushChanges for any changed book
whose metadata carries a null field.
Sanitize the decoded metadata and progress tables, converting the
function sentinels to dkjson.null so the payload re-encodes as a real
JSON null, byte-faithful to the wire and with no metadata churn.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(koplugin): keep auto-sync off the book open/close UI thread (#5006)
Auto-sync ran heavy blocking HTTP on KOReader's UI thread when opening or
closing a book, freezing the reader for seconds. The Turbo async path is
dead (DUSE_TURBO_LIB defaults to false, so Spore falls back to blocking
socket HTTP), and rapid book switching stacked the work into ANRs.
Close path: replace the full library pull+push ("both", a ~3s 26-row
pull) with a targeted push of only the open book's row (pushOpenBook).
Closing a book only needs to persist this book's changes; the touched
row still carries the cloud-side uploaded_at/metadata/group_id from the
last pull, so the single-book push preserves them with no explicit-null
wipe (issue #4138). Cross-device library reconciliation still runs when
the Library widget opens.
Open path: defer the per-book pull and make it cancellable. The reader
paints first, and a rapid book switch drops the pending pull in
onCloseWidget instead of stacking blocking round-trips.
Adds spec/main_close_spec.lua and spec/main_open_spec.lua.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a Dispatcher action for "Full sync all annotations" so it can be bound
to a tap or gesture instead of costing several taps through the plugin menu
(closes#5094). The work it performs already shipped as fullSyncBookNotes;
what was missing was the registration that makes it bindable. It is
reader-only, and its title keeps the "readest" token because KOReader's
gesture picker pools every plugin's actions into one flat list.
Add "Upload current book to Readest" to the plugin menu, matching the
Library widget's long-press "Upload to Cloud". A book that was sideloaded
and opened may have no LibraryStore row at all, and uploadBook needs one for
the hash, format and file path, so the entry point creates the row first,
writing the same shape "Add to Readest" does.
Extract syncbooks.uploadAndRecord for the bookkeeping that has to follow a
successful upload: mark the row cloud-present, stamp uploaded_at, clear any
tombstone, then push the row so peers see the book. Both upload routes now
share it, so they cannot drift. Skipping it would strand a book with
cloud_present=0, leaving the Library offering Upload forever.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Waking the device with a book already open now pulls progress,
annotations and stats like reopening the book does, instead of
requiring a manual sync or book reopen. The pull is delayed 1s so
Wi-Fi can come back up after wake (same delay upstream kosync uses
on resume), debounced against rapid Suspend/Resume pairs (Android
fires them on focus changes), and the pending task is dropped on
widget close so it cannot run against a torn-down ReaderUI.
Closes#4924
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The stats pull keyed the statistics book table by md5 alone, while
KOReader's native statistics plugin keys rows by exact (title, authors,
md5). When the two parsers extract slightly different metadata for the
same file, the first native open creates a second, zeroed book row that
the KOReader UI reads, and the reading time synced from Readest stays
stranded on the sync-created row.
applyRemote now inserts a book row only for an md5 the DB has never
seen, attaches pulled events to the row the native plugin reads (native
rows always set pages and last_open; sync-created rows leave pages
NULL), and folds never-adopted duplicate rows into the surviving row on
every pull, so existing databases heal and the stranded time reappears.
Adopted rows and the live session's cached book id are never deleted,
and the totals recompute no longer regresses last_open below a real
native open timestamp.
Fixes#4861
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* fix(koplugin): repair reading-stats sync push/pull
Reading statistics (statistics.sqlite3 page events) never reached the
Readest sync server. Three stacked defects in the koplugin stats path:
1. push/pull called settings:readSetting/saveSetting on self.settings,
which is the plain readest_sync data table (not a LuaSettings object),
so auto-sync crashed on every book open
("attempt to call method 'readSetting' (a nil value)").
2. pushChanges declares books/notes/configs as required_params, but the
stats push sent only statBooks/statPages, so Spore rejected the request
client-side ("books is required for method pushChanges").
3. statBooks/statPages were listed only under the spec's payload, not as
optional_params. Spore's expected-param set is
required_params + optional_params, so it rejected them too
("statBooks is not expected for method pushChanges").
Fixes:
- Read/persist the cursor as a plain field and save the whole table via
G_reader_settings:saveSetting, mirroring readest_syncauth.
- Send empty books/notes/configs alongside statBooks/statPages; the server
defaults each to [] and processes the stat arrays independently.
- Declare statBooks/statPages as optional_params in readest-sync-api.json.
Also add ReadestStats debug logging across pushBookStats/pullBookStats and
push/pull (cursor, collected counts, dispatch, response status, cursor
advance), and surface the push failure status/body that was previously
swallowed on non-interactive syncs.
Tests: cover push/pull cursor handling, the pushChanges required_params
contract, and a spec-level check that every stats payload key is an
expected pushChanges param.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(koplugin): add interactive Push/Pull stats now menu items
Add "Push stats now" and "Pull stats now" entries to the Readest sync
menu, placed after "Readest library" and before "Push books now" and
gated on being signed in (access_token + user_id) like the other
account-level items. They call pushBookStats(true) / pullBookStats(true)
for a manual interactive sync of reading statistics (the whole
statistics.sqlite3 delta), complementing the automatic pull-on-open /
push-on-close.
Interactive push/pull now also confirm their result (pushed / pulled /
up to date) to match the sibling "now" items, since a silent success
would look like a no-op.
Extract the five new strings into the koplugin .po catalogs (empty
msgstr, English fallback at runtime).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(koplugin): translate reading-stats sync strings (33 locales)
Fill the previously empty msgstr entries for the reading-statistics sync
strings across all koplugin locale catalogs: the two new "Push/Pull stats
now" menu items, the pushed / pulled / up-to-date confirmations, and the
push/pull failure messages. Each locale mirrors its existing
Push/Pull/Failed-to verbs and "reading" terminology for consistency.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deleting a highlight or bookmark in the koplugin never reached the
server. SyncAnnotations:push builds its payload from getAnnotations,
which walks only the live ui.annotation.annotations list, so a deleted
note can never appear in a push — the server kept the row and the next
pull resurrected it. The pull direction (server deletions → koplugin)
was already handled by removeDeletedAnnotations (#4119); this is the
missing push direction.
Capture a tombstone at deletion time instead. onAnnotationsModified
detects a removal (negative index_modified, with the deleted item at
items[1]) and records a deletedAt-stamped descriptor in the per-book
sidecar (readest_sync.deleted_notes). push folds those tombstones into
the payload and clears them only once the server accepts them, so a
failed push retries. Extracted buildNoteDescriptor so the deletion path
derives a note's id identically to the push walk.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Supersedes #3156. Adds a reading-statistics system whose canonical data model
is KOReader's own (book + page_stat_data), so stats round-trip losslessly
between Readest and KOReader.
- Storage: a cross-platform Turso statistics.db in KOReader's exact schema
(web/Workers, desktop, iOS, Android) — replacing #3156's Node-only
better-sqlite3 + statistics.json.
- Tracking: per-page reading events (time-on-page, idle-capped) flushed on
page-change/idle/hide/close — the KOReader model — not session aggregates.
- Sync: legacy /api/sync extended with a stats type backed by self-contained
Supabase tables (stat_books, stat_pages); union/longer-duration-wins merge
keyed on book_hash. apps/readest.koplugin syncs through the same endpoint.
- Scale & robustness: per-tab singleton connection (avoids OPFS lock
conflicts) + explicit WAL checkpoint; transactional bulk apply; chunked
resumable push; client-driven paged pull with trailing-ms completion;
paginated/scoped server merge.
Verified: 5668 unit tests, 155 koplugin busted tests, biome+tsgo + luacheck
all green; web OPFS DB verified live.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(koplugin): pull before push so sync doesn't wipe cloud book fields, closes#4138
The Library sync pushed a touched book row before pulling, so a row
still missing the cloud's uploaded_at / metadata / group_id (e.g. one
created by lightScan, not yet merged from a cloud pull) was sent with
those fields nil. The server's transformBookToDB explicit-nulls
uploaded_at and metadata for any field absent from the wire payload,
wiping the cloud copy — after which every device that pulled lost the
book's upload state.
syncBooks("both") now pulls first, then pushes, and takes a before_push
callback. syncBooksLibrary passes touchOpenBook through it so the
open book's updated_at bump lands after the pull has refreshed the
local row, letting the push carry the preserved cloud fields.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(koplugin): hide Library books with neither an uploaded nor a local file
The Library showed any row with cloud_present = 1, but a bare cloud
*record* whose file was never uploaded (uploaded_at NULL) has no cover
and can't be opened — showing it is meaningless. Tighten the visibility
predicate to (uploaded_at IS NOT NULL OR local_present = 1) across
listBooks, getGroups, listBookshelfGroups and listBooksInGroup.
This mirrors Readest, which only adds a synced book to the library when
uploadedAt is set and keeps locally-imported books that carry a
downloadedAt.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(koplugin): close the Library widget when opening a book
Opening a book from the Library called ReaderUI:showReader without
closing the Library Menu, so it stayed in the UIManager widget stack
with M._menu still set. A later background M.refresh() — a cloud-sync
or cover-download completion — then repainted that ghost Library over
the reader, making it flash on screen for a few seconds.
Add M.close(); route the title-bar X, M.reopen() and both handleTap
book-open paths through it. A wrapped onCloseWidget clears M._menu on
every close path, so M.refresh() no-ops once the Menu is gone.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(koplugin/library): data layer + busted harness + design doc
- LibraryStore: per-user SQLite index merging cloud + local books by
partial-md5 hash. listBooks/listBookshelfBooks/listBookshelfGroups,
upsertBook with cloud_present/local_present OR-merge + _force/clear
sentinels, parseSyncRow, getChangedBooks for tombstone push.
- EXTS table mirroring web's document.ts.
- busted harness with KOReader stubs (G_reader_settings, DataStorage,
lua-ljsqlite3 against :memory:); spec_helper, exts_spec, smoke_spec,
librarystore_spec covering schema, sort, group nesting, dedupe.
- Library design doc + spec README.
- pnpm test:lua wired through root + app package.json; lint-koplugin
recurses into library/ + spec/.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(koplugin/library): cloud sync — push, pull, upload, delete, downloads
- Spore methods: pullBooks (incremental /sync), getDownloadUrl,
getUploadUrl, listFiles, deleteFile.
- syncbooks.lua: pushBook + pushChangedBooks (advances watermark to
max(updated_at, deleted_at)), syncBooks(opts, mode) for push/pull/both,
downloadBook + downloadCover (sync socket.http with file sink; cover
download via fork+poll with single-slot queue + visible-page filter +
coalesced refresh), uploadBook (presigned-PUT flow + best-effort
cover), deleteCloudFiles (list-then-delete-each, mirrors
cloudService.deleteBook).
- SyncAuth.withFreshToken wrapper resolves the ensureClient race; 401/403
unified across syncconfig + syncannotations.
- Cloud + local book covers shared by partial-md5 hash; cover.png cached
at <settings>/readest_covers/<hash>.png with sentinel for known 404s.
- syncbooks_spec covers row-to-wire conversion + file_key shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(koplugin/library): local discovery — sidecar scanner + cover provider
- localscanner.lightScan iterates ReadHistory entries, reads
partial_md5_checksum from .sdr sidecars, and upserts local rows.
Slow filesystem walks deferred to fullSidecarWalk (24h-gated).
- coverprovider wraps BookInfoManager:getBookInfo for local books with
graceful FakeCover fallback when coverbrowser is absent.
- localscanner_spec + coverprovider_spec.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(koplugin/library): UI — widget, item, view menu, FileManager hooks
- librarywidget: full-screen Menu mixed in with CoverMenu + Mosaic/List
per zen_ui's group_view pattern. Title-bar tap → view menu, search via
left icon, drill-in/back for grouping. Async cloud sync deferred via
scheduleIn so the menu paints before HTTP fires.
- libraryitem: BIM patch for cloud-only (readest-cloud://) and group
(readest-group://) URIs; group-cover composer (2x2 mosaic for grid,
same in list) with cache key derived from the actual first-N hashes
for content-based invalidation; ListMenuItem update + paintTo patches
for wider list-mode cover strip and cloud-up/down icon overlay.
- libraryviewmenu: ButtonDialog with View/Group by/Sort by/Actions.
Default Group by = Groups (parity with web), values authors/groups.
- librarypaint: partial-page e-ink repaint shim adapted from zen_ui.
- main.lua: Library menu entry, dispatcher actions (Open Library / Push
/ Pull as general; progress + annotations as reader-only),
"Add to Readest" button in FileManager's long-press file dialog
(dedupe by partial_md5; bumps updated_at when present, inserts a
fresh local-only row otherwise; un-tombstones via _clear_fields).
Push books on Library open when auto_sync is on, pull-only otherwise.
- Long-press action sheet with Readest BookDetailView parity:
Remove from Cloud & Device / Cloud Only / Device Only,
Upload to Cloud, Download Book / Cover / All.
- Cloud-down + cloud-up SVG icons (LiaCloudDownloadAltSolid /
LiaCloudUploadAltSolid) painted in the right-side wpageinfo slot.
- i18n catalog updated for new strings.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(koplugin/library): split libraryitem into focused modules
libraryitem.lua had grown to 1018 lines mixing five unrelated
concerns. Split along the natural seams:
cloud_covers — readest-cloud:// URI scheme, on-disk <hash>.png
cache, single-slot async download queue, visible-page
filter
group_covers — readest-group:// URI scheme, 2x2 mosaic composer with
content-derived cache key (first-N hashes), cell
layout table
cloud_icons — bundled cloud-up/cloud-down SVG loader, IconWidget
cache, paint-overlay positioning
list_strip — list-mode group row builder (4-cover wider strip
replacing ListMenu's square cover slot)
bim_patch — BookInfoManager:getBookInfo router (cloud / group /
local) + ListMenuItem update + paintTo patches; owns
the _library_local_paths set and orig BIM reference
libraryitem.lua is now 141 lines: just the entry-table constructors
(entry_from_row, entry_from_group, entry_back) plus thin install /
set_visible_hashes delegates. Each new module is 88-216 lines.
No behavior change — same 113 specs pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(koplugin): co-locate dev tooling, ship-zip exclusions, CI job split
- apps/readest.koplugin/scripts/build-koplugin.mjs: local sideloading
build with the same exclusions the release workflow uses.
- Move lint-koplugin + test-koplugin from apps/readest-app/scripts/ to
apps/readest.koplugin/scripts/. All koplugin dev tooling now lives
with the koplugin and is excluded from the published release zip.
- Rename to .mjs so Node treats them as ESM without the reparse warning
(the i18n CommonJS scripts stay .js).
- Release workflow: zip -r exclusions for scripts/, docs/, spec/,
.busted so dev artifacts don't ship to end users.
- PR workflow: split build_web_app into build_web_app + test_web_app
for parallelism. The test job installs luarocks + busted +
lsqlite3complete and runs pnpm test:lua. test-koplugin.mjs now
hard-fails (instead of soft-skipping) when CI=true and a tool is
missing — a broken CI toolchain previously exited 0 silently.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- i18n loader at apps/readest.koplugin/i18n.lua: isolated callable,
falls back to KOReader's gettext when a string is untranslated
- Translation catalog at locales/<i18next-code>/translation.po for 31
languages, mirroring apps/readest-app/public/locales/
- scripts/extract-i18n.js (scan _("...") and _([[...]]); preserve
existing, drop obsolete, add new) and scripts/apply-translations.js
(bulk import from /tmp/koplugin-translations/<lang>.json)
- Mirror apps/readest-app SyncInfoDialog: rename showMetaHashInfo to
showSyncInfo, dialog title "Sync Info", new Last Synced row computed
as max(last_synced_at_config, last_synced_at_notes) from doc_settings
- syncconfig.lua / syncannotations.lua mark per-book sync timestamps
on push/pull success
- Rename "Meta Hash" -> "Book Fingerprint" in koplugin and
apps/readest-app SyncInfoDialog.tsx; translations propagated to
all readest-app locales
- "book config" -> "reading progress" wording across user-facing
strings (matches QiuYukang fork terminology)
- Replace "Log out as " / "Login failed: " concat prefixes with
T(_("...%1..."), arg) placeholder pattern (RTL / verb-final friendly)
- pnpm lint:lua: luajit -b syntax check across koplugin .lua files;
soft-skips when luajit is missing locally; CI installs luajit and
runs the check unconditionally
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements the hook introduced by koreader/koreader#15240, called when
the user deletes the plugin via the plugin manager with "Also delete
plugin settings" checked. Removes the readest_sync entry from
G_reader_settings (auth tokens, user info, auto_sync flag, last_sync_at)
and resets the in-memory copy to defaults.
Closes#4039
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add "Full sync all annotations" menu item that pushes and pulls all
annotations regardless of the last sync timestamp, enabling users to
sync old highlights that were created before the plugin was installed.
Changes:
- Add full_sync parameter to push/pull that bypasses timestamp filter
and uses since=0 for pulling all server annotations
- Deduplicate by annotation ID alongside position-based dedup
- Store server ID on pulled annotations and reuse it when pushing
- Parse ISO 8601 timestamps from server to preserve original
created/updated dates instead of using current time
- Resolve KOReader page numbers from xpointers via getPageFromXPointer
- Resolve Readest page numbers from CFI via getCFIProgress on pull
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add bidirectional annotation/highlight sync between KOReader and Readest:
- Add xpointer0/xpointer1 fields to BookNote and DBBookNote types for
KOReader XPointer positions alongside Readest's CFI format
- Extend transform layer to pass through xpointer fields to/from DB
- Convert CFI→XPointer on push and XPointer→CFI on pull in useNotesSync,
discarding notes that fail conversion
- Support KOReader's text()[K].N indexed text node format in xcfi.ts for
paragraphs with inline elements (e.g. <a> page anchors)
- Generate KOReader-compatible XPointers: text().N for single text nodes,
text()[K].N only when multiple direct text nodes exist
- Skip cfi-inert elements (injected by Readest at runtime) in XPointer
path building and resolution
- Map highlight colors between KOReader and Readest color systems
- Implement KOReader plugin annotation push/pull with deterministic IDs,
auto-sync on document open/close, and UIManager refresh on pull
- Refactor koplugin into focused modules: syncauth, syncconfig,
syncannotations, selfupdate
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>