Skip to content

Remote control + per-PDF resume via Solid state docs #1

Description

@melvincarvalho

What

Two Solid-native features that turn the pod into a shared state layer for the PDF reader:

  1. Remote control — viewer writes its current `{pdfUrl, page}` to `/public/pdf/state.jsonld` on every page change and subscribes to that doc via JSS's legacy WebSocket. Any other client that PUTs the doc (the bundled CLI, a phone, `curl`) drives the viewer in real time.
  2. Per-PDF resume — viewer also writes a sibling `.state.jsonld` next to each PDF. On open, the viewer reads this and jumps to the last-read page. Owner-write, public-read inherited from `/public/.acl` — no special ACL.

The two layers are independent: remote control drives which page is active right now; resume remembers where each PDF was across sessions.

Why

Generic PDF readers can't do this — it's the pod being a real-time state bus, not just file storage. Live demo without any peer-to-peer setup: open the viewer in one window, run `pdf-remote next` in a terminal, watch the page flip.

Implementation sketch

  • `src/app.js` gains `ensureStateDoc`, `pushState` (debounced), `subscribeState` (WS with reconnect/backoff), `loadResumePage`, `perPdfStateUrl`. ~90 lines.
  • `cli/pdf-remote` — 30-line bash script using `curl + jq` for GET-modify-PUT. Defaults to localhost:5444; `PDF_STATE` env var to point elsewhere.
  • ACL written as JSON-LD (JSS is JSON-LD-first; rejects Turtle for writes).
  • README updated with the CLI snippet and a "Solid-native" features section.

Test plan

  • Viewer flips pages in real time when CLI runs `next | prev | page N` from a separate terminal
  • Per-PDF resume: open PDF, flip to page 12, close tab, reopen → lands on page 12
  • Switching between two PDFs preserves each one's last-read page
  • WS reconnect: if jspod restarts, viewer reconnects within ~10s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions