fix: guard against no-phase programs in timer screen#11
Open
fix: guard against no-phase programs in timer screen#11
Conversation
Root cause: when a program exists but has no phases yet,
`Program::totalDuration()` returns 0 (programTotalDuration = 0) and
`TimerRunner::start()` throws RuntimeException("Program has no phases.").
Livewire silently rolls back the response, so the UI never transitions
out of idle — the Start button appears to do nothing.
Changes:
- `TimerScreen::start()`: return early when phases are empty; avoids the
unhandled exception and leaves the idle state intact so the user can
still navigate to the editor.
- `timer-screen.blade.php`: replace the Start button with an amber
warning notice ("No phases — edit this program…") when `$phases` is
empty and state is idle, so the user immediately understands why the
timer cannot start.
- `ProgramEditor::totalDuration()`: add an empty-phases guard (returns 0)
and subtract the last phase's cooldown, matching `Program::totalDuration()`
which already skips it (the timer goes straight to COMPLETED after the
final rep, never entering the last cooldown).
https://claude.ai/code/session_01GWCpmWmmUb8R1EE23kC29k
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
When a program exists but has no phases yet:
Program::totalDuration()returns0→programTotalDuration = 0TimerRunner::start()throwsRuntimeException("Program has no phases.")— Livewire silently rolls back the response, so the UI never transitions out of idle and the Start button appears to do nothingThis happens when a user creates a program but navigates to the timer screen before adding any phases.
Changes
TimerScreen::start()— guard against empty phasesInstead of letting
TimerRunner::start()throw aRuntimeException(silently swallowed by Livewire),start()now returns early when phases are empty. State is left untouched so the blade can render the "no phases" notice.timer-screen.blade.php— no-phases noticeWhen the timer is idle and
$phasesis empty, the Start button is replaced with an amber warning:The Edit button in the secondary row remains visible so the user can fix the program immediately.
ProgramEditor::totalDuration()— match timer behaviourThe editor's preview summed every phase's cooldown, including the last phase. But the timer skips the last phase's cooldown (goes straight to
COMPLETEDafter the final rep). This made the preview total higher than the actual run duration for any program with a last-phase cooldown. Fixed to subtract the last phase's cooldown, matchingProgram::totalDuration().Test plan
https://claude.ai/code/session_01GWCpmWmmUb8R1EE23kC29k