Skip to content

Conversation

@dnzxy
Copy link
Contributor

@dnzxy dnzxy commented Dec 22, 2025

Summary

This PR fixes cases where negative IOB can occur when pump history contains a resume without a preceding suspend (e.g. fresh installs of newly onboarded Trio users).

Fixes: #898

Changes

The logic now detects resume-only states within the DIA (duration of insulin action) window and injects a simulated suspend event 1s before the resume only if no real suspend exists in the relevant history window. This gives oref a safe baseline without altering valid pump history.

@marionbarker
Copy link
Contributor

Test

Summary: TBD

Configuration

  • Use an older version of the pod rPi simulator (commit 4e2a622) that does not properly report pods as suspended in certain cases.
  • Use an older version of OmniBLE (commit b65dbfc2e) so can present resume without suspend.

Test 1

Delete Trio for SE 3rd gen phone running iOS 26.

  • build Trio dev (0.6.0.31) (with modified OmniBLE) to the phone
  • accept all default settings except set basal rates to 1 U/hr, CR to 10 g/U and ISF to 50 mg/dL/U
    • for the initial attempt I left basal at 0.1 U/hr and the negative IOB was -0.21; so started over with higher basal rates

Add Glucose simulator as CGM and rPi DASH as pump.
Observe IOB

Time IOB Comment
14:16 0 pod connected
14:19 -1.56 closed loop disabled
14:24 -1.56 flip from disable to enable
14:25 -1.51 first loop, TB set
14:32 -1.41 end test

Test 2

Delete Trio for SE 3rd gen phone running iOS 26.

  • build Trio fix-negative-iob-after-onboarding, commit 6e5e780, with modified OmniBLE to the phone
  • accept all default settings except set basal rates to 1 U/hr, CR to 10 g/U and ISF to 50 mg/dL/U

Add Glucose simulator as CGM and rPi DASH as pump.
Observe IOB

Time IOB Comment
14:42 0 pod connected
14:51 -1.56 closed loop disabled

no difference. Make sure I really have the new build.
Do a clean build folder, close and open workspace
rebuild and no difference.

Do another delete Trio and rebuild again.
Repeat the test.
Same result.

@dnzxy dnzxy marked this pull request as ready for review December 27, 2025 03:32
@dnzxy dnzxy requested a review from kingst December 27, 2025 03:32
@marionbarker
Copy link
Contributor

Test Summary

Initial look is good - no unexpected negative IOB after pump and CGM are attached to a fresh build.
I'll let this phone run in closed Loop for a while to see if unexpected negative IOB show up later in the history.

Test 3

Earlier tests were done before the PR was ready for testing.

Delete Trio from SE 3rd gen phone running iOS 26.

  • build Trio commit b7d42e3 (this pr) to the phone
  • accept all default settings except set basal rates to 1 U/hr, (SMB are disabled)

Add Glucose simulator as CGM and rPi DASH as pump.

  • TBR = temp basal rate
  • SBR = scheduled basal rate

Observe IOB

Time IOB Comment
19:46 0 rPi pod connected
19:50 0 first new CGM reading, closed loop still disabled
19:57 0 flip from closed loop from disable to enable
20:05 0 looping, TBR (0.55 U/hr) < SBR (1.0 U/hr) because of glucose history
20:08 -0.05 U looping, this small negative IOB is because TBR still 0.55 U/hr
20:13 -0.1 U looping, TBR is now same as SBR, 1.0 U/hr
20:23 -0.1 U looping, TBR still same as SBR, 1.0 U/hr

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.

3 participants