Skip to content

feat(pomodoro): add live Pomodoro timer with Firestore session history#278

Open
aayushprsingh wants to merge 1 commit into
indresh404:mainfrom
aayushprsingh:gssoc-fix-212
Open

feat(pomodoro): add live Pomodoro timer with Firestore session history#278
aayushprsingh wants to merge 1 commit into
indresh404:mainfrom
aayushprsingh:gssoc-fix-212

Conversation

@aayushprsingh
Copy link
Copy Markdown
Contributor

Summary

Implements live Pomodoro Focus Session History with Firestore logging, addressing #212.

Changes

src/pages/CodingOwl.jsx

New: Live Pomodoro Timer

  • Functional 25-minute countdown timer with circular SVG progress ring
  • Start / Pause / Reset controls — timer fires a callback on completion
  • On session completion: auto-saves to Firestore focusSessions collection:
    • uid — linked to the authenticated Firebase user
    • durationMinutes — always 25 (Pomodoro default)
    • completedAt — Firestore serverTimestamp()

New: usePomodoroHistory Hook

  • Reads all completed sessions for the current user from Firestore, ordered by completedAt desc
  • Exposes totalHours, totalSessions, saveSession(), loading

New: Aggregate Stats Cards

  • Total Hours Focused
  • Sessions Completed
  • Average Session Length

New: Session History Log

  • Displays last 10 sessions with human-readable date and duration badge
  • Graceful empty state when no sessions exist
  • "Sign in" prompt when user is unauthenticated
  • "Firestore not configured" message in unconfigured environments

Firestore Collection

focusSessions/{docId}
  uid: string           // Firebase Auth UID
  durationMinutes: 25   // session length
  completedAt: Timestamp // server timestamp

Testing

  1. Sign in with GitHub on RankerHub
  2. Navigate to CodingOwl → start a 25-minute Pomodoro session (or speed-test with a short session)
  3. On completion, verify the session appears in the history log
  4. Verify aggregate stats update (Total Hours, Sessions)
  5. Open Firestore console → focusSessions collection → confirm documents created

Fixes #212

@aayushprsingh aayushprsingh requested a review from indresh404 as a code owner June 4, 2026 00:24
Copilot AI review requested due to automatic review settings June 4, 2026 00:24
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

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

Project Deployment Actions Updated (UTC)
ranker-hub Ready Ready Preview, Comment Jun 4, 2026 4:15pm

@github-actions github-actions Bot added backend Backend/Firebase related changes bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review labels Jun 4, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a live Pomodoro focus timer to the CodingOwl page, persisting completed sessions to Firestore and surfacing basic focus statistics and session history.

Changes:

  • Replaces the placeholder/“coming soon” content with a functional Pomodoro timer UI.
  • Introduces a Firestore-backed hook to save and fetch focus session history per user.
  • Adds focus stats (total hours, sessions completed, average session length) and a session history list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pages/CodingOwl.jsx
Comment on lines +75 to +93
useEffect(() => {
if (running) {
intervalRef.current = setInterval(() => {
setSecondsLeft((s) => {
if (s <= 1) {
clearInterval(intervalRef.current);
setRunning(false);
setCompleted(true);
onSessionComplete(25);
return 0;
}
return s - 1;
});
}, 1000);
} else {
clearInterval(intervalRef.current);
}
return () => clearInterval(intervalRef.current);
}, [running, onSessionComplete]);
Comment thread src/pages/CodingOwl.jsx
Comment on lines +79 to +85
if (s <= 1) {
clearInterval(intervalRef.current);
setRunning(false);
setCompleted(true);
onSessionComplete(25);
return 0;
}
Comment thread src/pages/CodingOwl.jsx
Comment on lines +154 to +158
{completed && (
<span className="text-xs font-bold text-emerald-600 dark:text-emerald-400 animate-pulse">
✅ Session saved to Firestore!
</span>
)}
Comment thread src/pages/CodingOwl.jsx
Comment on lines +27 to +33
const q = query(
collection(db, "focusSessions"),
where("uid", "==", userId),
orderBy("completedAt", "desc")
);
const snap = await getDocs(q);
setSessions(snap.docs.map((d) => ({ id: d.id, ...d.data() })));
Comment thread src/pages/CodingOwl.jsx
}

// --- Pomodoro Timer ---
const POMODORO_DURATION = 25 * 60; // 25 minutes in seconds
Comment thread src/pages/CodingOwl.jsx
clearInterval(intervalRef.current);
setRunning(false);
setCompleted(true);
onSessionComplete(25);
Comment thread src/pages/CodingOwl.jsx
Comment on lines +146 to +151
<button
onClick={reset}
className="p-2 rounded-xl font-bold border border-slate-200 dark:border-slate-800 text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 transition-colors"
>
<RotateCcw className="w-4 h-4" />
</button>
@indresh404
Copy link
Copy Markdown
Owner

Conflict

…h404#212)

- Replace disabled static timer with a live 25-minute Pomodoro countdown
- Circular progress ring with animated stroke transition
- Start/Pause/Reset controls with state management
- On completion: save session to Firestore 'focusSessions' collection (uid, durationMinutes, completedAt serverTimestamp)
- usePomodoroHistory hook: reads sessions from Firestore ordered by completedAt desc
- Aggregate stats cards: Total Hours Focused, Sessions Completed, Avg Session Length
- Session history log (last 10 sessions) with date and duration badges
- Graceful degradation when db is null (unconfigured) or user not signed in

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

Labels

backend Backend/Firebase related changes bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 level3 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Pomodoro Focus Session History & Firestore Logs

3 participants