Repository navigation
feat(preview): stream unsaved lecture edits into the preview panel - #290
Conversation
`/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
Deploying with
|
| 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 |
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
Deploying with
|
| 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
left a comment
There was a problem hiding this comment.
🧐 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 namescustom: { livePreviewSubscribes: false }andtests/unit/preview-notice-coverage.spec.ts. Neither is on SahajCloudmain. Both ship in open PR sydevs/SahajCloud#1209, so name it.consider—pages/lectures/[id]/embed/+data.ts:16: the strip, andLectureLoadwith it, guard a URL nothing points at.consider—pages/lectures/[id]/_lecture.ts:22:documentshadows 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
`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
|
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 |
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
|
Adopted the one open thread, pushed as f52026e.
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 — Body refreshed where this push made it false: summary, change outline, types, and the two dismissed findings this reverses. Lean gate green — lint, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
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
Summary
/lectures/:idnow streams an editor's unsaved lecture edits into the SahajCloud preview panel.resolveLectureflattens it at render./previewroute'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 hereThe stream carries a raw
Lecture, so route data carries one too andresolveLectureruns insidethe callback. Handed the resolved shape,
mergeDatawould lay raw fields over a view model and aclip's own empty
metadatawould overwrite the parent's playback source.LivePreviewDocumentmounts unconditionally, which is what/[slug]and the meditation embedalready do: the component owns the off-preview case and then renders
children(initialData)withno subscription at all.
lib/live-preview/document.test.tsxis 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/embedis not a preview target — SahajCloud's
Lectures.tsbuildsadmin.livePreview.urlfromlectures/${data.id}, checked on that repo'smain— so it mounts no subscriber and resolvesonce, for its render.
Files — the removed
/previewroute's leftoversNothing under
pages/has putcollectionorinitialDatainto 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>/embedon it.Test results
.claude/skills/pr-prep/check.sh— lint +tsc --noEmit+test:run, 130 files, 1222 testspages/lectures,tests/a11y,lib/live-preview,lib/content-blocks— all passedEach of the four streaming cases in
pages/lectures/[id]/(full)/Page.test.tsxwas watched failingagainst
origin/main's+Page.tsxbefore being kept. The fifth asserts the saved lecture renderswhen the panel streams nothing.
Manual verification
The acceptance criteria no spec can reach need a SahajCloud environment whose
WEMEDITATE_WEB_URLpoints at this branch's preview:/admin/collections/lectures/<id>, open the preview panel, and type in the title — thepanel updates with no save.
merged subtitles.
/lectures/<id>directly in a browser: the saved lecture renders and the console shows nopostMessagetraffic.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;leadSplashFromRouteDatais one, andLayoutChrome'sRouteDatacarried the two type members that fed it.Once this merges, SahajCloud drops its opt-out —
custom: { livePreviewSubscribes: false }onLecturesand the['lectures']expectation intests/unit/preview-notice-coverage.spec.ts.Neither is on SahajCloud
main: both arrive with open PR sydevs/SahajCloud#1209, which is alsowhat 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
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.
shape, the raw document, as
/[slug]and the meditation embed each do.transformprop onLivePreviewDocument. Rejected: it would relocate two lines at onecall site and eliminate none of the branch's other changes, while forcing a second generic
through
lastGoodRefandcreatePopulateRequestHandler. TheinitialDatadoc now states thecontract instead.
Lecturefactory and a vike-mock helper for the test suite. Realduplication, but it reaches three unrelated specs and is not this ticket's. Left as is.
the streamed clip's own
startTime/stopTimeare read, which the poster assertion does notcover — that one travels through the parent relationship.
A security review ran on each push touching
server/, and found nothing. The raw document nowreaches every public lecture view rather than only a preview one, so the question is what it
publishes that the view model did not:
LECTURE_SELECTbounds the fields,LECTURE_POPULATEbounds the relationships to
images(url,filename,alt,width,height) and tolecturesunder that same select, andlecturescarries no_statusupstream. So no othercollection 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 andwindow — 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