fix: read AnimationConfigCtx lazily in HydrationControlCtx#23
Merged
Conversation
The hydration control contexts were reading AnimationConfigCtx once at Layer construction (at the hydration root) and closing over the result. Since each's animate config is provided locally via Effect.provideService around the each, the captured value was always undefined — the layer runs before any each has a chance to provide its config. Net effect: list animations were silently dropped on every hydrated page (SSG/SSR). Mirrors the ClientControlCtx pattern: read AnimationConfigCtx via Effect.serviceOption inside addSlot/removeSlot, so each call sees the config its parent provided. Drops the captured animationConfig parameter from createClientLikeControlCtx and createHydrationControlCtx entirely; the Layer no longer pre-reads the service. Confirmed all existing Control/hydrate/Animation tests still pass (50 tests, 3 files). Closes #22 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Deploying effex with
|
| Latest commit: |
2e2670e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f71ab932.effex.pages.dev |
| Branch Preview URL: | https://fix-hydration-animation-conf.effex.pages.dev |
Deploying effex-api with
|
| Latest commit: |
2e2670e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8ee54fe8.effex-api.pages.dev |
| Branch Preview URL: | https://fix-hydration-animation-conf.effex-api.pages.dev |
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes list animations being silently dropped on hydrated pages (SSG + SSR).
each'sanimateconfig is supplied locally viaEffect.provideService(AnimationConfigCtx, ...)wrapping theeachbody.ClientControlCtxalready reads this config lazily insideaddSlot/removeSlotviaEffect.serviceOption(AnimationConfigCtx)— so when aneachprovides config one frame up, the client context sees it. ✅HydrationControlCtxwas reading it once at Layer construction time, at the hydration root — before anyeachhad a chance to run. The captured value was alwaysundefined, everyif (animate && ...)guard short-circuited, and animations were silently skipped. ❌This change mirrors
ClientControlCtx's pattern: everyaddSlot/removeSlotreadsAnimationConfigCtxviaEffect.serviceOptionat the moment the effect runs. Drops the capturedanimationConfigparameter fromcreateClientLikeControlCtxandcreateHydrationControlCtxentirely; the Layer no longer pre-reads the service.Diagnosis credit
The diagnosis came from an investigation by another agent looking at why list animations silently failed on a hydrated SSG portfolio site. The specific evidence trail:
Control/index.ts:172—eachprovidesAnimationConfigCtxlocallyClientControlCtx.ts:111-112— client context reads it lazily insideaddSlot(works)HydrationControlCtx.ts:418-435(before this fix) — hydration context read it at Layer construction (broken)undefinedvalue was threaded throughfork → createClientLikeControlCtx, so even forked client-like contexts inherited the staleundefinedTest plan
pnpm exec tsc --noEmitinpackages/dom— cleanhydrate.test.tsthat exerciseseachwithanimateduring hydration. Skipped here to keep the fix focused — the change is purely "do the same thing ClientControlCtx already does."Closes #22
🤖 Generated with Claude Code