fix(watch): kick sync service unconditionally on app start

Without this, the watch would only run a poll cycle if the pending
queue happened to be non-empty — meaning the case list was empty
forever for users who didn't dictate before opening the app. Kicking
on every launch makes the foreground service start, primes the case
store from the snapshot cache, then polls /api/oneliners.

Verified end-to-end on Wear OS 36 emulator-5556 against a live local
server:
- 4 server cases populate the list within ~150 ms of app start
- Tap Neu → mic permission → record → stop completes in <3 s of UI
- Sync service uploads, server transcribes (whisper) + classifies
  (ollama), watch's burst-poll hits within 2 s of upload-success and
  merges the OnelinerState.Empty (silence rule) back into the marker
- unsynced/ ends empty (deletePair after ACK), cases/ has 5 markers
  with synced_to_server=true, snapshot_cache.json on disk
This commit is contained in:
2026-04-27 00:03:40 +02:00
parent 20706bcf0c
commit 1016788514
@@ -80,16 +80,16 @@ class DoctateApp : Application() {
.launchIn(applicationScope)
// One-shot data-minimization sweep before the sync worker starts,
// then kick the service if the pending queue still has work.
// then kick the service so it polls /api/oneliners and uploads any
// pending recordings. Kicking unconditionally — even with an empty
// queue we want the case list to populate from the server.
applicationScope.launch {
StartupCleanup.run(
store = caseStore,
pendingDir = File(filesDir, "recordings/unsynced"),
)
if (pendingStore.scan().isNotEmpty()) {
Log.i(TAG, "startup: pending queue non-empty → kicking sync service")
syncTrigger.kick(this@DoctateApp, SyncKick.NewPending)
}
Log.i(TAG, "startup: kicking sync service (queueLen=${pendingStore.scan().size})")
syncTrigger.kick(this@DoctateApp, SyncKick.NewPending)
}
}