Repository navigation
feat: add deterministic 'today's gotcha' pick to the pattern library - #26
Merged
Merged
Conversation
- src/lib/gotcha-of-the-day.ts: pure function of the date that cycles through INTERVIEW_PATTERNS one entry per calendar day (stable, no Math.random, no per-visit state, SSR/hydration safe). - PatternLibrary.tsx: small 'Today's gotcha' callout above the categorized list; clicking it expands and scrolls to the matching pattern row via the existing focus interaction. The pick renders client-only after mount. - Fix the missing pattern-row id the existing scroll-to-focus effect already referenced, so jumping to a pattern actually scrolls. - tests/gotcha-of-the-day.test.ts: determinism, stability within a local day, one-step daily rotation, full-list cycling, and year-boundary wrap. Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Highlights one entry from the existing
INTERVIEW_PATTERNSlist as "today's gotcha" — deterministic per calendar date, no backend, no randomness.Changes
src/lib/gotcha-of-the-day.ts(new):gotchaForDate(date)/gotchaIndexForDate(date)— a pure function of the date. Indexed by the visitor's local calendar date, advancing one entry per day and cycling through the full 15-entry list (day-count modulo length, with a safe negative-modulo). NoMath.random, no stored state.src/components/devtools/PatternLibrary.tsx: a small, understated "Today's gotcha" card above the categorized list showing the picked pattern's title. Clicking it expands and smooth-scrolls to the matching row using the existing focus interaction (focusedprop → open +scrollIntoView), which works on both the timeline tab and era pages. The pick is computed client-only after mount so SSR and client render agree.PatternRowfix: the row<section>was missing thepattern-row-<id>attribute its own scroll-to-focus effect already references, so the existing jump interaction silently never scrolled. Added it.tests/gotcha-of-the-day.test.ts(new): determinism for the same date, stability across any time within the same local day, always-valid index, one-step daily rotation, full-list cycling over consecutive days, and clean wrap across a year boundary.Scope
INTERVIEW_PATTERNSis untouched, no new patterns, no backend, no "last seen" state.Verification
bun run typecheck— cleanbun run lint— 0 errors (pre-existing warnings only)bun run test— 37 pass / 0 failbun run build— successasync-await-order; the next 15 days cover all 15 patterns uniquely; consecutive days differ deterministically.