Skip to content

hr fallback: don't skip first sample after a hole as run start - #119

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/hrfb-hole-skip
Dec 5, 2026
Merged

abdulsaheel merged 1 commit into
mainfrom
fix/hrfb-hole-skip

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

the run scan broke at a recording hole with j on the first sample after it, then did i = j + 1, so that sample was never tried as a run start. onset landed one sample late (1 to 5 min on slow-cadence devices), or the run was lost if it was a single sample. now resumes at j after a hole break. test added.

Summary by Sourcery

Correct heart-rate fallback run scanning so it evaluates the first sample after a recording gap as a possible run start.

Bug Fixes:

  • Preserve the first sample after a recording gap as a candidate start for a low-heart-rate run, preventing sleep onset from shifting later or a one-sample run from being skipped.

Tests:

  • Add a regression test verifying that a run beginning immediately after a recording hole retains its correct onset.

Summary by CodeRabbit

  • Bug Fixes
    • Sleep detection now correctly identifies the start of a low-heart-rate sleep period when it begins after a gap in recorded data. Previously, the first sample after a long gap could be skipped, preventing the period from being recognized at the correct time. This improves the accuracy of sleep windows when recordings are interrupted.

@sourcery-ai

sourcery-ai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Resume the scan at the first sample after a recording hole so it can become the start of a low-HR run.

  • lib/src/onehz/sleep/hr_fallback.dart L105, L112-115, L141-143

Tests

Add a regression test confirming the first sample after a recording hole is preserved as the run onset.

  • test/onehz/hr_fallback_test.dart L93-113

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The HR-run scan now resumes at the first sample after a large recording gap. A regression test checks that the detected window starts at that sample.

Changes: Heart-rate fallback gap handling

Layer / File(s) Summary
Resume scanning after a sample gap
lib/src/onehz/sleep/hr_fallback.dart, test/onehz/hr_fallback_test.dart
The scan resumes at the first sample after a large gap. The regression test checks that the detected window starts at the first post-gap sample.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 03750

This change fixes late sleep-onset detection after a recording gap in the heart-rate fallback, and it adds a regression test. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the actual change: the HR fallback scan no longer skips the first sample after a recording hole when it considers a run start. The raw summary and PR objectives both describe this same…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the actual change: the HR fallback scan no longer skips the first sample after a recording hole when it considers a run start. The raw summary and PR objectives both describe this same fix, so the title matches the changeset's main point.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3569cda0-edc3-4ddc-8511-49cf0640cae2
Commits

Reviewing files that changed from the base of the PR and between 5e07e02 and 0375089.

Files selected for processing: 2

  • lib/src/onehz/sleep/hr_fallback.dart
  • test/onehz/hr_fallback_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@abdulsaheel
abdulsaheel merged commit d54980e into main Dec 5, 2026
4 checks passed
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