Skip to content

feat: add recently viewed models with localStorage persistence#81

Open
samalbishnupriya06-stack wants to merge 1 commit into
AditthyaSS:mainfrom
samalbishnupriya06-stack:feat/recently-viewed
Open

feat: add recently viewed models with localStorage persistence#81
samalbishnupriya06-stack wants to merge 1 commit into
AditthyaSS:mainfrom
samalbishnupriya06-stack:feat/recently-viewed

Conversation

@samalbishnupriya06-stack

Copy link
Copy Markdown

Description

Implements the "Recently Viewed" feature — a pure client-side history tracker that saves the last 5 visited model pages to localStorage and displays mini-card links on the models directory and model detail pages.

Closes #52


Changes Made

New Files

  • src/hooks/useRecentlyViewed.ts — custom hook to read/write recently viewed models in localStorage
  • src/components/models/TrackModelView.tsx — headless client component that calls addModel() on mount
  • src/components/models/RecentlyViewed.tsx — displays mini-cards linking back to recently viewed models

Modified Files

  • src/app/models/[slug]/page.tsx — renders <TrackModelView> to record the visit and <RecentlyViewed> at the bottom
  • src/app/models/page.tsx — renders <RecentlyViewed> at the bottom of the directory listing

Behavior

  • Visiting any /models/[slug] page appends that model (slug, name, avatar) to a localStorage array
  • Duplicate entries are removed before prepending — no repeated models
  • History is capped at 5 items
  • The RecentlyViewed component only renders after useEffect (client-side), preventing Next.js hydration mismatch errors
  • If history is empty, the section renders nothing (null)

Type of Change

  • Bug fix
  • New feature (non-breaking)
  • Breaking change
  • Documentation update

Checklist

  • No API routes or Supabase changes introduced
  • Component only renders on the client (hydration-safe)
  • Duplicate models are prevented in the history array
  • History is capped at 5 items
  • npm run build passes without errors
  • Tested locally in both light and dark mode
  • Tested with fresh localStorage (no prior history) — section is hidden
  • Tested with 6+ visited models — confirms max 5 cap

@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

@samalbishnupriya06-stack is attempting to deploy a commit to the aditthyass' projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
ai-atlas Error Error Jun 7, 2026 6:12pm

@AditthyaSS

Copy link
Copy Markdown
Owner

@samalbishnupriya06-stack Touched package-lock.json plz revert it

@samalbishnupriya06-stack

Copy link
Copy Markdown
Author

@samalbishnupriya06-stack Touched package-lock.json plz revert it

Okh doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add "Recently Viewed" Models History using LocalStorage

2 participants