Skip to content

End the exercise after the last exhale, not on the timer - #134

Merged
mmazzarolo merged 1 commit into
masterfrom
claude/exercise-ending-timing-4e7a11
Aug 2, 2026
Merged

End the exercise after the last exhale, not on the timer#134
mmazzarolo merged 1 commit into
masterfrom
claude/exercise-ending-timing-4e7a11

Conversation

@mmazzarolo

@mmazzarolo mmazzarolo commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Problem

The time limit stopped the exercise in the middle of a step. The exercise could stop during an inhale or during a hold, thus the "Complete" screen appeared while the user still held a full breath.

Change

The time limit no longer stops the exercise. It only arms the completion. The exercise then continues to the end of the first step that leaves the lungs empty — the exhale, or the hold that follows the exhale. The rule is getExerciseStepTransition in exercise-session.ts, a pure function.

The extra time is never more than one inhale, one hold and one exhale:

Pattern Steps Maximum extra time
Awake 6-0-2-0 8 s
Square 4-4-4-4 12 s
Ujjayi 7-0-7-0 14 s
Deep Calm 4-7-8-0 19 s
Pranayama 7-4-8-4 19 s

Other effects:

  • The timer fades away when it shows 00:00. It does not stay frozen for the last breath. While it is invisible it also leaves the accessibility tree.
  • The guided voice and the vibration do not cue the step that follows the last exhale. The completion bell plays after the breath, not in the middle of a step.
  • StepMetadata.id is a union type instead of string, thus a wrong step name is now a compilation error.

The time limit stopped the exercise in the middle of a step. The exercise
could stop during an inhale or during a hold, thus the completion screen
appeared while the user still held a full breath.

The time limit now only arms the completion. The exercise continues to the
end of the first step that leaves the lungs empty: the exhale, or the hold
that follows it. The extra time is never more than one inhale, one hold and
one exhale (8 s for Awake, 12 s for Square, 19 s for Deep Calm and
Pranayama).

- The timer fades away at 00:00 instead of staying frozen for the last
  breath, and it leaves the accessibility tree while it is invisible.
- The voice and the vibration no longer cue the step that follows the last
  exhale, and the completion bell plays after the breath.
- `StepMetadata.id` is a union type, thus a wrong step name is now a
  compilation error.

Tests: 6 unit tests for the new step transition, and a Maestro flow that
sets the shortest time limit and waits for the exercise to end by itself.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mmazzarolo
mmazzarolo merged commit 825a742 into master Aug 2, 2026
1 check passed
@mmazzarolo
mmazzarolo deleted the claude/exercise-ending-timing-4e7a11 branch August 2, 2026 11:35
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.

1 participant