Repository navigation
feat(garmin): watch button controls for workouts — Phase 1 MVP (#1391) - #1407
9thLevelSoftware wants to merge 18 commits into
Conversation
…1-B7 Pinned shared API: RemoteSetControlReceipt (B1 seam result), GarminCompanionTransport (B2 controller / B4-B6 platform transports), GarminControlPreferences (namespaced local store), GarminSessionController public UI surface (B2 impl / B3 phone UI).
B1: endCurrentSetAndPrepareNext seam in DefaultWorkoutSessionManager with ActiveSessionEngine cooperation and RemoteSetControlSeam typed receipts. B7: garmin/ Monkey C watch app (manifest, protocol, delegate, view, tests, static-check + simulator-test scripts) and .github/workflows/garmin-ci.yml. B8: regression/coexistence tests across Issue869SummaryAfterCommitTest, JustLiftCompletionBehaviorTest, ManualStopProfileAttributionTest, WorkoutTeardownRecoveryTest.
GarminControlsSettingsCard beside HrmSensorSettingsCard in SettingsTab, GarminControlsArmStrip integrated into SetReadyScreen/ActiveWorkoutScreen/ JustLiftScreen, additive string resources only.
Android CIQ companion transport + DI binding, iOS transport + GarminCompanionBridge.swift with dedicated callback scheme and -ObjC, tvOS no-op transport; version-catalog + build wiring.
…ssthrough Unblocks :shared:compileAndroidHostTest for the B1/B8 remote set-control tests.
GarminProtocol.kt: frozen v1 wire codec mirroring garmin/source/PhoenixProtocol.mc (HELLO/STATE/COMMAND/RESULT, bounded validation walk, codec-size estimator, fail-closed key sets). GarminSessionController: association/arming with fresh epochs, 3s grants + 10s confirmation binding, fail-closed dedupe (256/epoch, reserve-before-dispatch, cached identical duplicates, COMMAND_ID_CONFLICT, EPOCH_CAP_REACHED disarm/rekey), single serialized admission with urgent STOP_SET pre-emption, ACCEPTED/APPLIED/REJECTED receipt semantics with UNKNOWN_RESULT/SAVE_FAILED start-block, authority invalidation and owner- generation callback drops. DI: GarminControlPreferences + holder-based GarminSessionController binding; MainViewModel composes the controller against its single session manager (integration-model §5). DWSM gains a manager-level currentRemoteExecutionIdentityOrNull() accessor. Tests: GarminProtocolTest + GarminSessionControllerTest (fake monotonic clock, no sleeps).
- garmin Monkey C: Array.push() does not exist on Monkey C arrays — use .add() (fixes all four garmin-ci Build + simulator checks jobs: fenix7/fr255/fr265/fr965) - iOS KN export visibility: GARMIN_CALLBACK_URL_SCHEME/selection TTL stay internal; the deliberate Garmin companion-bridge Swift seam (GarminNativeBridge, GarminNativeBridgeEvents, GarminBridgeDeviceInfo, GarminCompanionBridgeRegistry) is allowlisted in IosKnExportVisibilityContractTest with rationale - KoinModuleVerifyTest: extraTypes += GarminCompanionTransport (platformModule) and DefaultWorkoutSessionManager (composed in MainViewModel, never a bean) - GarminControlsArmStrip/SettingsCard: best-effort controller resolution — environments without the Garmin Koin bindings hide the controls instead of failing composition (fixes Issue1366JustLiftExitNavigationTest 12 failures) - Remote seam (B1): a deferred bodyweight rep-entry save reports NO_COMPLETION (the dialog owns the decision), and a second watch press while the prompt owns the completion returns PHONE_INPUT_REQUIRED via an identity-anchored gate check that outlives the execution lease - Tests: the auto-complete race pins honest observed-identity reporting (matches WorkoutTeardownRecoveryTest semantics); the timed-set attribution fixture gets a second set so 'advance to the exact next set' is a real scenario; the remote JustLift end pins the completion machinery's waiting-mode arming (no autostart)
…h-controls # Conflicts: # shared/src/androidMain/kotlin/com/devil/phoenixproject/di/PlatformModule.android.kt # shared/src/commonMain/composeResources/values/strings.xml # shared/src/iosMain/kotlin/com/devil/phoenixproject/di/PlatformModule.ios.kt
…d migration 64) ExerciseMediaWiringTest pinned maxSeen <= 63 as 'Phase 1 adds no schema migration', but main's own #1392 power-loss work added 64.sqm — breaking this gate on main itself (main CI red at 6f95247, Unit Tests). The gate's intent ('media adds no migration of its own'; ExerciseImage pinned to 43.sqm) is preserved: unrelated schema work only moves the baseline. Cross-feature baseline drift flagged to the media Phase-1 owner; supersede freely.
PR follow-up — CI hardening (ticket 1569464719817838833, pr_followup stage)Pushed head garmin-ci — Build + simulator checks (fenix7 / fr255 / fr265 / fr965) — all four jobs failed on Unit Tests — 18 failures at
Merged Pre-existing main breakage (NOT from this PR): Still required before merge (merge gate must keep holding): the final visual QA capture matrix in this PR's body (GarminControlsSettingsCard states, Arm strip SetReady/Active frames, JustLift strip, cancel-confirm sheet, urgent-stop preemption, save timeout/failure, default + largest text sizes, plus one watch-simulator Start/Next–Stop/Cancel cycle recording). Not yet posted — the merge gate must not merge until it is captured, uploaded to |
… delegate signatures monkeyc rejects untyped Any-signature methods where the SDK expects Method(msg as Communications.PhoneAppMessage) as Void, Method(error as Communications.PhoneAppMessageError) as Void and Method() as Void (registerForPhoneAppMessages / registerForPhoneAppMessageErrors / Timer.start). Explicitly type the parameters and return Void on onPhoneMessage / onPhoneMessageError / onTick / onComplete / onError.
- Rename a commonTest backtick test name containing ',' — Kotlin/Native rejects ',.:;/<>[]' in names, breaking :shared:compileTestKotlinIosArm64 (required check 'iOS Test Target Compile'). - garmin-ci: DuckSoft/setup-connectiq-actions@v1 does not support the install-simulator-dependencies input (silently ignored), leaving the simulator without libwebkit2gtk-4.0.so.37. Install the simulator runtime libraries explicitly via apt instead.
…h-controls # Conflicts: # shared/src/commonTest/kotlin/com/devil/phoenixproject/presentation/ExerciseMediaWiringTest.kt
…m timeout - Pin DuckSoft/setup-connectiq-actions to main SHA 64f7145d with install-simulator-dependencies=true: the v1 tag predates that input and silently ignored it, leaving native deps for bin/simulator AND bin/shell unresolved (monkeydo hung until the outer timeout; exit 124). The upstream installer apt-installs and ldd-validates the full dependency set. - Raise run-simulator-tests.sh outer timeout 240s -> 480s for the larger Phoenix Run No Evil suite on cold simulator boots.
…nBridge The installed Connect IQ Mobile SDK renamed the app-message APIs (registerForAppMessages -> register(forAppMessages:delegate:), unregisterForAppMessages -> unregister(forAppMessages:delegate:), unregisterForAllAppMessages -> unregister(forAllAppMessages:), receivedMessage(_:fromApp:) -> receivedMessage(_:from:)); the old names fail the PhoenixApp iOS build (no CI job covers the app target, so this only surfaced in the phantom capture build).
…Connect IQ SDK Resolved SPM SDK (connectiq-companion-app-sdk-ios) renames vs the spellings the PR used: IQDevice(id:modelName:friendlyName:), IQApp(uuid:store:device:) (failable import; unannotated headers), NS_ENUM cases .connected/.failure_*_style, and receivedMessage(_:from:). Also move .onOpenURL from the Scene (SwiftUI Scene has no onOpenURL) to the root view. Verified: xcodebuild iphonesimulator build of PhoenixApp succeeds.
… timeout - The SPM ConnectIQ binary framework embeds into PhoenixApp.app/Frameworks but LD_RUNPATH_SEARCH_PATHS lacked @executable_path/Frameworks, so every build crashed at launch with 'Library not loaded: @rpath/ConnectIQ.framework/ConnectIQ' (fatalDyldError). Verified fix in the simulator build (app launches and renders). - run-simulator-tests.sh now prints the captured MonkeyDo output in cleanup so a timed-out run reveals how far monkeydo progressed (previous runs discarded tests.log silently).
PR follow-up status (2026-11-18) — CI hardening + first final visual evidenceCI at head
Verified green at Still red: Final visual evidence (implementation build, iOS Simulator — simulator evidence per owner policy):
Captured from Remaining before merge gate (merge gate must keep holding):
|



Garmin watch button controls for workouts (Phase 1 MVP) — issue #1391
Implements the signed-off Phase-1 enhancement for #1391 (ticket
1569464719817838833): control a Phoenix workout from the physical buttons on a Garmin watch — Start/Next, Stop set, and a confirmed Cancel exercise — with mandatory on-watch text feedback and a haptic only afterAPPLIED.Governance:
signoff.mdbinding corrections 1–8 + escalated decisions (routine watch Start == phone STARTskipCountdown=true;APPLIEDonly on commit-path persistence receiptSUCCEEDED/NOT_REQUIRED; iOS selection callback solicited/single-use on a dedicated scheme). Grounded atorigin/mainf6bf1712with all spec line citations re-derived.Fixes #1391
What this contains (packets B1–B8)
DefaultWorkoutSessionManager.endCurrentSetAndPrepareNext(expectedExecutionIdentity)with typedRemoteSetControlReceipt(commit-path persistence receipt, teardown observation, prepared-not-started successor, no-autostart suppression) +currentRemoteExecutionIdentityOrNull()manager accessor. Characterization/regression tests extended acrossIssue869SummaryAfterCommitTest,ManualStopProfileAttributionTest,WorkoutTeardownRecoveryTest,JustLiftCompletionBehaviorTest.GarminProtocol.kt(frozen v1 wire codec byte-mirroringgarmin/source/PhoenixProtocol.mc: HELLO/STATE/COMMAND/RESULT, bounded validation walk ≤2048 bytes / ≤24 keys / ≤2 container levels / ≤3 array elements / 64-80-32 byte string limits, codec-size estimator, fail-closed key sets) andGarminSessionControllerinternals: per-workout arming with fresh epochs, 3 s grants + 10 s confirmation tokens (bound to epoch+exercise+context+revision), fail-closed dedupe (256 command IDs/epoch, reserve-before-dispatch, identical-duplicate cached outcome,COMMAND_ID_CONFLICT,EPOCH_CAP_REACHEDdisarm/rekey), single serialized admission with urgentSTOP_SETpre-emption,ACCEPTED/APPLIED/REJECTEDresult semantics withUNKNOWN_RESULT/SAVE_FAILEDstart-blocks, authority invalidation (logout/profile switch/disconnect/restart) and owner-generation drops of late native callbacks. DI:GarminControlPreferences+ holder binding;MainViewModelcomposes the controller against its single session manager (integration-model §5 — one phone manager only).GarminControlsSettingsCardbesideHrmSensorSettingsCard(HR surfaces untouched) +GarminControlsArmStripon SetReady/Active/JustLift screens; default-OFF release boundary (card shows unavailable until a matched production watch-app UUID is configured).GarminCompanionBridge.swift(dedicated callback scheme, solicited single-use selection callback,-ObjC), tvOS no-op.garmin/Monkey C app (manifest, protocol, view, delegate, Run-No-Evil tests, static checks) +.github/workflows/garmin-ci.yml. Button map: top-right Start/Next, bottom-right urgent Stop, bottom-left open Cancel confirm, middle-left dismiss; no long-hold destructive action.Verification (commands run on this branch)
./gradlew -Pskip.supabase.check=true :shared:testAndroidHostTest --tests '*GarminProtocolTest*' --tests '*GarminSessionControllerTest*'— 43/43 PASS (frozen-contract validation rows, grant/confirmation TTLs via fake monotonic clock, dedupe/conflict/cap rekey, provenance rejections, authority invalidation, STOP pre-emption, routing parity, receipt semantics).'*Issue869*' '*ManualStop*' '*Teardown*' '*JustLift*') — known not green at this head; needs triage before merge:ManualStopProfileAttributionTest2 failures (remoteSetControlSaves*: observed execution identity differs — an extra execution appears in those scenarios);JustLiftCompletionBehaviorTest2 failures (timed-summary grab/dismiss expectations);Issue1366JustLiftExitNavigationTest12 failures (untouched by this PR; suspected pre-existing/flaky — please compare againstmain).Issue869SummaryAfterCommitTestandWorkoutTeardownRecoveryTestpass (receipt honesty incl. stuck-savePENDING/FAILEDand no fabricated successor).Visual evidence (UI-involved)
Final in-app visual QA (settings-card states, Arm strip at default + largest accessibility text sizes, native Active/Rest/Summary frames, cancel-confirm sheet, watch-simulator cycle recording) is in progress and will be posted as PR comments and referenced here before merge. Merge gate: do not merge until
final_visual_artifactsexist and are linked.Release-note draft (from
user-instructions.md)Scope boundary
Phase 1 only. No DB/schema/sync/portal/analytics changes; no background start (
backgroundStopSupported=false); no watch-side routine loading/selection/weight editing; no media-key mapping; no HR surface changes. Phone side ships default-OFF until a supported, matched watch app is detected. Garmin developer signing and Connect IQ Store submission are release-time external dependencies and do not block merging default-off code. Phases 2 (on-watch exercise/set/rest dashboard, rest-end haptic) and 3 (button remapping) are deferred to their own cards.