Restructure into a three-tab app with Progress, goals, and Meditation

The UX redesign's first landing (spec in UX-REDESIGN.md): ContentView
becomes a Today / Progress / Settings TabView, "Routine" replaces
"Split" in every user-facing string and view name (code-level types
keep their names), and workout starting moves to shared
WorkoutStarter / StartedWorkoutNavigator plumbing.

- New Progress tab: weekly goal streaks, workout trends, per-exercise
  weight progression, achievements, and the full history list
  (WorkoutLogsView -> WorkoutHistoryView).
- Goals: stable categories workouts roll up to, managed from Settings.
- New Meditation exercise + starter routine; timed sits record to
  Apple Health as Mind & Body sessions.

Claude-Session: https://claude.ai/code/session_012qw2itfzKyEJ1HpsFt8Ex4
This commit is contained in:
2026-07-11 07:53:01 -04:00
parent 5c201289fb
commit 6e440317c4
97 changed files with 5354 additions and 1291 deletions
@@ -11,7 +11,7 @@ import SwiftData
/// Root of the watch app. The watch only runs the workouts that are currently
/// active on the phone there's no history browsing here. An "active" workout is a
/// cached one that isn't finished (`notStarted` or `inProgress`); a workout is
/// created on the phone as `notStarted` the moment a split is picked, and flips to
/// created on the phone as `notStarted` the moment a routine is picked, and flips to
/// `completed` once every exercise is done, at which point it drops off this list.
///
/// The root shows every active workout (most-recent first); picking one opens its
@@ -20,7 +20,7 @@ struct ActiveWorkoutGateView: View {
@Environment(WatchConnectivityBridge.self) private var bridge
@Query(sort: \Workout.start, order: .reverse) private var workouts: [Workout]
@Query private var splits: [Split]
@Query private var routines: [Routine]
/// Navigated workouts (depth 1). Held here rather than relying on implicit
/// `NavigationLink` destinations so we can pop back to the gate the moment the phone
@@ -31,17 +31,17 @@ struct ActiveWorkoutGateView: View {
workouts.filter { $0.status == .inProgress || $0.status == .notStarted }
}
private func split(for workout: Workout) -> Split? {
guard let id = workout.splitID else { return nil }
return splits.first { $0.id == id }
private func routine(for workout: Workout) -> Routine? {
guard let id = workout.routineID else { return nil }
return routines.first { $0.id == id }
}
/// True while the phone has this workout's exercise or the split it came from open
/// True while the phone has this workout's exercise or the routine it came from open
/// in an editor. The watch parks such a run and blocks re-entry so the phone owns the
/// edit and the watch can't forward a stale optimistic write over it.
private func isLockedForEditing(_ workout: Workout) -> Bool {
if let id = bridge.editingWorkoutID, id == workout.id { return true }
if let splitID = bridge.editingSplitID, splitID == workout.splitID { return true }
if let routineID = bridge.editingRoutineID, routineID == workout.routineID { return true }
return false
}
@@ -89,17 +89,17 @@ struct ActiveWorkoutGateView: View {
// pop back to the gate so re-entry rebuilds a fresh working copy. Also pop if the run
// we're inside was pruned (discarded/deleted on the phone, or aged out of the push).
.onChange(of: bridge.editingWorkoutID) { _, _ in popIfNavigatedRunUnavailable() }
.onChange(of: bridge.editingSplitID) { _, _ in popIfNavigatedRunUnavailable() }
.onChange(of: bridge.editingRoutineID) { _, _ in popIfNavigatedRunUnavailable() }
.onChange(of: workouts.map(\.id)) { _, _ in popIfNavigatedRunUnavailable() }
}
@ViewBuilder
private func row(for workout: Workout) -> some View {
if isLockedForEditing(workout) {
ActiveWorkoutRow(workout: workout, split: split(for: workout), editingOnPhone: true)
ActiveWorkoutRow(workout: workout, routine: routine(for: workout), editingOnPhone: true)
} else {
NavigationLink(value: ActiveWorkoutRoute(workoutID: workout.id)) {
ActiveWorkoutRow(workout: workout, split: split(for: workout))
ActiveWorkoutRow(workout: workout, routine: routine(for: workout))
}
}
}
@@ -135,7 +135,7 @@ struct ActiveWorkoutGateView: View {
private struct ActiveWorkoutRow: View {
let workout: Workout
let split: Split?
let routine: Routine?
/// When true, the phone is editing this run render it dimmed and non-tappable.
var editingOnPhone: Bool = false
@@ -144,13 +144,13 @@ private struct ActiveWorkoutRow: View {
var body: some View {
HStack(spacing: 10) {
Image(systemName: editingOnPhone ? "pencil" : (split?.systemImage ?? "figure.strengthtraining.traditional"))
Image(systemName: editingOnPhone ? "pencil" : (routine?.systemImage ?? "figure.strengthtraining.traditional"))
.font(.title3)
.foregroundStyle(split.map { Color.color(from: $0.color) } ?? .workTint)
.foregroundStyle(routine.map { Color.color(from: $0.color) } ?? .workTint)
.frame(width: 26)
VStack(alignment: .leading, spacing: 2) {
Text(workout.splitName ?? Split.unnamed)
Text(workout.routineName ?? Routine.unnamed)
.font(.headline)
.lineLimit(1)