Repository navigation
Finish a workout the app was recording when it was closed - #80
Merged
Merged
Conversation
A workout in progress when the process died (an update install, Android reclaiming memory, a crash) stayed "recording" in the database forever: nothing persisted the live workout but its samples, ActivitySessionDao.active() had no caller, and the Activity tab lists finished workouts only, so it never appeared. WorkoutRecovery runs when the workout manager comes up: each workout still marked active that started before then is closed at its own last live heart-rate sample or GPS point (before a 10-minute silence, at most 6 h), recomputed and credited like a normal finish. A paused one ends where it was paused; one with nothing recorded is cancelled rather than given an invented duration. A workout started while this runs is never touched. Claude-Session: https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w
If the summary failed, finish() threw before the session was saved, leaving it "recording" for good. It is now saved as finished first; the summary and the day's credit can't take it down with them. Claude-Session: https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w
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.
The owner started workouts with Record in PulseLoop (confirmed), and they never showed up on the Activity tab. Workouts recorded by Google Health did show up, because they come in through Health Connect, a separate path.
Cause
If the app's process ends during a workout, that workout stays "recording" in the database forever. The process can end because an update is installed, Android reclaims memory, or the app crashes. Three things combine:
ActivitySessionDao.active()has no caller, so nothing ever looks for a workout left running.So the workout never appears, and nothing ever finishes it. Today alone had four release installs, and each install ends any workout in progress.
There is a second way to get stuck in the same state.
finish()saved the workout only after recomputing its summary. If that recompute failed, the workout stayed "recording".Fix
WorkoutRecoveryruns when the workout manager starts. It finds each workout still marked as running that started before that moment, and closes it:finish()now saves the workout as finished before computing its summary. If the summary or the day's credit fails, the workout still appears.WorkoutRecoveryTestcovers these cases: a quiet stretch, no evidence, a paused workout, the 6-hour cap, and "now".The diagnostics export the owner attached (11 Nov, v2.16.0) contains no workout data, since exports carry no database rows by design, so it could not confirm the cause either way.
No UI change, so there is no audit file and no canvas update.
🤖 Generated with Claude Code
https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w