chore(memory): TODO + journal + BDR-009..011 + LRN-011..012
Mark B0/B1/B2/B5 done on TODO. Journal 2026-05-20 entry with the three commit SHAs and a per-phase recap. Three new design decisions captured: JSON snake_case kept in TS (BDR-009), snapshot labels at selection time (BDR-010), hard-fail v1 PDF with FR-language message (BDR-011). Two new learnings: Zod recursive schemas via z.lazy + explicit ZodType<T> (LRN-011), once-per-session UX modal via sessionStorage flag (LRN-012). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b67f4cd82b
commit
b7b094535e
4 files changed
+79
-65
No files matched your search
@@ -80,3 +80,17 @@ Apply: any pdf-lib page where image count is data-driven and text must remain vi
|
||||
Symptom: highlight effect (querySelectorAll + setAttribute) silently no-ops when sibling effect appends DOM async via loadSvg().then(append). First render: mutate-effect runs against empty container, then DOM arrives, then nothing re-paints because deps didn't change. Symptom is intermittent ("sometimes highlighted, sometimes not") — actually depends on which effect resolves first on a given mount.
|
||||
Fix pattern: hold a `loadedSrc` state, set it to null at src-change, set it to src right after appendChild, and depend the mutate-effect on [data, loadedSrc, src] with guard `if (loadedSrc !== src) return`. Now the mutate-effect re-runs both on data change AND when DOM finishes mounting.
|
||||
Apply: any React component that mounts external DOM async and applies attribute/style mutations in a separate effect. Includes inline SVG injection, MapLibre overlays, Lottie players. Never rely on effect ordering across an async boundary.
|
||||
|
||||
---
|
||||
|
||||
## LRN-011 | 2026-05-20 | Zod recursive schema via z.lazy + explicit ZodType<T>
|
||||
|
||||
Recursive shapes (FindingNode with optional children: FindingNode[]) need TS interface declared first, then `const FindingNodeSchema: z.ZodType<FindingNode> = z.lazy(() => z.object({...}))`. Without the explicit ZodType<T> annotation, TS infers `any` for the recursive arm and the entire downstream type chain collapses. Without z.lazy, the schema references itself before initialization → runtime ReferenceError.
|
||||
Apply: any tree/AST-style schema in Zod 3.x. Declare interface first, type the schema explicitly, wrap recursive shape in z.lazy. Same trick works for ZodType<U[]> when the recursion is via children: U[].
|
||||
|
||||
---
|
||||
|
||||
## LRN-012 | 2026-05-20 | Once-per-session UX modal via sessionStorage flag
|
||||
|
||||
Pattern: state `disclaimer: string | null`, useEffect on the data dep that reads `sessionStorage.getItem(FLAG)`; if absent, set state to the message. Acknowledge handler writes the flag and clears state. Survives reloads within tab, resets on new tab. Cheaper than persisting per-user (no backend) and respects practitioner intent — they see the legal scope reminder once per work session.
|
||||
Apply: any single-praticien tool needing one-shot acknowledgment per session (legal disclaimers, version-change notices, GDPR banners scoped to a session). Use a stable string key prefixed with `osteo:` to avoid collision.
|
||||
Reference in new issue
Block a user