Skip to content

Fix timer ignoring workout repetitions - #46

Open
Maria1-eng wants to merge 1 commit into
mainfrom
fix/timer-repetitions
Open

Fix timer ignoring workout repetitions#46
Maria1-eng wants to merge 1 commit into
mainfrom
fix/timer-repetitions

Conversation

@Maria1-eng

Copy link
Copy Markdown
Collaborator

Summary

  • El campo repetitions de Workout no se leía en el timer
  • Al terminar el último intervalo el cronómetro paraba en lugar de reiniciar los intervalos N veces
  • También avanza al siguiente workout al terminar las repeticiones del actual

Test plan

  • Workout con repetitions > 1: verificar que los intervalos se repiten N veces
  • Workout con repetitions = 1: verificar que el comportamiento no cambió
  • Múltiples workouts: verificar que el timer avanza al siguiente al terminar las repeticiones del primero

🤖 Generated with Claude Code

@Maria1-eng
Maria1-eng requested a review from Tyler-Lopez April 24, 2026 19:27
@Tyler-Lopez

Copy link
Copy Markdown
Owner

Nice! :) Could you rebase with main? See how there are two commits? That is what was throwing me for a loop last night.

I think the problem here is you already merged the "Following interval" commit, which wasn't authored with Claude, but then you did this without it being rebased with the new merged commit. So this branch you are on doesn't know that main already has this commit.

Just a quick rebase of this branch with main should fix it. 🔥

The `repetitions` field on `Workout` was never read by the timer. After the
last interval finished its rest phase the timer stopped instead of restarting
the interval sequence for the remaining repetitions. Also advances to the next
workout once all repetitions for the current one are complete.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@Maria1-eng
Maria1-eng force-pushed the fix/timer-repetitions branch from da153b2 to 52eb690 Compare April 24, 2026 20:23
@Maria1-eng
Maria1-eng marked this pull request as ready for review April 24, 2026 20:29
}
!isLastWorkout -> {
currentWorkoutRepetitionIndex = 0
currentWorkoutIndex++

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This PR actually does something besides fixing repetitions 😮

So you see that right? It noticed that we also were ignoring the fact that we only were iterating over just one Workout, when we could have a whole list of Workout.

That is why this PR has so many lines change, it also includes that.

Could we rename this PR and commit something like Fix timer ignoring multiple workouts and repetitions?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We were initially focusing on a single workout because each workout already contains multiple intervals and exercises. My intention was that users could select which workout they want to run, which is why I was considering adding a database to manage multiple workouts. What do you think?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

So we will make it so instead of incrementing workouts, you always just "play" one workout at a time, right? Never more than one workout at a time.

Then, because in the future, you will save workouts in a database, it'll be really easy to finish one workout and start another?

I think that makes a lot of sense, and I bet if you fed these instructions into Claude it could kind of put some things together.

One thing is that this would kind of be a big refactor because it probably eliminates the need to have the whole "Build Workout" screen.

That said, I think if you want to merge this as-is it is fine, or you could remove (or tell Claude to remove) the lines about incrementing the workout for now.

Comment on lines +170 to +175
val hasFinishedCurrentWorkoutCycle = isResting && currentIntervalIsLastInWorkout

if (hasFinishedCurrentWorkoutCycle) {
val totalRepetitions = currentWorkout?.repetitions ?: 1
val hasMoreRepetitions = currentWorkoutRepetitionIndex < totalRepetitions - 1
val isLastWorkout = currentWorkoutIndex == workouts.lastIndex

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Do all these names make sense to you? It got rid of hasFinishedAllWorkouts in favor of isLastWorkout, for example.

private val currentWorkoutInterval: Interval?
get() = currentWorkout?.intervals?.getOrNull(index = currentWorkoutIntervalIndex)

/** Tracks how many times the current workout's intervals have been repeated (0-based). */

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
/** Tracks how many times the current workout's intervals have been repeated (0-based). */
/** The index of the current repetition of the [currentWorkoutInterval] */

This is just a nit, but I would change the comment to be like this to be more in line with the others.

@Tyler-Lopez Tyler-Lopez left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice work getting this all working! :) 🔥

Just some small things for you to consider. I would just take a pass through yourself and make sure all of this makes sense. It does look good, it's just that it also included the separate fix to workouts not incrementing too.

Feel free to merge when you want :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants