Fix the visibility of the intro state #36
- The Cookie Store API is too new, it's not supported by some older browser versions yet
- Remove some redundant code
- Use a cookie for storing the showIntro state
Summary by CodeRabbit#
Refactor
- Tutorial intro visibility is now state-driven and persisted across sessions (cookie-backed); intro is no longer controlled via URL query.
- Intro component and route now consume a shared showIntro state/utility for consistent behavior.
Chores
- Lint configuration updated with an additional rule setting.
- 1
🚀 Preview Deployment#
Status: ✅ Ready!
Preview URL: Open Preview
Commit:
ea00aaab01c96da1258fc680fa66690201a866aeBuilt and deployed successfully
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/utils/getShowIntro.ts (1)
20-25: Consider extracting the max-age constant to avoid duplication.The 1-year max-age calculation is duplicated between server and client implementations.
🔎 Proposed refactor
const INTRO_COOKIE_NAME = "intro-visibility"; +const INTRO_COOKIE_MAX_AGE = 60 * 60 * 24 * 365; // 1 year const showIntroSchema = z.enum(["hidden", "visible"]).catch("visible");Then use
INTRO_COOKIE_MAX_AGEin both implementations. This follows the pattern used insidebar.tsxwithSIDEBAR_COOKIE_MAX_AGE.Also applies to: 36-41
src/components/HomeIntro.tsx (1)
76-81: Consider memoizing thegetShowIntro()call.getShowIntro()creates a newupdateShowIntrofunction reference on each render, causingstartTutorialto be recreated every time despiteuseCallback. This is unlikely to cause issues given the component's usage, but could be optimized.🔎 Proposed refactor
+import { useMemo } from "react"; // ... - const { updateShowIntro } = getShowIntro(); + const { updateShowIntro } = useMemo(() => getShowIntro(), []);Alternatively, since
updateShowIntrodoesn't depend on any reactive values, you could remove it from the dependency array and use an eslint-disable comment, though that's less idiomatic.📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 7fa9ca714c3f03bde2d10ae0931a01a559415eb6 and 6b6147949ac7fcf0141be6c7f718032746aba394.
📒 Files selected for processing (6)
biome.jsonsrc/components/HomeIntro.tsxsrc/routes/_tutorial._db.projects.tsxsrc/routes/_tutorial.tsxsrc/utils/getShowIntro.tssrc/utils/getTutorialDataHandlers.ts
💤 Files with no reviewable changes (2)
- src/routes/_tutorial._db.projects.tsx
- src/utils/getTutorialDataHandlers.ts
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Always ensure no formatting/linting issues exist in code - use
pnpm check --fixto automatically fix issuesFiles:
src/utils/getShowIntro.tssrc/components/HomeIntro.tsxsrc/routes/_tutorial.tsx
**/*.{tsx,ts}
📄 CodeRabbit inference engine (AGENTS.md)
Prefer functions over arrow functions for React components
Files:
src/utils/getShowIntro.tssrc/components/HomeIntro.tsxsrc/routes/_tutorial.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Prefer
typeoverinterfacefor type definitionsFiles:
src/utils/getShowIntro.tssrc/components/HomeIntro.tsxsrc/routes/_tutorial.tsx
🧠 Learnings (3)
📚 Learning: 2025-12-24T15:25:07.106Z
Learnt from: fulopkovacs Repo: fulopkovacs/trytanstackdb.com PR: 22 File: src/components/TodoBoards.tsx:63-81 Timestamp: 2025-12-24T15:25:07.106Z Learning: In Tailwind CSS v4, prefer canonical classes using bg-linear-to-* (e.g., bg-linear-to-b, bg-linear-to-t, bg-linear-to-r) over the older bg-gradient-to-* syntax. This aligns with Tailwind LSP's suggestCanonicalClasses rule. Apply across TSX files (e.g., src/components/*.tsx); replace occurrences of bg-gradient-to-* with the corresponding bg-linear-to-* equivalents and verify gradients visually.Applied to files:
src/components/HomeIntro.tsxsrc/routes/_tutorial.tsx
📚 Learning: 2025-12-28T23:34:13.416Z
Learnt from: fulopkovacs Repo: fulopkovacs/trytanstackdb.com PR: 32 File: src/components/HomeIntro.tsx:16-25 Timestamp: 2025-12-28T23:34:13.416Z Learning: In Motion (motion/react), when configuring variant transitions, use delayChildren: stagger(x) to create per-child delays (e.g., delayChildren: stagger(0.2)). This is different from the older API that used a separate staggerChildren property. Apply this guidance to TSX files that declare motion variants (e.g., in src/components/**/*.tsx) and verify that stagger is imported from framer-motion. Ensure transitions reflect the intended stagger timing and that no conflicting delay values override the staggered effect.Applied to files:
src/components/HomeIntro.tsxsrc/routes/_tutorial.tsx
📚 Learning: 2025-12-29T13:20:08.377Z
Learnt from: CR Repo: fulopkovacs/trytanstackdb.com PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-12-29T13:20:08.377Z Learning: Applies to src/route/__root.tsx : The root route is located at `src/route/__root.tsx` in this TanStack Start projectApplied to files:
src/routes/_tutorial.tsx
🧬 Code graph analysis (2)
src/utils/getShowIntro.ts (2)
src/utils/getTutorialDataHandlers.ts (2)
Promise(73-86)data(96-113)
src/components/ui/sidebar.tsx (1)
value(83-93)
src/components/HomeIntro.tsx (1)
src/utils/getShowIntro.ts (1)
getShowIntro(15-43)
🔇 Additional comments (5)
biome.json (1)
38-41: LGTM!Disabling
noDocumentCookieis appropriate given the PR's shift to cookie-based state management for intro visibility. This aligns with the existing pattern insidebar.tsxwhich also usesdocument.cookiedirectly.src/utils/getShowIntro.ts (1)
15-43: LGTM!The isomorphic implementation correctly separates server and client concerns. The use of
z.enum().catch()for schema validation with a safe fallback is a solid pattern.src/components/HomeIntro.tsx (1)
63-68: LGTM on the prop signature change.Changing from
intro: "true" | "false" | undefinedtoshowIntro: booleanis cleaner and aligns better with how the value is used in the component logic.src/routes/_tutorial.tsx (2)
16-23: LGTM!The loader correctly integrates
getShowIntro()alongside the existing tutorial data handler. Returning both values in the loader ensures the intro state is available server-side for SSR.
27-39: LGTM!The component cleanly consumes the loader data and converts
showIntroStateto a boolean forHomeIntro. This keeps the prop interface simple and the conversion logic centralized in the route.@@ -0,0 +1,6 @@1+import { createIsomorphicFn } from "@tanstack/react-start";2+import { getCookie, setCookie } from "@tanstack/react-start/server";3+import { z } from "zod";4+5+// NOTE: when we'll have different users -> respect the user's id6+const INTRO_COOKIE_NAME = "intro-visiblity";⚠️ Potential issue | 🟡 Minor
Typo in cookie name: "visiblity" should be "visibility".
This will work functionally but creates a misspelled cookie name that persists in users' browsers.
🔎 Proposed fix
-const INTRO_COOKIE_NAME = "intro-visiblity"; +const INTRO_COOKIE_NAME = "intro-visibility";📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const INTRO_COOKIE_NAME = "intro-visibility";🤖 Prompt for AI Agents
In src/utils/getShowIntro.ts around line 6 the INTRO_COOKIE_NAME constant is misspelled as "intro-visiblity"; change it to the correct "intro-visibility". Update any references in this file (and across the codebase) to use the new constant, and add backwards-compatibility: when reading the cookie, fall back to the old "intro-visiblity" value if present and then rewrite it to "intro-visibility" so existing users are migrated to the corrected name.✅ Confirmed as addressed by @fulopkovacs
fixed it
@fulopkovacs, thank you for fixing the typo! 🎉
fuko merged this897d672
fuko closed this
Sign in to join this conversation.
Walkthrough#
Refactors tutorial intro state from a query-parameter string to a cookie-backed, isomorphic state. Adds
getShowIntroutility, updates route loaders and HomeIntro props to use a booleanshowIntro, and adjusts a linter rule inbiome.json.Changes#
biome.jsonnoDocumentCookie: "off"underlinter.suspicious.src/components/HomeIntro.tsxHomeIntroprop changed from `intro: "true"src/routes/_tutorial._db.projects.tsxloaderproperty; route now only includescomponentandssr: false.src/routes/_tutorial.tsxintrofrom search validation; integratedgetShowIntroin loader and return value;HomeIntronow receivesshowIntroboolean derived fromshowIntroState.src/utils/getShowIntro.tsgetShowIntro()exposing{ showIntroState, updateShowIntro }; server reads/writes cookie viagetCookie/setCookie(1 year), client reads/writesdocument.cookie; zod schema enforces `"hidden"src/utils/getTutorialDataHandlers.tsSequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs#
HomeIntrois rendered insrc/routes/_tutorial.tsxand intro/showIntro prop wiring.HomeIntroprop signature and usages across the tutorial route.HomeIntrousage; overlaps in intent and impacted files.Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 6b6147949ac7fcf0141be6c7f718032746aba394 and ea00aaab01c96da1258fc680fa66690201a866ae.
📒 Files selected for processing (2)
src/components/HomeIntro.tsxsrc/utils/getShowIntro.ts🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/utils/getShowIntro.ts**/*.{tsx,ts}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/utils/getShowIntro.ts**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/utils/getShowIntro.ts🔇 Additional comments (2)
Comment `@coderabbitai help` to get the list of available commands and usage tips.