Skip to content

feat: add deterministic 'today's gotcha' pick to the pattern library - #26

Merged
hoce1n merged 1 commit into
mainfrom
260810-feat-gotcha-of-the-day
Aug 10, 2026
Merged

hoce1n merged 1 commit into
mainfrom
260810-feat-gotcha-of-the-day

Conversation

@monkeycode-global

Copy link
Copy Markdown
Contributor

Highlights one entry from the existing INTERVIEW_PATTERNS list 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). No Math.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 (focused prop → 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.
  • PatternRow fix: the row <section> was missing the pattern-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

  • Only surfaces existing patterns — INTERVIEW_PATTERNS is untouched, no new patterns, no backend, no "last seen" state.

Verification

  • bun run typecheck — clean
  • bun run lint — 0 errors (pre-existing warnings only)
  • bun run test — 37 pass / 0 fail
  • bun run build — success
  • Mocked-date checks (script, not waiting for real days): pick stable across same-day times; today → async-await-order; the next 15 days cover all 15 patterns uniquely; consecutive days differ deterministically.
  • Headless-browser check: the "Today's gotcha" card appears after mount, its title is stable across a full reload, and clicking it expands the target row and scrolls it into view.

- 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>
@vercel

vercel Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
runtimejs Ready Ready Preview Aug 10, 2026 1:37pm

@hoce1n
hoce1n merged commit 6600d90 into main Aug 10, 2026
3 checks passed
@hoce1n
hoce1n deleted the 260810-feat-gotcha-of-the-day branch August 10, 2026 13:39

This branch was successfully deployed

1 active deployment
Preview — b1f2c91a Deployed Aug 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants