Skip to content

Show remote command results sooner on the phone, watch and Live Activity - #805

Merged
bjorkert merged 4 commits into
loopandlearn:devfrom
achkars-org:fix/refresh-after-remote-command
Nov 1, 2026
Merged

bjorkert merged 4 commits into
loopandlearn:devfrom
achkars-org:fix/refresh-after-remote-command

Conversation

@MtlPhil

@MtlPhil MtlPhil commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Loop and Trio apply a remote command within seconds, but LoopFollow only saw the result on its next regular fetch. That's up to 2 minutes for treatments and about 5 for device status.

This follows up on @marionbarker's testing in #792 (comment), where preset changes on the phone and presets sent from the watch were slow to show on the watch.

Phone

  • After a command is sent from the phone or the watch, the phone fetches treatments and device status at 10, 20, 30, 60, 90 and 120 s.
  • It stops once the change shows up: the override or temp target changed, or a bolus or carb entry with the sent amount appeared.
  • A newer command restarts the schedule. If the app was suspended past several fetches, it runs one on resuming, not all the overdue ones.
  • It doesn't send the watch a state that hasn't changed. It still sends at least every 5 minutes, and always after the session activates or the watch changes.

Watch

  • After a command sent directly to Loop or Trio (phone out of reach), the watch fetches at 10, 20, 40 and 60 s, and stops once the change shows up or a newer state arrives from the phone.
  • The watch's own fetch now drops a recommended bolus from before a manual bolus, as the phone does.
  • Trio override names now read from notes before reason, so they match the phone.

Every Nightscout fetch rebuilds the chart, and every rebuild sent the full
24-hour state to the watch, even when nothing in it had changed. Each send
can wake the watch app.

The phone now skips a state equal to the last one sent, apart from its build
time. It still sends at least every 5 minutes, well inside the 10 minutes
after which the watch treats the phone's data as stale and fetches on its
own. It always sends after the session activates or the watch changes (new
install or pairing), and retries after a failed send.
When the phone is out of reach, the watch sends commands directly to Loop or
Trio. Nothing then fetched the result: the watch only fetches on its own once
the phone's last state is more than 10 minutes old, so a command sent soon
after losing the phone could take up to 10 minutes to show.

After a successful direct command, the watch now fetches 10, 20, 40 and 60
seconds after the send, even while the phone's last state is still fresh,
and stops at the first fetch that shows the change: the preset's override or
temp target, its cancellation, or a new bolus or carb entry with the sent
amount. A check that never matches only means all four fetches run.

The follow-up stops as soon as a newer state arrives from the phone, so a
fetch that was already under way does not replace it. While the phone's last
state is still fresh, its alarm stays shown, since the watch's own fetch has
no alarms.

The watch's own fetch now reads the override name from "notes" before
"reason", as the phone does, so Trio overrides show the same name on both.
Loop and Trio apply a command within seconds, but the phone only saw the
result on its next regular fetch: up to 2 minutes for treatments (overrides,
temp targets, boluses, carbs) and about 5 minutes for device status (IOB,
recommended bolus). The phone, the watch and the Live Activity showed the
old state until then.

After a command is sent from the phone or the watch, the phone now fetches
treatments and device status 10, 20, 30, 60, 90 and 120 seconds later. It
stops as soon as the command's change is visible: the active override or
temp target differs from before the send, or a new bolus or carb entry with
the sent amount appears. A Trio meal sent with a bolus waits for both. A
newer command restarts the schedule.

Each fetch schedules the next, so when the app was suspended past several
of them, as in the Bluetooth heartbeat modes, it fetches once on resuming
instead of all the overdue ones at once.
When the watch fetches on its own, it took the recommended bolus from the
latest device status as is. If a manual bolus came after that loop cycle,
the recommendation leaves that bolus out, and the watch could start the
bolus screen at it. The phone already drops such a recommendation, and the
watch only dropped one from before insulin it sent itself.

The watch's own fetch now drops it the same way as the phone: when a manual
bolus (not automatic, not an SMB) is at or after the loop cycle. This matters
more now that the watch also fetches right after a command it sends without
the phone, while the phone's last state is still fresh.
@marionbarker

Copy link
Copy Markdown
Collaborator

Test

✅ successful test

Configuration

Build LoopFollow from this PR onto phone that is observing a Loop URL.

Test Details

Tested the sending of bolus, setting/clearing override, sending of carbs.
The update on the watch is very fast on all of these.
So long as the LoopFollow phone is locked, the success shows up on the watch promptly.
Even when the LoopFollow phone version is open and unlocked, so message goes to phone, not watch, the watch app promptly moves from the action screen (like bolus) to the main LoopFollow watch screen.

@marionbarker marionbarker 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 from test. I would like a code review prior to merge.

@bjorkert
bjorkert merged commit 33d6e56 into loopandlearn:dev Nov 1, 2026
3 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.

3 participants