{'heading': 'How Practice History works in Ayurveda & Asana Yoga', 'summary': 'Tapping the `History` button in the top-right corner of the `Practices` tab opens `PracticeHistoryView`, which displays all guided sessions recorded for the active profile grouped by calendar date from newest to oldest. Each session card shows the practice artwork and dosha ring, title, modality (`MEDITATION`, `PRANAYAMA`, `RELAXATION`, etc.), exact `startedAt – endedAt` clock range, and the actual time spent in the player (`actualDuration`).', 'bullets': ['Honest duration logging: Even if you end a 15-minute session after 6 minutes and 20 seconds, `PracticeSession` records the real `startedAt`, `endedAt`, and `actualDuration` (`6 min 20 sec`).', 'Profile-isolated history: Each user profile maintains its own separate `PracticeSession` log (`session.profile?.id == profileID`).', 'Search across dates and durations: Global search inside `Practice History` matches title, kind, full or abbreviated date, start/end clock time, and formatted duration.', 'Zero streak penalties: The log is a calm chronological record with no punitive streak counters or badges.']}
Tapping the `History` button in the top-right corner of the `Practices` tab opens `PracticeHistoryView`, which displays all guided sessions recorded for the active profile grouped by calendar date from newest to oldest. Each session card shows the practice artwork and dosha ring, title, modality (`MEDITATION`, `PRANAYAMA`, `RELAXATION`, etc.), exact `startedAt – endedAt` clock range, and the actual time spent in the player (`actualDuration`).
Honest duration logging: Even if you end a 15-minute session after 6 minutes and 20 seconds, `PracticeSession` records the real `startedAt`, `endedAt`, and `actualDuration` (`6 min 20 sec`).
Profile-isolated history: Each user profile maintains its own separate `PracticeSession` log (`session.profile?.id == profileID`).
Search across dates and durations: Global search inside `Practice History` matches title, kind, full or abbreviated date, start/end clock time, and formatted duration.
Zero streak penalties: The log is a calm chronological record with no punitive streak counters or badges.
Opening Practice History and Reading Session Cards
In the `Practices` tab header, right next to the *"Practices — Meditation, breath and deep rest"* title, sits the pill-shaped `History` button (`clock.arrow.circlepath`). Tapping it opens `PracticeHistoryView` for the currently active profile. If you have not started any guided practices yet, the screen displays a clean empty state explaining: *"Practices you start will appear here with their start and end times."*
Once you have practiced, `groupedSessions` buckets your sessions by the start of each calendar day (`Calendar.current.startOfDay(for: $0.startedAt)`) and sorts both the date headers and the individual sessions within each day in reverse chronological order (newest first). Every session row displays the circular `PracticeThumbnailView` (including its Vata/Pitta/Kapha dosha ring), the practice title, the uppercase modality label (`practiceKind.uppercased()`), the clock range (`startedAt – endedAt`), and the formatted elapsed duration.
- Exact clock window: Shows when you began and finished (for example, `7:15 AM – 7:25 AM`), making it easy to see which time of day supports your most consistent practice.
- Granular duration formatting (`durationText`): Displays seconds when under a minute (`45 sec`), exact minutes when whole (`10 min`), or combined minutes and seconds (`6 min 20 sec`) when ended early.
- Catalog artwork fallback: `practice(for: session)` resolves the live `Practice` by `practiceID` or `practiceCatalogNumber` so the dosha ring and artwork always render accurately.
Why Recording Actual Duration Beats All-or-Nothing Streaks
Many wellness apps refuse to log a meditation or breath session unless you sit through 100% of the timer, or punish a missed day by resetting a streak counter to zero. That all-or-nothing design often discourages people from starting a practice when they only have four minutes before a meeting or when a toddler interrupts a 15-minute relaxation session.
In `Ayurveda & Asana Yoga`, `PracticeHistoryView` treats both completed sessions and early exits as valid practice records (`"Shows the history of completed and ended practices"`). Seeing that you practiced for 4 minutes and 30 seconds on a hectic Tuesday reinforces continuity and helps you choose a realistic target duration next time.
- Spot your real duration sweet spot: If your history shows you consistently end 20-minute morning sessions around minute 9, switch your default `Length` selection to 10 minutes.
- Observe time-of-day patterns: Compare your morning vs. evening timestamps to see when sessions run to completion most smoothly.
- Pair with dated Notes: Check the date and clock time in `Practice History` when writing an observation in the `Notes` tab (`New Node`).
Searching Your Practice History by Date, Kind, or Time
As your log grows over weeks and months, `visibleSessions` in `PracticeHistoryView` lets you filter your history using the global search bar without scrolling endlessly. Each `PracticeSession` is matched against seven formatted strings using `localizedStandardContains`.
You can type a practice name (such as `Nadi Shodhana` or `Yoga Nidra`), a modality kind (`pranayama`, `meditation`, `relaxation`, `kriya`, `visualisation`), a month or weekday name (`October`, `Sunday`), a clock time (`7:30`), or a duration (`10 min`) to isolate matching days immediately.
- Filter by modality: Type `pranayama` or `relaxation` to see how often you practiced breathwork vs. supine rest this month.
- Filter by weekday or month: Type `Monday` or `Oct` to review weekly consistency.
- Filter by duration: Type `15 min` or `5 min` to compare short resets against longer sessions.
Frequently Asked Questions
If two family members use different profiles in the app, is Practice History shared?
No. `PracticeHistoryView` filters `@Query` by `session.profile?.id == profileID`, so each profile sees only its own practice sessions.
Does ending a practice early still appear in Practice History?
Yes. The session is logged with its actual `startedAt` and `endedAt` timestamps and the exact `actualDuration` you practiced.
Can I search Practice History by the day of the week?
Yes. Because `visibleSessions` searches `session.startedAt.formatted(date: .complete, time: .shortened)`—which includes the full weekday name—typing `Tuesday` or `Saturday` filters the history to those days.





