Skip to content

feat: port sleep editing, estimated SpO2, phone step source, and bucket/HR time formatting - #152

Open
foureight84 wants to merge 1 commit into
saksham2001:mainfrom
foureight84:feat/android-sync-batch-2026-12
Open

foureight84 wants to merge 1 commit into
saksham2001:mainfrom
foureight84:feat/android-sync-batch-2026-12

Conversation

@foureight84

Copy link
Copy Markdown
Contributor

Summary

Ports the remaining Android features/fixes (PulseLoopAndroid PRs #98, #129, #130, #149, #154) to iOS:

  1. Sleep Record Editing & Extension + Bedtime Tail Detector (SleepRecordExtension, SleepTailSuggestion, SleepView, PulseEventBus):
    • Added isManuallyEdited (Bool = false) to SleepSession (and ArchiveSleepSession backward compatibility) and overlap protection in PulseEventBus.persistSleepTimeline so ring re-syncs do not overwrite edited sleep bounds without blocking distinct sessions (e.g. naps) on the same waking day.
    • Added Edit sleep button & SleepEditSheet in SleepView to extend/trim bedtime and wake bounds (with SleepRecordExtension.computeLimits / editedBlocks) or delete a sleep record.
    • Added SleepTailSuggestionDetector & SleepTailSuggestionStore (including the manual-edit cap from Android PR #154).
  2. Estimated Hourly SpO₂ Labeling (EstimatedSpo2, MetricDetailView):
    • Ported EstimatedSpo2 heuristic detecting when a ring's history SpO₂ values vary deterministically with heart rate alongside respiratory-rate timestamps.
    • Wired "Estimated from HR" badge and disclaimer into MetricDetailView for .spo2 when detected.
  3. Phone Step Source Option (StepSourcePrefsStore, DisplaySteps, PhoneStepManager, MeasurementSettingsView, ActivityView, ActivityTrendsView, PulseServices):
    • Added ActivityDaily.phoneSteps / phoneDistanceMeters (non-destructive alongside ring steps, preserved in DataArchive), NSMotionUsageDescription in project.pbxproj, and CMPedometer-backed PhoneStepManager.refreshToday.
    • Added Ring / Phone / Auto (Highest) Step Source segmented picker in MeasurementSettingsView.
    • Routed MetricsService.buildTodaySummary, metricRange, ActivityTrendsView, and Coach context through DisplaySteps.
  4. Activity Step Bucket Time Ranges & HR Live Seconds (ReadingsTimeFormatter, ActivityBucketSample.durationMinutes, ActivityView, MetricDetailView):
    • Plumbed durationMinutes: Int? on activityBucket events (15m Colmi/JRing, 30m YCBT, 60m RWfit JieLi) and ActivityBucketSample.
    • Added today's Step Breakdown card in ActivityView displaying formatted time ranges (9:00 AM – 9:15 AM).
    • Added Recent Readings in MetricDetailView displaying seconds for live sub-minute HR streams.

Verification

  • xcodebuild test -project PulseLoop.xcodeproj -scheme PulseLoop -destination 'platform=iOS Simulator,name=iPhone 17' -only-testing:PulseLoopTests/SleepEditingAndTailTests -only-testing:PulseLoopTests/EstimatedSpo2Tests -only-testing:PulseLoopTests/StepSourceTests -only-testing:PulseLoopTests/ActivityBucketAndReadingsTests -only-testing:PulseLoopTests/ColmiDecoderTests -only-testing:PulseLoopTests/RWfitDecoderTests -only-testing:PulseLoopTests/YCBTHealthRecordsTests -only-testing:PulseLoopTests/RingDecoderTests -only-testing:PulseLoopTests/LuckRingDecoderTests: 141/141 tests passed.
  • Independent code review completed and all findings addressed prior to PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant