Skip to content

feat: Kindle control panel reports the device and queues commands - #6

Merged
listlessbird merged 2 commits into
mainfrom
design/control-panel
Nov 22, 2026
Merged

listlessbird merged 2 commits into
mainfrom
design/control-panel

Conversation

@listlessbird

@listlessbird listlessbird commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

The app couldn't see what was on the Kindle or act on it. Deleting a book or forcing a rescan meant plugging the Kindle in.

How

On every wake, the Kindle reports its battery, free and total space, firmware and library, then runs any commands the app queued. The new Kindle screen (the tablet button in the Library header) shows the last report and queues commands for the next wake.

  • Worker (src/Api.ts). New endpoints:

    • PUT /device: the Kindle's report, form-encoded so ts.sh can send it with curl.
    • POST /commands, DELETE /commands/:id: the app queues or cancels a command.
    • GET /commands/, PUT /commands/:id: the Kindle lists pending commands as tab-separated text, then settles each one with ok or failed plus a message.

    /status now includes device and commands. Commands are DeleteBook { path } and Rescan. A delete path must be inside /mnt/us/documents with no . or .. segments, or the Worker returns 400. Commands expire after 30 days through an R2 lifecycle rule.

  • App.

    • Two tiles: Battery, and Free space with a storage bar. Under them: "Kindle checked in 4 h ago · 5.16.2.1.1".
    • The library has a compact search (titles, any case) and a Rescan text action.
    • Tapping a book confirms, then shows "Deleting · Waiting for Kindle" with Undo.
    • A failed command shows as a notice with Try again, which queues it again, and Dismiss. The Kindle's own error text stays out of the UI.
    • Notice gains an optional action, which is in the component catalog.
  • Kindle (ts.sh, in the kindle repo).

    • run_commands deletes the book, its .sdr and both cover thumbnails, settles each command, and rescans once if anything ran.
    • report_device reads lipc, df and the firmware version.
    • The library lists only EBOK and PDOC entries from cc.db, so KUAL, hotfix runners and other indexed non-books never reach the app.

    The ts.sh change ships to the Kindle separately and isn't part of this PR. It needs this Worker deployed first.

No native change: the Android fingerprint matches main's, so this ships OTA. apps/worker moves to @cloudflare/workers-types v5 for R2's include list option.

Verification

  • Worker tests in workerd cover command order and outcomes, cancelling before the Kindle runs a command, rejected paths, and the device report (repeated, single, missing, and malformed books). App tests cover queue, cancel and Try again, search, and the tile summary. check:changed passes.
  • On the real PW3, against a local dev Worker:
    • lipc battery and charging, the firmware version and df all read correctly.
    • A queued delete removed a sideloaded test file and settled ok.
    • After the rescan, the next report no longer listed it.
  • Screenshots below show the first design, not the final one. The redesign (tiles, search, Undo, Try again) passed tests but wasn't run on a device, because the emulator tooling failed to install. It still needs a check on the emulator.
Before: Library After: Library First design: report

The screenshots live on the assets/control-panel branch, which can be deleted after merge.

@listlessbird
listlessbird merged commit 24af393 into main Nov 22, 2026
4 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