feat(sync): unlinked-books queue — ingest, page route, dashboard banner
Release / build-and-push (push) Successful in 3m7s

The identification queue for device files the sync cannot match is now
live end-to-end. Previously the whole feature was dark: unmatched device
files were silently dropped (losing their reading progress), the queue
table sat empty by construction, and the page template had no route.

- Ingest: the KOReader sync loop, on an unresolvable file, upserts
  unlinked_books (one row per device + content id; re-syncs bump
  last_seen_at and refresh device-reported metadata) instead of
  dropping the file. Schema gains the (device_id, content_id) unique
  index the upsert needs.
- Page: GET /unlinked-books routes the existing page template, listing
  the caller's own unresolved rows (ListUnresolvedUnlinkedBooksForUser
  — devices.user_id scoping; no cross-user leakage).
- Dashboard banner: a warning card above the shelves, rendered only
  when the caller's queue is non-empty (hidden-unless-needed), linking
  to the page.
- Resolve flow unchanged and already gated: MatchingHandler.LinkBook
  verifies device ownership and target-item visibility (403s) and
  creates the device file alias, so the next sync matches by path.
  SyncHandler.LinkBook and Handler.LinkBook are unrouted dead handlers
  — triage candidates, not part of the live flow.
This commit is contained in:
John O'Keefe committed 2026-10-18 16:45:48 -04:00
1 parent 9e831085ef
commit d74db03cf3
10 files changed
+823 -454

No files matched your search

+19 -1
View File
@@ -5,7 +5,7 @@ import (
"fmt"
)
templ Dashboard(user User, sections []handlers.SectionData, allSections []handlers.SectionData, libData []LibraryData, currentLibraryID string, hiddenCollections []string, itemsPerSection int, week *WeekStatsData, activeLibType string, errorMessage string) {
templ Dashboard(user User, sections []handlers.SectionData, allSections []handlers.SectionData, libData []LibraryData, currentLibraryID string, hiddenCollections []string, itemsPerSection int, week *WeekStatsData, activeLibType string, errorMessage string, unlinkedCount int) {
<!DOCTYPE html>
<html lang="en">
<head>
@@ -23,6 +23,24 @@ templ Dashboard(user User, sections []handlers.SectionData, allSections []handle
re-render wipes that container's innerHTML, and anything
server-rendered inside it dies on the first library
switch. The widget re-fetches itself via htmx instead. -->
if unlinkedCount > 0 {
<div class="mx-auto container px-4 sm:px-6 lg:px-8 pt-4">
<a
href="/unlinked-books"
class="card p-4 flex items-center gap-3 transition-colors hover:bg-surface-hover"
style="border-left-width: 4px; border-left-color: var(--status-warning);"
>
<span class="grid place-items-center h-8 w-8 rounded-lg shrink-0" style="background-color: color-mix(in srgb, var(--status-warning) 16%, transparent); color: var(--status-warning);">
@Icon("alert", "h-4 w-4")
</span>
<span class="flex-1 text-sm" style="color: var(--text-primary)">
<span class="font-semibold">{ fmt.Sprintf("%d", unlinkedCount) }</span>
{ pluralizeBooks(unlinkedCount) } on your devices could not be identified — reading progress for them is paused until they are linked.
</span>
<span class="text-sm font-medium shrink-0" style="color: var(--accent)">Review →</span>
</a>
</div>
}
if week != nil {
<div class="w-full px-4 sm:px-6 lg:px-8 pt-6">
@DashboardWeekWidget(*week, activeLibType)