Skip to content

feat: add mock interview history and analytics dashboard#862

Open
Kr1491 wants to merge 4 commits into
durdana3105:mainfrom
Kr1491:feat/mock-interview-history
Open

feat: add mock interview history and analytics dashboard#862
Kr1491 wants to merge 4 commits into
durdana3105:mainfrom
Kr1491:feat/mock-interview-history

Conversation

@Kr1491

@Kr1491 Kr1491 commented Jun 7, 2026

Copy link
Copy Markdown

🚀 Feature: Mock Interview History & Analytics Dashboard

Closes #839

📋 Changes Made

New Files

  • supabase/migrations/20260608000000_interview_sessions.sql — creates the interview_sessions table with RLS policies (users can only read/insert/delete their own sessions)
  • src/pages/InterviewHistory.tsx — new page showing past interview sessions with score progression chart and expandable session details

Modified Files

  • src/pages/MockInterview.tsx — saves completed interview session (role, messages, strengths, improvements, score, summary) to the database after report generation. Added "View History" button on the report screen
  • src/App.tsx — added lazy import and /interview-history protected route

✨ What This Feature Does

  • Every completed mock interview is now persisted to the database
  • Users can navigate to /interview-history to view all past sessions
  • A line chart shows score progression across sessions over time
  • Each session card is expandable to view full report (strengths + improvement areas)
  • Empty state handled — shows CTA to start first interview if no sessions exist
  • Route is protected — unauthenticated users are redirected to login

🗃️ Database

New table interview_sessions:

Column Type Description
id uuid Primary key
user_id uuid References profiles(id)
role text Interview role selected
messages jsonb Full conversation history
strengths text[] Strengths from report
improvements text[] Improvement areas from report
overall_score integer Score out of 100
summary text Overall summary
created_at timestamptz Timestamp

RLS is enabled — users can only access their own sessions.

📝 Notes

  • Used supabase as any for the new table queries since types.ts will need to be regenerated after the migration runs (supabase gen types typescript)
  • Full E2E testing requires the complete project database setup with all existing migrations

🎯 Program

GSSoC26

Summary by CodeRabbit

  • New Features

    • Interview History page: view past interviews with score progression chart, expandable session details (summary, strengths, improvements) and a computed "Recurring Improvement Areas" section.
    • Post-interview flow now saves sessions automatically and adds a "View History" path from the finished screen.
  • Bug Fixes / UX

    • Save failures show a toast; history load errors show an inline message with a “Try Again” retry action.
    • Finished-state action buttons have improved spacing and a lightweight loading fallback while history loads.

@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the durdana3105's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 09e1eaf9-dc05-4aea-925f-c23734f7ccb6

📥 Commits

Reviewing files that changed from the base of the PR and between 97fbf06 and 8d6cca1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • src/App.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/App.tsx

📝 Walkthrough

Walkthrough

Creates interview_sessions table with RLS, persists completed interviews from MockInterview to that table, adds a lazy-loaded protected /interview-history route, and introduces an InterviewHistory page that fetches sessions, shows a score progression chart, recurring improvement areas, and expandable session details with error handling.

Changes

Interview History & Analytics

Layer / File(s) Summary
Interview sessions schema and RLS policies
supabase/migrations/20260608000000_interview_sessions.sql
New interview_sessions table with id UUID, user_id FK, role, messages JSONB, strengths/improvements text[], overall_score constrained 0–100, summary, and created_at. Row-level security enabled with SELECT, INSERT, DELETE policies limiting access to the owning user.
Session persistence in MockInterview
src/pages/MockInterview.tsx
After report generation, constructs and inserts an interview_sessions row (user id, role, messages, strengths, improvements, overall_score, summary) via Supabase integrations client, logs/toasts on insert failure, adds useNavigate, and updates "View History" to navigate to /interview-history with adjusted spacing.
InterviewHistory page with chart and expandable sessions
src/pages/InterviewHistory.tsx
New page imports Recharts and UI icons, defines Session type, fetches user's sessions with loading/error states, computes recurringImprovements, derives chartData for a LineChart, conditionally renders loading/error/empty states, shows score progression chart, lists top recurring improvements, and displays a reverse-ordered expandable session list revealing summary, strengths, and improvements.
Route registration and code splitting
src/App.tsx
Declares InterviewHistory with React.lazy and adds a /interview-history route wrapped in ProtectedRoute and WithNav, rendering the page inside an inner Suspense boundary with a minimal fallback.

Sequence Diagram

sequenceDiagram
  participant User
  participant MockInterview
  participant Supabase
  participant InterviewHistory
  
  User->>MockInterview: Complete interview
  MockInterview->>Supabase: INSERT interview_sessions
  Supabase-->>MockInterview: Session persisted / error
  MockInterview-->>User: Display report + "View History"
  User->>InterviewHistory: Navigate /interview-history
  InterviewHistory->>Supabase: SELECT user's sessions
  Supabase-->>InterviewHistory: Sessions retrieved
  InterviewHistory-->>User: Render score chart + session list
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

  • durdana3105/peer-learning#790: Modifies src/pages/MockInterview.tsx Supabase client/auth handling that intersects with this PR's persistence logic.

Poem

🐰 I dug a little tunnel through code,

Saved each session like carrots stowed.
Charts that hop up, progress in sight,
Recurring tips to practice each night.
Hooray — your interviews take flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add mock interview history and analytics dashboard' directly summarizes the main changes: adding a history page and analytics/score tracking for mock interviews.
Linked Issues check ✅ Passed All coding requirements from #839 are met: interview sessions are persisted after completion, /interview-history page displays sessions with expandable details, score progression chart is implemented, and route protection is in place.
Out of Scope Changes check ✅ Passed All changes are directly aligned with #839 requirements: database migration, interview persistence, history page, and route additions. No unrelated or out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/InterviewHistory.tsx`:
- Around line 79-159: The page is missing aggregation of recurring improvement
areas across sessions; add logic to compute and display recurring improvements
by scanning the sessions array (the same data used for chartData and session
list), e.g., implement a helper (computeRecurringImprovements or
deriveRecurringImprovements) that flattens session.improvements, counts
frequencies, sorts by count, and returns top N items, then render a new UI block
(e.g., a "Recurring Improvements" card) under the Score Chart using that helper;
reference the existing sessions variable and ensure you reuse or memoize the
result (useMemo or equivalent) so it updates when sessions change and ties into
expandedId/session rendering flow.
- Around line 27-35: fetchSessions currently treats Supabase errors as an empty
result by only calling setSessions when "!error && data" and then always calling
setLoading(false); change fetchSessions to explicitly handle errors: detect when
"error" is truthy, set an error state (e.g., setFetchError or reuse existing
state), do not clear sessions to an empty array in that case, and ensure the
component renders a failure message instead of the empty-state; update the
fetchSessions flow around the Supabase call and the setLoading/setSessions calls
so successful responses call setSessions(data) and clear any error, while
failures set the error state and setLoading(false) without overwriting existing
sessions.

In `@src/pages/MockInterview.tsx`:
- Around line 140-148: The Supabase insert call using (supabase as
any).from("interview_sessions").insert(...) is not checking the returned { error
} so failures are silent; update the code after this insert to inspect the
returned result (error) and handle it explicitly—either throw the error so the
outer try/catch handles it or set an error state and avoid calling
setReport(data) (or revert it) when insert fails; reference the insert call and
the setReport(data) usage in MockInterview.tsx and ensure the error path
surfaces a user-visible failure/rollback and logs the Supabase error details.

In `@supabase/migrations/20260608000000_interview_sessions.sql`:
- Around line 8-10: The migration must enforce analytics invariants: update the
interview_sessions column definitions so overall_score has a CHECK enforcing
0–100 (e.g., add "CHECK (overall_score BETWEEN 0 AND 100)") and make created_at
NOT NULL with a default now() so timestamps are always present; modify the
CREATE TABLE/column lines for overall_score and created_at (or add equivalent
ALTER TABLE constraints) to implement these checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2984f597-6dfb-48d8-bd8e-a0d5404813ea

📥 Commits

Reviewing files that changed from the base of the PR and between b11a714 and 4ab8a26.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • src/App.tsx
  • src/pages/InterviewHistory.tsx
  • src/pages/MockInterview.tsx
  • supabase/migrations/20260608000000_interview_sessions.sql

Comment thread src/pages/InterviewHistory.tsx
Comment thread src/pages/InterviewHistory.tsx
Comment thread src/pages/MockInterview.tsx Outdated
Comment thread supabase/migrations/20260608000000_interview_sessions.sql Outdated
@Kr1491

Kr1491 commented Jun 8, 2026

Copy link
Copy Markdown
Author

Hi @durdana3105, could you please review this PR? I've addressed all the issues and suggestions raised by CodeRabbit. Thank you!

@durdana3105

Copy link
Copy Markdown
Owner

this have merge conflicts

@Kr1491

Kr1491 commented Jun 9, 2026

Copy link
Copy Markdown
Author

Heyy @durdana3105
I've addressed all the CodeRabbit review comments and resolved the merge conflict in package-lock.json. The PR is ready for your review!

Just a note — the 2 failing checks (CI test and Vercel) are pre-existing infrastructure issues unrelated to this PR:

  • The CI test is failing due to missing OPENROUTER_API_KEY in the CI environment (in chatRoutes.js which I haven't touched)
  • Vercel deployment requires authorization from your end

Would love to get your feedback whenever you get a chance. Thank you! 🙏

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] Mock Interview History & Analytics Dashboard

2 participants