Skip to content

feat(preview): stream unsaved lecture edits into the preview panel - #290

Merged
sydevs-bot merged 6 commits into
mainfrom
claude/feat-287-lecture-live-preview
Nov 19, 2026
Merged

sydevs-bot merged 6 commits into
mainfrom
claude/feat-287-lecture-live-preview

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • /lectures/:id now streams an editor's unsaved lecture edits into the SahajCloud preview panel.
  • Route data carries the collection's own shape, as both sibling preview routes do, and resolveLecture flattens it at render.
  • Joined: retires the removed /preview route's last dead branch and five comments still describing it.

Change outline

Flow — one read, one shape, resolved at render

 loadLecture(pageContext)                       pages/lectures/[id]/_lecture.ts
   loadLivePreview → previewArgs(session)       # active && scope === null
   getLecture({ id, locale, ...previewArgs })   server/sahajcloud-client.ts
-    → ResolvedLecture
+    → Lecture
   return { lecture, locale, id }

 Page()                                         pages/lectures/[id]/(full)/+Page.tsx
-  LectureTemplate(lecture)
+  LivePreviewDocument(initialData=lecture, slug="lectures")   # mounts always
+    children(live) → LectureBody(resolveLecture(live))        # per message, and once off-preview
+
+  LectureBody(lecture, locale)                  # usePageHead, sr-only h1, LectureTemplate

 Page()                                         pages/lectures/[id]/embed/+Page.tsx
-  LecturePlayer(lecture)
+  LecturePlayer(resolveLecture(lecture))        # no subscriber; nothing points a preview here

The stream carries a raw Lecture, so route data carries one too and resolveLecture runs inside
the callback. Handed the resolved shape, mergeData would lay raw fields over a view model and a
clip's own empty metadata would overwrite the parent's playback source.

LivePreviewDocument mounts unconditionally, which is what /[slug] and the meditation embed
already do: the component owns the off-preview case and then renders children(initialData) with
no subscription at all. lib/live-preview/document.test.tsx is where that case is covered.

Types

 interface LectureData {
-  lecture: ResolvedLecture; locale: Locale; id: string
+  lecture: Lecture; locale: Locale; id: string
 }

One shape serves both lecture routes, as one serves both meditation routes. /lectures/:id/embed
is not a preview target — SahajCloud's Lectures.ts builds admin.livePreview.url from
lectures/${data.id}, checked on that repo's main — so it mounts no subscriber and resolves
once, for its render.

Files — the removed /preview route's leftovers

 lib/content-blocks.ts
-  leadSplashFromRouteData({ page, collection, initialData })   # the pair was unreachable
+  leadSplashFromRouteData({ page })

Nothing under pages/ has put collection or initialData into route data since that route went,
so only the function's own two specs exercised the branch; both go with it.

Preview

https://claude-feat-287-lecture-live-preview-wemeditate-web.contact-c66.workers.dev — the deep
links a reviewer wants are /lectures/<id> and /lectures/<id>/embed on it.

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh — lint + tsc --noEmit + test:run, 130 files, 1222 tests
  • Targeted specs: pages/lectures, tests/a11y, lib/live-preview, lib/content-blocks — all passed
  • Build: N/A — not run locally; the Cloudflare preview build is the real one

Each of the four streaming cases in pages/lectures/[id]/(full)/Page.test.tsx was watched failing
against origin/main's +Page.tsx before being kept. The fifth asserts the saved lecture renders
when the panel streams nothing.

Manual verification

The acceptance criteria no spec can reach need a SahajCloud environment whose
WEMEDITATE_WEB_URL points at this branch's preview:

  1. Open /admin/collections/lectures/<id>, open the preview panel, and type in the title — the
    panel updates with no save.
  2. On a clip, confirm the panel still plays the parent's video inside the clip window, with
    merged subtitles.
  3. Open /lectures/<id> directly in a browser: the saved lecture renders and the console shows no
    postMessage traffic.

Notes for reviewer

The third commit is a joined finding, not ticket scope — review it on its own. The ticket's notes
say the old pages/preview/ renderer left no dead path; leadSplashFromRouteData is one, and
LayoutChrome's RouteData carried the two type members that fed it.

Once this merges, SahajCloud drops its opt-out — custom: { livePreviewSubscribes: false } on
Lectures and the ['lectures'] expectation in tests/unit/preview-notice-coverage.spec.ts.
Neither is on SahajCloud main: both arrive with open PR sydevs/SahajCloud#1209, which is also
what gives the lecture panel the "the preview did not load" notice. The removal is one line of
that repo's, once this merges.

Review findings dismissed, and why
  • Ship only the raw document and resolve client-side (two lenses proposed it). Adopted in
    f52026e
    , on the reviewer's ask for consistency. It was first rejected to keep a visitor's
    payload on the smaller shape; the reviewer weighed one shape across all three preview routes
    above that, which is their call. A clip's payload does grow by its populated parent.
  • Send both shapes on every request, dropping the condition. Moot: the route now sends one
    shape, the raw document, as /[slug] and the meditation embed each do.
  • A transform prop on LivePreviewDocument. Rejected: it would relocate two lines at one
    call site and eliminate none of the branch's other changes, while forcing a second generic
    through lastGoodRef and createPopulateRequestHandler. The initialData doc now states the
    contract instead.
  • Extract a shared raw-Lecture factory and a vike-mock helper for the test suite. Real
    duplication, but it reaches three unrelated specs and is not this ticket's. Left as is.
  • Drop the clip-window assertion as template coverage. Kept: it is the one assertion proving
    the streamed clip's own startTime/stopTime are read, which the poster assertion does not
    cover — that one travels through the parent relationship.

A security review ran on each push touching server/, and found nothing. The raw document now
reaches every public lecture view rather than only a preview one, so the question is what it
publishes that the view model did not: LECTURE_SELECT bounds the fields, LECTURE_POPULATE
bounds the relationships to images (url, filename, alt, width, height) and to
lectures under that same select, and lectures carries no _status upstream. So no other
collection is reachable, no draft state travels, and the new facts a visitor can read are
metadata.lastSyncedAt, the thumbnail's dimensions and filename, and the parent's own title and
window — all facts about published content. The subscriber's origin and token gates are unchanged.

Closes #287

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjUpipU8QSczmHeXTxG

`/lectures/:id` rendered `LectureTemplate` bare, so no subscriber mounted and
nothing answered Payload's `payload-live-preview` handshake. The panel showed
the saved lecture and an editor had to save to see anything.

The server half was already wired — `loadLecture` threads `previewArgs` into
the read, and SahajCloud emits an unscoped session for `lectures`, so
`useDocumentPreviewActive()` was already true here. Only the client subscriber
was missing.

⚠ The stream carries a raw `Lecture`, and this route renders a
`ResolvedLecture`. A subscriber handed the resolved shape would merge raw
fields into a view model, and a clip's own empty `metadata` would overwrite the
parent's playback source. So `getLecture` returns the document beside the
resolved lecture, the route subscribes to the document, and `resolveLecture`
runs inside the children callback.

`/lectures/:id/embed` is not a preview target, so its `+data` drops the
document rather than shipping a second copy of the lecture.

The a11y fixture now derives its `ResolvedLecture` from a raw document, which
also retires a `Lecture` cast over a shape no read returns.

Refs #287

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZZmo9WcDoppHwEnpa
The review pass found the first commit shipping both shapes of the lecture to
every visitor. The raw document is the larger of the two — a clip carries its
whole populated parent — and only an open preview session ever reads it.

`loadLecture` now sends it under `previewArgs`' own condition, which is what
`useDocumentPreviewActive()` decides on the other side, and `null` otherwise.
The page branches on that, so off-preview nothing changes for a visitor: the
server's view model renders, and `resolveLecture` does not run in the browser
at all.

`LectureBody` is what the two arms share. `usePageHead` moves into it, so under
the panel the `<title>` follows the stream too — `PageTemplate` already does
that on `/[slug]`, and the comment claiming otherwise was wrong.

`LivePreviewDocument`'s `initialData` now states the rule both call sites were
restating: the stream merges into the collection's own shape, so derive inside
`children`. Its "two call sites" count goes to three.

The spec drops the case that only re-covered `resolveLecture` and
`LectureTemplate`, reads its copy from `EN_TRANSLATIONS`, narrows the poster
assertion with `openTag`, and gains the off-preview case.

Refs #287

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZZmo9WcDoppHwEnpa
Five comments still described live preview as its own route, which
`lib/live-preview/document.tsx` replaced: a preview is the real URL carrying
`?live-preview=`. The ticket's own notes say no dead path survives that
removal. One does.

`leadSplashFromRouteData` still read a `collection` / `initialData` pair off
route data, and nothing under `pages/` has put either there since the route
went. The branch could not fire, and only its own two specs exercised it, so
both go with it. `[slug]`'s `page` is the one shape left to read.

Its comment in `LayoutChrome` now says what the surviving code does: the
overlay reads the server's page, so a splash added in the panel reaches the
header only after a save.

Refs #287

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZZmo9WcDoppHwEnpa
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-design fd3e921 Commit Preview URL

Branch Preview URL
Nov 19 2026, 05:15 PM

@sydevs-bot

sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 17:58Z address-review · attempt 1 · session · done
  • 17:58Z address-review · attempt 1 · session
  • 17:25Z address-review · attempt 1 · session · done
  • 17:25Z address-review · attempt 1 · session
  • 17:16Z review-pr · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-web f52026e Commit Preview URL

Branch Preview URL
Nov 19 2026, 06:06 PM

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 19, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The diff matches the ticket and stops where the ticket stops. The platform owns the transport, resolveLecture already existed, and the producer side holds: SahajCloud main points the lecture panel at lectures/<id> unscoped, so previewArgs and useDocumentPreviewActive() test one condition.

One shape question is open. Sending the raw document only under preview buys an unmeasured payload saving on public lecture views. It costs two exported types, a nullable field, a second off-preview branch, and a route that no longer matches its siblings — /[slug] and the meditation embed hand LivePreviewDocument the collection shape unconditionally and let its gate decide. The body rebuts raw-only and a transform prop well, but never weighs the third option: send both, always.

Findings

  • should-fix — the closing note names custom: { livePreviewSubscribes: false } and tests/unit/preview-notice-coverage.spec.ts. Neither is on SahajCloud main. Both ship in open PR sydevs/SahajCloud#1209, so name it.
  • consider — pages/lectures/[id]/embed/+data.ts:16: the strip, and LectureLoad with it, guard a URL nothing points at.
  • consider — pages/lectures/[id]/_lecture.ts:22: document shadows the DOM global, and its consumer renames it.

What was checked

Read whole on the branch: live-preview/document.tsx, server/live-preview.ts, lecture-shape.ts, both sibling call sites, lib/head.tsx and the new spec. Ladder: LivePreviewDocument and resolveLecture are reused, and LectureBody earns its boundary, because usePageHead sits behind an early return. Consumer side: Lectures.ts admin.livePreview.url on SahajCloud main, and a grep there for livePreviewSubscribes. ContentHead does return null under livePreview.active (lib/head.tsx:179), so the [slug]/+config.ts edit is true.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread pages/lectures/[id]/embed/+data.ts Resolved
Comment thread pages/lectures/[id]/_lecture.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 19, 2026
`document` is the DOM global, and the route's only consumer renamed it on
destructure. Both sibling subscribers carry the raw document under its
collection's noun — `page` on `/[slug]`, `meditation` on the meditation
embed — and `tests/a11y/fixtures.ts` already spells this one `lectureDocument`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjUpipU8QSczmHeXTxG
Nothing points a preview at `/lectures/:id/embed` — SahajCloud's `Lectures`
builds `admin.livePreview.url` from `lectures/${data.id}` — so the embed
route's strip fired only for a hand-written `?live-preview=` URL, where it
saved one copy of a document nothing there reads. Folding the field into
`LectureData` retires `LectureLoad` and leaves the two lecture routes
sharing one shape again, as the meditation pair do.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjUpipU8QSczmHeXTxG
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both critic threads adopted; pushed as b92b829.

Review body, two points:

Body also refreshed: types block, preview URL. Lean gate green.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 19, 2026 17:34
@sydevs-bot
sydevs-bot requested a review from Ardnived November 19, 2026 17:34
@sydevs-bot
sydevs-bot enabled auto-merge November 19, 2026 17:34
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 19, 2026
Comment thread server/sahajcloud-types.ts Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 19, 2026
The route held two shapes from one read: a `ResolvedLecture` for the
render and a nullable raw `Lecture` sent only under preview. Both sibling
preview routes carry the collection's own shape unconditionally and let
`LivePreviewDocument` decide whether to subscribe, so this route is now
the same: route data holds the raw `Lecture`, `resolveLecture` runs in the
subscriber's callback, and the embed route resolves once for its render.

Removes the `LectureRead` interface, the nullable `lectureDocument` field
and the off-preview branch in `+Page`. A visitor's payload becomes the raw
document rather than the view model; every field in it is narrowed by
`LECTURE_SELECT` and `LECTURE_POPULATE`, which publish no collection the
resolved shape did not, and `lectures` carries no `_status`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY1YHgCWGC1j5YMcAE
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Adopted the one open thread, pushed as f52026e.

  • Is this pattern needed? — the premise held. The route now carries the raw Lecture and resolves at render, so all three preview routes hand LivePreviewDocument the collection's own shape. LectureRead, the nullable lectureDocument field and the off-preview branch are gone.

The condition was buying one thing, and it is now spent: a clip's public payload grows by its populated parent. The body's security review is rewritten for that — LECTURE_SELECT and LECTURE_POPULATE bound what the raw document publishes, and lectures carries no _status.

Body refreshed where this push made it false: summary, change outline, types, and the two dismissed findings this reverses.

Lean gate green — lint, tsc, 1222 tests.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
Merged via the queue into main with commit beb7e10 Nov 19, 2026
36 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-287-lecture-live-preview branch November 19, 2026 22:17
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 19, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 19, 2026
main moved the player to Video.js 10 (#285) and started streaming unsaved
lecture edits into the preview panel (#290). Both sides are kept:

- package.json / pnpm-lock.yaml: main's `@videojs/*` replaces `vidstack` and
  `hls.js`; this branch's `unhead` and `@unhead/schema-org` stay.
- pages/[slug]/+config.ts: comment only. `ContentHead` is gone here, so the
  text describing it went with it.
- pages/lectures/[id]/(full)/+Page.tsx: main's `LivePreviewDocument`
  subscriber and `LectureBody` are kept; `usePageHead` is not, because the
  head is the route's `+data.ts` on this branch.

Semantic conflict, outside any marker: #290 made `loadLecture` and
`getLecture` answer a raw `Lecture` and moved `resolveLecture` to the render,
so the two consumers this branch adds — the lecture `+data.ts` head and
`/oembed`'s `readMedia` — resolve it themselves. Both read a clip's player
source and poster from its parent, as the page does.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWiiELoro82VSgyRc7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

feat(preview): stream unsaved lecture edits into the preview panel

3 participants