Skip to content

gate select_wrist decode on cmd_status - #59

Merged
abdulsaheel merged 2 commits into
mainfrom
fix/select-wrist-status-gate
Sep 18, 2026
Merged

abdulsaheel merged 2 commits into
mainfrom
fix/select-wrist-status-gate

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

select_wrist reply was decoded unconditionally, unlike every other set-style
confirmation in this file (battery pack info, hello, clock, data range) which
all check cmd_status first. a failed write (bad wrist value, refused
mid-handshake) still returned a SelectWristResponse built from stale payload
bytes, indistinguishable from a real success.

fix: gate it on status == 1, matching the getHello precedent. added a test
for the failure case.

Summary by Sourcery

Only decode select-wrist confirmations when the command reports success.

Bug Fixes:

  • Prevent failed select-wrist commands from being decoded as successful confirmations by requiring an OK command status.

Tests:

  • Add coverage verifying that select-wrist responses with a failed command status are ignored.

Summary by CodeRabbit

  • Tests
    • Added coverage confirming failed wrist-selection responses are not presented as successful selections.
  • Documentation
    • Clarified the explanation for handling failed wrist-selection responses, without changing application behavior.

…plies

a failed select_wrist write still returned a SelectWristResponse built from
stale payload bytes, no different from the fixed getBatteryPackInfo/getHello
cases. added the status==1 check + a test for the failure case.

@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.

Sorry @abdulsaheel, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 6 days and 17 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 1128013b-6049-4b58-af06-6e6dd2e09999

📥 Commits

Reviewing files that changed from the base of the PR and between eda21e8 and 3659149.

📒 Files selected for processing (2)
  • lib/src/control.dart
  • test/whoop_protocol_update_test.dart
 ____________________________________________________________________________________________________________________________
< There is nothing quite so useless as doing with great efficiency something that should not be done at all. - Peter Drucker >
 ----------------------------------------------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

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

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR aligns select_wrist decoding with other SET-style responses by requiring cmd_status == 1, preventing failed writes from being represented as successful confirmations, and adds a regression test for stale payload data on failure.

Sequence diagram for status-gated wrist selection response decoding

sequenceDiagram
    participant Device
    participant Parser as parseCommandResponse
    participant Consumer

    Device->>Parser: select_wrist response with status and payload
    alt status == 1
        Parser->>Parser: SelectWristResponse(revision, payload)
        Parser-->>Consumer: dec[select_wrist]
    else status != 1
        Parser-->>Consumer: no select_wrist response
    end
Loading

File-Level Changes

Change Details Files
Gate decoded select-wrist confirmations on a successful command status.
  • Only construct SelectWristResponse when status equals 1.
  • Preserve existing revision and payload decoding for successful responses.
lib/src/control.dart
Add regression coverage for failed select-wrist responses.
  • Verify a non-success status does not add a select_wrist decoded response, even when stale-looking payload bytes are present.
test/whoop_protocol_update_test.dart

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

@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.

Sourcery assessment

Approved.

@abdulsaheel
abdulsaheel merged commit 62fdc4e into main Sep 18, 2026
3 of 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