Repository navigation
fix(workout): publish Idle on manual summary continue so SetReady can navigate (#1413) - #1414
Conversation
…n while a SetSummary is held (#1413) Manual "Next Set" on a held Set Summary (Set summary duration = Manual) was rejected with AUTHORITY_REJECTED on every tap once the raw live mirror flows (currentRoutineId / currentRoutineSessionId / _currentExerciseIndex / _currentSetIndex) drifted silently during the hold, freezing the workout on the summary. The same check had passed when the completion job installed the rest plan at set-completion time. The duplicated raw-coordinate conjuncts at the four rest-transition authority gates are replaced by liveRoutinePositionMatchesSource: while a SetSummary is still displayed the position is anchored on the loaded routine and the last explicitly entered RoutineFlowState.SetReady coordinates (written atomically with the index flows by every legitimate transition); in every other state the raw mirrors stay fully authoritative, preserving #1398's PostWriteDrift rest-control revalidation contract exactly. Instrumentation: connection-log diagnostics name the rejecting conjunct and the drifting mirror (privacy-safe; index values only). Tests: Issue1413ManualSummaryDelayedContinueTest — delayed-tap contract, 4 drift regressions (RED pre-fix / GREEN post-fix, sabotage-verified), and a stale-completion guard test proving a genuine successor transition still rejects the superseded completion.
…ry-continue-authority
… navigate (#1413) With Set summary duration = Manual, the explicit 'Next Set' continue runs the successor through startNextSetOrExerciseFor, which advances the set/exercise indexes and enters SetReady via startWorkoutOrSetReady(autoplay=false) but never publishes WorkoutState.Idle. ActiveWorkoutScreen only navigates to SetReady when workoutState leaves SetSummary/Resting/Active, so the summary card strands and every retry tap dies in hasCompletionRestAuthority (Rest transition install failed reason=AUTHORITY_REJECTED). Publish WorkoutState.Idle in both autoplay-off successor arms (distinct exercise without deferManualStart, and within-entry next set) after enterSetReady and applyPendingRestRackSelection, guarded by hasExpectedAuthority, mirroring the existing deferManualStart arm. The authority checks (hasCompletionRestAuthority / executionGuard) are untouched: superseded completions are still rejected. RED/GREEN: Issue1413ManualSummaryContinueIdleTest (4 tests) fails on main exactly on the live signature (stuck SetSummary, AUTHORITY_REJECTED on the retry tap) and passes with this fix. Issue1394ConsecutiveDuplicateAutoAdvance, Issue656Repro, DropSetRestTransition, DWSMRoutineFlow and Issue1360RestControlOutcome suites stay green; full unit gate green (6047 shared host + 26 androidApp tests). Fixes #1413
|
Reworked per the architecture review (issue comment on #1413). This PR has been reworked from the anchored-position authority relaxation to the approved
Net diff vs Verification: RED→GREEN on the recreation signature (stuck |
Problem
Fixes #1413.
With Profile → Set summary duration = Manual, the Set Summary holds as designed after a completed set, but every tap on its visible Next Set button is rejected app-side:
Rest transition install failed reason=AUTHORITY_REJECTEDper tap and the screen stays frozen (51 taps on the iPad simulator / Phantom provider = 1 silent successful tap + 50 rejections; evidence in the issue and the recreation packet).Root cause
The explicit continue installs the rest transition and runs the successor through
ActiveSessionEngine.startNextSetOrExerciseFor, which advances_currentExerciseIndex/_currentSetIndexand then enters SetReady viastartWorkoutOrSetReady(autoplay = false)— but never publishesWorkoutState.Idle.ActiveWorkoutScreenonly navigates to SetReady whenworkoutStateleaves SetSummary/Resting/Active, so the summary card strands on screen; every retry tap re-enters the rest-plan install with the completion identity frozen at the completed set and dies inhasCompletionRestAuthority(_currentSetIndexno longer matches the claimed identity), loggingreason=AUTHORITY_REJECTEDforever.The sibling
deferManualStartarm already publishes Idle afterenterSetReady+applyPendingRestRackSelection(Issue #572 / #1394 comment) — the two autoplay-off successor arms (distinct exercise withoutdeferManualStart, and within-entry next set) were missing that publication.Fix (reworked per the architecture review on the issue)
Publish
WorkoutState.Idlein both autoplay-off successor arms ofstartNextSetOrExerciseFor, afterenterSetReadyandapplyPendingRestRackSelection, guarded byhasExpectedAuthority(lease, …)— mirroring the existingdeferManualStartarm. Navigation-only: one shared-engine function, no schema/Supabase/portal/persistence/BLE change, and no authority relaxation —hasCompletionRestAuthorityandexecutionGuardare untouched, so superseded/stale completions are still rejected (pinned by a dedicated guard test).Tests
Issue1413ManualSummaryContinueIdleTest(new, 4 tests, commonTest, Kotlin/Native-safe names) — all driving the real production tap handler (DefaultWorkoutSessionManager.proceedFromSummary) withDWSMTestHarness:WorkoutState.Idle(not SetSummary),routineFlowState = SetReady(0, 1),_currentSetIndex = 1, and no unsolicited successor CONFIG before explicit Start.SetReady(1, 0)/_currentExerciseIndex = 1.Rest transition install failedlog entries across the first and any later taps.InitialRestPlanInstallResult.AuthorityRejected.RED → GREEN on the recreation's exact signature: on the pre-fix tree the two boundary tests fail (
Expected … WorkoutState.Idle, actual … WorkoutState$SetSummary) and the no-warning test fails (expected:<0> but was:<1>— the liveAUTHORITY_REJECTEDretry tap); with the fix all 4 pass. The guard test passes on both.Guard suites (arch-review binding):
Issue1394ConsecutiveDuplicateAutoAdvanceTest(27),Issue656ReproTest(2),DropSetRestTransitionTest(13),DWSMRoutineFlowTest(58),Issue1360RestControlOutcomeTest(10 — thePostWriteDriftcontract is preserved) — all green.Full unit gate:
./gradlew -Pskip.supabase.check=true :shared:testAndroidHostTest :androidApp:testDebugUnitTest :androidApp:testReleaseDexTypes --continue— BUILD SUCCESSFUL, 6047 shared host + 26 androidApp tests, 0 failures.Risk & scope
ActiveSessionEngine.kt(+16 lines) and one new test file. Navigation-only; no persistence, BLE, schema, Supabase or portal change.deferManualStartarms are unchanged. Manual summaries that already worked keep their exact behavior.Not merged by design: the merge gate is
phoenix-rca.