Skip to content

test(meditations): cover loadMeditation - #297

Merged
sydevs-bot merged 9 commits into
mainfrom
claude/fix-meditation-frames-payload
Nov 20, 2026
Merged

sydevs-bot merged 9 commits into
mainfrom
claude/fix-meditation-frames-payload

Conversation

@sydevs-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • Visitors and editors: nothing changes. This PR now only adds tests.
  • Developers: loadMeditation, the loader both meditation routes share, gets its first tests (F12c).

The meditation frames payload (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:

  • a 404 for a malformed id, with no read made
  • a 404 for a missing meditation
  • the route locale passed to both reads
  • the draft requested only under an unscoped preview session; the songs are never read as a draft
  • the published meditation read while the panel previews a global (scope: 'wm-web-config'). This test fails if the loader passes preview: session.active and ignores the scope.

Why the frames fix moved upstream

  • Where the bloat comes from. SahajCloud's frames afterRead hook (src/collections/Meditations/Meditations.ts) ran its own payload.find with no depth, so Payload's defaultDepth: 2 applied: 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 KB frames.
  • Why no client can narrow it. frames is a JSON field, so a client's select[frames][…] keys are ignored. That includes the installed mobile app, whose sub-selects on frames do nothing today. Only the server can fix it for every consumer.
  • The upstream fix. fix(meditations): stop keyframes carrying their chakra node's whole page SahajCloud#1233 reads the frames at depth 1 with populate: { 'subtle-system-nodes': { slug: true } }. A keyframe's subtleSystemNode becomes { id, slug }, which is all the app and the admin read, and every frame field stays as it is.
  • Removed from this PR: MEDITATION_FRAME_SELECT, narrowMeditationFrames, the narrow entry in COLLECTION_BY_ID_CONFIG and its step in getDocumentById, the server/AGENTS.md note about it, and the keyframe tests in server/sahajcloud-client.test.ts. server/ now matches main.

Not in this PR

  • downloadUrl vs mp4Url (seen, not fixed). components/templates/MeditationTemplate.tsx uses frame.downloadUrl as a video keyframe's fallbackSrc. No SahajCloud frame carries downloadUrl; the real field is mp4Url (for example, frame 79 of meditation 130). So that fallback never fires. This needs a separate template fix.

🤖 Generated with Claude Code

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
@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 e15e68f Commit Preview URL

Branch Preview URL
Nov 20 2026, 12:35 AM

Comment thread server/sahajcloud-client.ts Resolved
Comment thread server/sahajcloud-client.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 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 1

recent dispatches
  • 00:09Z fix-ci · attempt 1 · session · done
  • 00:09Z fix-ci · attempt 1 · session
  • 00:05Z resolve-conflicts · attempt 1 · session · done
  • 00:05Z resolve-conflicts · attempt 1 · session
  • 23:49Z address-review · attempt 1 · session · done

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

@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 19, 2026
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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 20, 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-design 27b960b Commit Preview URL

Branch Preview URL
Nov 20 2026, 12:15 AM

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both threads answered. Pushed as e240304, on top of a clean origin/main (54d8684) merge.

Naming — adopted (fe6e7f1), resolved. MEDITATION_FRAME_SELECT, select-shaped, typed against the generated FramesSelect. A keyframe field renamed upstream is now a compile error here.

Duplication — placement adopted (96bef1d), one premise corrected, left open. The narrowing moved into COLLECTION_BY_ID_CONFIG.meditations as narrow, applied by getDocumentById, so no caller remembers a second step and narrowMeditationFrames is unexported. But no populate reaches frames at all — SahajCloud's afterRead hook runs its own payload.find. Yours to settle.

Joined: server/AGENTS.md now records that exception to the select/populate contract. The four keyframe tests moved to the client's spec with the behaviour.

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

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 20, 2026
…-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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged origin/main (182fbb3) in. One conflicted file, server/sahajcloud-client.test.ts, in its import block and its mock block. Both hunks kept both sides.

The mock block is the one choice worth naming: main replaced the local @sentry/cloudflare mock with one hoisted captureMessage spy shared with @sentry/react, so warnOnce is countable. That spy also backs this branch's existing Sentry.captureMessage assertions, so it supersedes the mock this branch wrote rather than sitting beside it. The MeditationPlayer stub this branch added is untouched.

Lean gate green on the merge: 0 lint errors, tsc exits 0, 1,409 of 1,409 tests pass across 146 files.

🤖 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 20, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 20, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 20, 2026
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Smoke (web) is fixed by a base merge. Pushed as 27b960b.

The two red specs are not on this branch. /zz/map and /zz/meditations/142 are asserted to 404 by tests/smoke/web/map.smoke.test.ts and meditations.smoke.test.ts, both of which arrived with #315 on main. CI checks out the pull request's merge ref, so it ran main's new specs against a Cloudflare preview built from this branch's tip, which predates #315's routing fix.

Measured: wemeditate-web.contact-c66.workers.dev/zz/map answers 404, and all three of this branch's previews answered 200.

So merging origin/main (dbf71dc) is the whole fix: the push rebuilds the preview with #315's matchers in it. Nothing conflicted — #315 touched lib/atlas-route.ts, lib/document-routes.ts and the four +route.ts matchers, while this branch touches the meditations region of server/sahajcloud-client.ts and the _meditation.ts loader, which runs only after a matcher claims the path.

Lean gate green on the merge: 0 lint errors, tsc exits 0, 1,427 of 1,427 tests pass across 146 files.

🤖 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 20, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 20, 2026
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]>
@Ardnived Ardnived changed the title fix(server): ship meditation keyframes without their page documents test(meditations): cover loadMeditation Nov 20, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 20, 2026
Merged via the queue into main with commit ac69560 Nov 20, 2026
45 of 47 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-meditation-frames-payload branch November 20, 2026 00:41
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 20, 2026
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.

3 participants