Skip to content

Restore Loop forecast after a refresh clears it#706

Closed
bjorkert wants to merge 1 commit into
devfrom
fix/loop-forecast-restore-on-refresh
Closed

Restore Loop forecast after a refresh clears it#706
bjorkert wants to merge 1 commit into
devfrom
fix/loop-forecast-restore-on-refresh

Conversation

@bjorkert

Copy link
Copy Markdown
Member

On Loop data sources, the glucose forecast is drawn on first load but disappears after a refresh and does not reappear until the next loop cycle.

refresh() clears predictionData and redraws an empty forecast. It runs on pull-to-refresh, on data-source reconfiguration, and on every WebSocket disconnect (which posts the refresh notification). The Loop forecast is only rebuilt in DeviceStatusLoop, and only when a newer loop cycle arrives (previousLastLoopTime < lastLoopTime). Because the current cycle has already been seen at that point, the forecast stays blank until the pump clock advances — up to five minutes, and longer when the WebSocket disconnects repeatedly.

Rebuild the forecast when predictionData is empty as well, so the next device-status poll restores it regardless of cycle timing. Same-cycle polls that already have forecast points continue to skip the rebuild. This mirrors the OpenAPS/Trio path, which already repopulates its prediction unconditionally and is unaffected.

refresh() clears predictionData and redraws an empty forecast, but the
Loop forecast is only rebuilt when a newer loop cycle arrives
(previousLastLoopTime < lastLoopTime). Since the current cycle has
already been seen at that point, the forecast stays blank until the pump
clock advances.

Also rebuild when predictionData is empty so the next device-status poll
restores the forecast regardless of cycle timing.

@codebymini codebymini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍
Approve by code review and test

@bjorkert

Copy link
Copy Markdown
Member Author

Superseded by #707, which absorbs this fix (rebuild the forecast when predictionData is empty) alongside the change that stops refresh() from wiping the forecast on every refresh.

@bjorkert bjorkert closed this Jul 17, 2026
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.

2 participants