From 072dc7e6e72a4cfc34475a6224b96e5dfe937806 Mon Sep 17 00:00:00 2001 From: ryanbr Date: Fri, 24 Jul 2026 07:14:09 -0700 Subject: [PATCH] Android auto-detect: read HR over the active-strap union, not hardcoded my-whoop (#767, #717) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Workout auto-detection silently stopped for live-BLE users while sleep, charge and everything else kept syncing. Root cause: AutoWorkoutNudge read HR via repo.hrSamples("my-whoop", ...) — a hardcoded id — but a live strap banks its raw under its OWN fresh id ("whoop-", #908), so the read returned nothing and detect() bailed at 'hr.size < 2'. The mid-July active-strap-id migration (#175/#512/#513) moved sleep/charge/health/iOS reads to the active-strap union but missed this one. Fix: read the hrSamplesUnion(activeDeviceId) — importedSourceIds(active) ∪ my-whoop, deduped — exactly what every other Today read and iOS Repository.autoDetectCandidate() already use. Android-only; iOS was never affected (it already reads the union). No behaviour change for single-WHOOP installs, whose active id resolves to my-whoop (one id, identical read). App-target Android; not compiled here (aapt2 x86-only on this host) - run ./gradlew compileFullDebugKotlin before merge. --- android/app/src/main/java/com/noop/ui/AutoWorkoutNudge.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/noop/ui/AutoWorkoutNudge.kt b/android/app/src/main/java/com/noop/ui/AutoWorkoutNudge.kt index 4ed2eebf49..d1e1c9fcad 100644 --- a/android/app/src/main/java/com/noop/ui/AutoWorkoutNudge.kt +++ b/android/app/src/main/java/com/noop/ui/AutoWorkoutNudge.kt @@ -229,7 +229,11 @@ private suspend fun autoDetectCandidate( val fromSec = nowSec - AUTO_DETECT_DAYS_BACK * 86_400L val repo = viewModel.repo - val hr = repo.hrSamples(AUTO_DETECT_DEVICE, fromSec, nowSec, limit = 200_000) + // #767/#717: read HR over the ACTIVE-strap UNION, not the hardcoded "my-whoop" id. A live-BLE strap + // banks its raw under its OWN fresh id ("whoop-", #908), so a read pinned to "my-whoop" finds + // NOTHING and auto-detect goes silent — even though sleep/charge (which read the union) keep working. + // Mirrors iOS Repository.autoDetectCandidate(), which reads the hrSamples(from:to:) union. + val hr = repo.hrSamplesUnion(viewModel.deviceId, fromSec, nowSec, limit = 200_000) if (hr.size < 2) return null // Resting HR: most recent nightly RHR in history, else the detector's own default (60). Byte-faithful