Skip to content

Conversation

@dragm83
Copy link
Contributor

@dragm83 dragm83 commented Dec 7, 2025

Store maximum observed bluetooth weight in header (instead of instantaneous scale reading at end of shot).

Summary by CodeRabbit

  • Bug Fixes
    • Modified weight tracking during espresso shots to record and utilize the maximum observed weight for final calculations, replacing the previous current weight method.
    • Ensured per-shot state is properly reset when starting new recording sessions, including all weight tracking counters.

✏️ Tip: You can customize this high-level summary in your review settings.

@cla-bot cla-bot bot added the cla-signed label Dec 7, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 7, 2025

Walkthrough

Modified ShotHistoryPlugin to track the maximum weight observed during a shot recording. The maxRecordedWeight member variable captures the peak weight, which is then used to compute the final weight instead of using the instantaneous weight value at flush time.

Changes

Cohort / File(s) Change Summary
Weight tracking enhancement in ShotHistoryPlugin
src/display/plugins/ShotHistoryPlugin.h, src/display/plugins/ShotHistoryPlugin.cpp
Added maxRecordedWeight member variable to track peak weight during shot. Modified record() to update max weight when current weight exceeds previous maximum. Modified flushing logic to compute finalWeight from maxRecordedWeight instead of instantaneous currentBluetoothWeight. Reset maxRecordedWeight in startRecording() for each fresh shot.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify maxRecordedWeight is properly reset in startRecording() alongside other per-shot state
  • Confirm the weight comparison logic in record() correctly updates the maximum value
  • Validate that finalWeight computation from maxRecordedWeight preserves expected behavior in the flushing path

Possibly related PRs

Poem

🐰 A shot's true strength lies not in the end,
But in the peak that it did ascend!
Max weight tracked, through every sip,
Making espresso shots truly ship. 📊✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Track maximum observed Bluetooth weight during shot' accurately describes the main change: storing the maximum weight observed during a shot instead of the instantaneous reading at the end.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8144c7f and aaadb42.

📒 Files selected for processing (2)
  • src/display/plugins/ShotHistoryPlugin.cpp (3 hunks)
  • src/display/plugins/ShotHistoryPlugin.h (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: deploy
  • GitHub Check: test
🔇 Additional comments (4)
src/display/plugins/ShotHistoryPlugin.h (1)

81-81: maxRecordedWeight field fits cleanly into existing per‑shot state

The new maxRecordedWeight member is well named, uses the same type as other weight fields, and is safely default‑initialized. Together with the reset in startRecording(), this should behave correctly per shot without leaking state between shots.

src/display/plugins/ShotHistoryPlugin.cpp (3)

143-146: Max-weight tracking logic correctly captures peak shot weight

Updating maxRecordedWeight whenever currentBluetoothWeight exceeds it ensures you retain the highest observed value across both brew and extended-recording phases. Because the field is per-instance and only written here, this is a simple and robust way to derive a peak weight for the shot.


221-222: finalWeight now correctly derived from the tracked maximum

Using maxRecordedWeight to derive header.finalWeight aligns the stored volume with the peak weight seen during the shot, rather than a potentially transient final reading. Existing consumers that rely on header.finalWeight (history list, index entries, rebuild logic) will automatically get the improved semantics without further changes.


288-290: Per-shot reset of maxRecordedWeight prevents cross-shot contamination

Resetting maxRecordedWeight in startRecording() complements the default initializer and guarantees each new shot’s final volume is computed purely from that shot’s samples, even if the plugin instance is reused across multiple shots.


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 and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 7, 2025

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant