Repository navigation
test(meditations): cover loadMeditation - #297
Conversation
A meditation's `frames` is a JSON field that SahajCloud fills in its own afterRead hook, with a `payload.find` on `frames` that takes no select, populate or depth from the request. So every keyframe on a chakra arrived with its subtle-system node's whole `page` document (content, managers, author, webUrl), and `loadMeditation` serialised all of it into the page: 58,803 B of `data.meditation.frames` on /meditations/17. No query variant narrows it. Against production, depths 0-3 and populate entries for `frames`, `subtle-system-nodes` and `pages` all return the same frames byte for byte, so the read itself cannot be fixed from here. `narrowMeditationFrames` keeps the keyframe fields MeditationTemplate reads (id, timestamp, url, mimeType, duration, downloadUrl) and the loader both meditation routes share applies it. The meditation's own fields, which the player and the head read, are untouched. The result is still the collection's own shape, so it can stay live preview's `initialData`: `mergeData` reads only its id, and a streamed document arrives whole from the populate proxy and renders the same. data.meditation.frames, deployed main -> this branch (local dev server against production SahajCloud): 17: 58,803 -> 1,999 B; 130: 30,284 -> 1,512 B; 105: 16,891 -> 997 B. These are the loader's first tests. A test hands the template's player the keyframes built from the whole and the narrowed document and requires them equal, so a field the template starts reading fails here until it is added to the list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
…review MEDITATION_FRAME_FIELDS works around a limit it did not name: the Worker still downloads every keyframe whole from SahajCloud, because the frames afterRead hook in sydevs/SahajCloud's Meditations collection passes no select or depth to its own read. The list now says so with a `shortcut:` line that points at that hook, so it can go once the hook takes either. The preview test only checked an unscoped session. A session previewing a global (scope 'wm-web-config') must still read the published meditation, and nothing pinned that: a loader passing `preview: session.active` would have passed every test. It now fails that way. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | e15e68f | Commit Preview URL Branch Preview URL |
Nov 20 2026, 12:35 AM |
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
Ardnived asked for consistency with LECTURE_SELECT. The list is now MEDITATION_FRAME_SELECT, select-shaped, and typed against the generated FramesSelect plus the three keys that are outside it, so an upstream rename of a keyframe field is a compile error here rather than a field silently dropped from the player — the guarantee server/AGENTS.md asks of every select constant. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXAtLV94y7ES2wqM5J
Ardnived asked whether this duplicates the existing per-collection select system. It does not duplicate it, but it sat beside it: the route loader had to remember a second step, so a third reader of a meditation would have shipped the keyframes whole. COLLECTION_BY_ID_CONFIG already owns a collection's read shape, so the narrowing is registered there as `narrow` and getDocumentById applies it. narrowMeditationFrames is no longer exported, and the loader is back to a plain read. documentReadArgs deliberately does not carry it: live preview's populate proxy answers an editor's own browser. The keyframe tests move with the behaviour, from the loader's spec to the client's, where the SDK stub makes them a test of the real wiring rather than of a mocked read. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXAtLV94y7ES2wqM5J
The select/populate contract now has an exception, and nothing in server/ said so. The next reader otherwise spends the same afternoon trying query variants against production that this branch already ruled out. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXAtLV94y7ES2wqM5J
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-design | 27b960b | Commit Preview URL Branch Preview URL |
Nov 20 2026, 12:15 AM |
|
Both threads answered. Pushed as e240304, on top of a clean Naming — adopted (fe6e7f1), resolved. Duplication — placement adopted (96bef1d), one premise corrected, left open. The narrowing moved into Joined: Lean gate green on the merged result: 141 files, 1,336 tests. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
…-frames-payload main gave `server/sahajcloud-client.test.ts` a shared `captureMessage` spy across both Sentry SDKs, plus `forgetReportedWarnings`. This branch gave the same file a `MeditationPlayer` stub that captures its `frames` prop. Both blocks are kept: the shared spy also backs this branch's existing `Sentry.captureMessage` assertions. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVPjSPbrSaEG9wq1aL
|
Merged The mock block is the one choice worth naming: Lean gate green on the merge: 0 lint errors, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Smoke (web) failed on `/zz/map` and `/zz/meditations/142` answering 200 where 404 is asserted. Neither assertion exists on this branch: both arrived with #315 on main. CI checks out the pull request's merge ref, so it ran main's new smoke specs, while the Cloudflare preview it fetched was built from this branch's tip, which predates that routing fix. Production answers 404 for `/zz/map`; all three of this branch's previews answer 200. So the merge is the fix. Pushing it rebuilds the preview with #315's routes in it, and the specs then run against a Worker that has them. Nothing conflicted. #315 touched `lib/atlas-route.ts`, `lib/document-routes.ts` and the four `+route.ts` matchers; this branch touches the meditations region of `server/sahajcloud-client.ts` and the `_meditation.ts` loader, which runs only after a matcher has claimed the path. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXbkobB5uhfhfthYE5
|
Smoke (web) is fixed by a base merge. Pushed as 27b960b. The two red specs are not on this branch. Measured: So merging Lean gate green on the merge: 0 lint errors, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The `frames` bloat comes from SahajCloud's afterRead hook reading frames at defaultDepth 2, so each chakra keyframe carries its node's whole page. No client can narrow a JSON field with `select`, the installed mobile app included, so the fix belongs in that hook, not in each consumer. With it fixed upstream, `narrow`, `MEDITATION_FRAME_SELECT` and their tests have nothing left to do. The loadMeditation tests stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
loadMeditation, the loader both meditation routes share, gets its first tests (F12c).The meditation
framespayload (F6) is now fixed in SahajCloud, in sydevs/SahajCloud#1233, instead of here. The client-side narrowing this PR used to add has been removed.Tests
Five tests, in
pages/meditations/[id]/_meditation.test.ts:scope: 'wm-web-config'). This test fails if the loader passespreview: session.activeand ignores the scope.Why the frames fix moved upstream
framesafterRead hook (src/collections/Meditations/Meditations.ts) ran its ownpayload.findwith nodepth, so Payload'sdefaultDepth: 2applied: frame →subtleSystemNode→page. That put each chakra keyframe's whole Page document into every meditation read. On /meditations/17 that was about 57 KB of the 59 KBframes.framesis a JSON field, so a client'sselect[frames][…]keys are ignored. That includes the installed mobile app, whose sub-selects onframesdo nothing today. Only the server can fix it for every consumer.populate: { 'subtle-system-nodes': { slug: true } }. A keyframe'ssubtleSystemNodebecomes{ id, slug }, which is all the app and the admin read, and every frame field stays as it is.MEDITATION_FRAME_SELECT,narrowMeditationFrames, thenarrowentry inCOLLECTION_BY_ID_CONFIGand its step ingetDocumentById, theserver/AGENTS.mdnote about it, and the keyframe tests inserver/sahajcloud-client.test.ts.server/now matchesmain.Not in this PR
downloadUrlvsmp4Url(seen, not fixed).components/templates/MeditationTemplate.tsxusesframe.downloadUrlas a video keyframe'sfallbackSrc. No SahajCloud frame carriesdownloadUrl; the real field ismp4Url(for example, frame 79 of meditation 130). So that fallback never fires. This needs a separate template fix.🤖 Generated with Claude Code