workout: stop auto-completing the day when sets are ticked (KC-52 follow-up 3)
Some checks failed
CI / build-and-test (push) Has been cancelled

Real bug, not cosmetic: setAllSetsDone/toggleSet/setExerciseDone still
auto-called logWorkoutCompleted() whenever doneSets == totalSets — leftover
pre-redesign behavior that fought the new completion card. Ticking the last
box (or tapping 'Check all sets') silently counted the day and snapped the UI
to the green 'done' takeover without the user ever hitting Finish.

Removed the auto-log from all three set-mutation methods. Only the card's
explicit Finish Workout/Finish Anyway (-> markWorkoutDone) now counts a day as
done. Check all sets just checks boxes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
kutesir
2026-07-08 13:54:13 +03:00
parent 5b3d4e5f9e
commit 017937bbff
2 changed files with 30 additions and 5 deletions

View File

@@ -1739,3 +1739,25 @@ on all these to avoid accidentals."
just 100%) now also confirms before executing — previously instant/silent. just 100%) now also confirms before executing — previously instant/silent.
Files: `WorkoutView.swift`. Files: `WorkoutView.swift`.
### KC-52 — follow-up 3: Check/Clear all no longer auto-jumps to "done" (real bug)
User: "when you check all or clear all it shouldnt load the screen shot [the
green 'Workout logged' card]. just show the workout widget."
### Root cause
Not a display bug — `setAllSetsDone(true)` ("Check all sets"), `toggleSet`, and
`setExerciseDone` all still auto-called `logWorkoutCompleted()` the instant
every set hit done (`doneSets == totalSets`). That's pre-redesign behavior that
now directly fights KC-52: the whole point of the new card was to make "Finish"
a single, deliberate, confirmable action — but ticking the last checkbox (or
tapping "Check all sets") silently counted the day anyway, snapping the card
straight to the green done takeover the user never asked for.
### Fix
Removed the auto-`logWorkoutCompleted()` call from all three sites
(`toggleSet`, `setExerciseDone`, `setAllSetsDone`). Checking sets — by any
path — now only ever updates progress; **only** the card's explicit "Finish
Workout"/"Finish Anyway" (→ `markWorkoutDone`) counts the day as done. "Check
all sets" now does exactly what it says: checks the boxes, nothing more.
Files: `ExerciseModels.swift`.

View File

@@ -818,7 +818,9 @@ class WorkoutViewModel: ObservableObject {
sessionStartDate = Date() sessionStartDate = Date()
} }
syncBack() syncBack()
if doneSets == totalSets && totalSets > 0 { logWorkoutCompleted() } // Ticking the last box no longer silently logs the day as done the
// main Workout card's explicit "Finish" is the single, confirmable way
// to count today (so mis-taps here can't jump the UI into the done state).
if wasMarkedDone && restTimerEnabled { startRestTimer() } if wasMarkedDone && restTimerEnabled { startRestTimer() }
} }
@@ -832,11 +834,13 @@ class WorkoutViewModel: ObservableObject {
} }
if done, sessionStartDate == nil { sessionStartDate = Date() } if done, sessionStartDate == nil { sessionStartDate = Date() }
syncBack() syncBack()
if doneSets == totalSets && totalSets > 0 { logWorkoutCompleted() } // See toggleSet: no longer auto-logs the day "Finish" is explicit.
} }
/// Mark every set of the active workout done/undone the "Select all & mark /// Mark every set of the active workout done/undone the "Check/Clear all
/// complete" quick action. Logs completion when everything is checked. /// sets" quick action. Ticking every box no longer auto-logs the day as
/// done on its own; "Finish Workout" on the main card is the single,
/// confirmable action that counts today.
func setAllSetsDone(_ done: Bool) { func setAllSetsDone(_ done: Bool) {
for si in activeSections.indices { for si in activeSections.indices {
for ei in activeSections[si].exercises.indices { for ei in activeSections[si].exercises.indices {
@@ -850,7 +854,6 @@ class WorkoutViewModel: ObservableObject {
UserDefaults.kisani.set(iso.string(from: Date()), forKey: kLastActiveDay) UserDefaults.kisani.set(iso.string(from: Date()), forKey: kLastActiveDay)
} }
syncBack() syncBack()
if done, doneSets == totalSets && totalSets > 0 { logWorkoutCompleted() }
} }
func addSet(sectionId: UUID, to exerciseId: UUID) { func addSet(sectionId: UUID, to exerciseId: UUID) {