feat(desktop): live shelf ingest progress and failed-book removal

Draft
CU
5mo ago
+911-14

Summary

This PR addresses the biggest first-run UX gap on the library shelf: after uploading a book, Phase A ingest can take minutes but the apps were not wired to the backend's live progress channel.

Primary improvement: live ingest feedback on the shelf

  • Added LibraryEventStream in @kinora/core to subscribe to GET /api/books/events (SSE ingest_progress)
  • Desktop library patches the React Query cache in real time as ingest stages advance
  • Book covers show a live progress bar and stage label during import
  • Opening a non-ready book is blocked with a clear gate message
  • Upload errors from the API envelope are surfaced in a dismissible banner
  • Poll fallback every 5s while any book is still importing (catches the final ready flip if SSE drops)

New open-source demo book

  • Added assets/books/build_little_red_cap_pdf.py — Little Red Riding Hood (Brothers Grimm, public domain)
  • make demo-pdf now builds both Frog-King and Little Red Riding Hood PDFs

Second improvement (from user testing)

Testing surfaced that the failed-import gate toast told users to "remove the book" but provided no way to do it.

  • Added DELETE /api/books/{id} (owner-only, cascades child rows)
  • Failed book covers now show a Remove button on the shelf

Verification

make install && make demo-pdf
pnpm install && pnpm --filter @kinora/core test
pnpm --filter @kinora/desktop typecheck
make stack-up && make seed-demo   # or seed_e2e for fast pre-ingested shelf
make app-desktop-dev

Manual walkthrough (local stack):

  1. Log in → library shows ingest progress on uploading books
  2. Click a failed/importing book → blocked with toast; failed books can be removed
  3. Open a ready book → reading room loads PDF + cinema pane

Backend impact

  • New route: DELETE /api/books/{book_id} (204)
  • BookRepo.delete() helper
  • Test: test_delete_book_removes_from_shelf
Open in Web View Automation 

Summary by cubic

Adds live ingest progress to the desktop shelf and lets users remove failed imports. Also adds a second public‑domain demo book for testing.

  • New Features
    • @kinora/core: LibraryEventStream subscribes to GET /api/books/events (SSE ingest_progress) and patches React Query caches.
    • Desktop shelf UI: progress bar + stage label on covers; blocks non‑ready books with a clear gate message; shows upload errors in a dismissible banner.
    • Poll fallback every 5s while any book is importing to catch the final ready flip if SSE drops.
    • Failed imports: new Remove button on covers; backend DELETE /api/books/{id} (owner‑only) removes the book and cascades child rows.
    • New demo PDF: Little Red Riding Hood; make demo-pdf now builds both demos.
    • Tests for SSE parsing, shelf helpers, and DELETE /api/books/{id}.