Commit 2e1ef3f
Codex
fix(apps/landing): prevent hydration mismatch in live-signal-preview
The previous implementation called getSemanticBridgePreview() inside
useState's lazy initializer, which executes both during SSR and during
client hydration. Each call invoked new Date(), producing a different
observedAt timestamp on server vs client. The rendered chip then
formatted that timestamp with toLocaleTimeString(), which uses the
runtime's timezone and locale, so the server-rendered text never
matched the client-rendered text.
Fix:
- Initial state is now null (same on server and client first render).
- useEffect fetches the real preview from /api/live-signal; on non-OK
or network error it falls back to the local getSemanticBridgePreview()
on the client side, so the fallback timestamp is also client-only.
- A structurally identical placeholder section renders while preview
is null, with aria-busy on the section and aria-hidden on the empty
right-grid slot. The 'Observed ...' chip is replaced by the real
time string only after hydration completes, so toLocaleTimeString()
is never called during the SSR vs client diff.
Scope: this commit contains the hydration hotfix only. The Week 2
practice-surface additions (consult page, session-types, cohort-cta,
ARIA fixes to the practice components, content namespace additions
and the new tests) remain uncommitted in the working tree and will
be committed separately once the copy review lands.
Validation: pnpm typecheck, pnpm lint, pnpm test (12/12), pnpm build
(10 static routes + 2 dynamic API routes) all pass.1 parent 12d85de commit 2e1ef3f
1 file changed
Lines changed: 49 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
| |||
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
22 | 29 | | |
23 | 30 | | |
24 | | - | |
25 | | - | |
| 31 | + | |
| 32 | + | |
26 | 33 | | |
27 | | - | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| |||
33 | 40 | | |
34 | 41 | | |
35 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
36 | 80 | | |
37 | 81 | | |
38 | 82 | | |
| |||
0 commit comments