Skip to content

Show a stale cue and status line on the CarPlay Live Activity - #829

Open
MtlPhil wants to merge 2 commits into
loopandlearn:devfrom
achkars-org:pr/carplay-stale-status-line
Open

MtlPhil wants to merge 2 commits into
loopandlearn:devfrom
achkars-org:pr/carplay-stale-status-line

Conversation

@MtlPhil

@MtlPhil MtlPhil commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

A Live Activity only redraws when an update reaches it, so on CarPlay a reading can look current long after it has stopped updating.

Staleness

  • staleDate is set 12 minutes after the reading and sent in update pushes, so iOS can flag a stale activity on its own.
  • Renewal now depends only on laRenewBy and laRenewalFailed, so stale data no longer forces a replacement when the app opens.

Small family (CarPlay and the Watch Smart Stack)

  • A stale reading is struck out in red, and the BG and arrow turn grey.
  • A status line shows the update time, IOB, COB and any active override. While it's on, IOB, COB and Override aren't offered for the right slot. It's on by default, except for users whose right slot already holds one of those three; they keep their slot until they turn the line on.
  • A Tight CarPlay Layout switch, off by default, puts projected BG, IOB, COB and basal in the right slot. It only applies at 205 points wide or more, because no API tells CarPlay apart from the Watch.

Tests cover the stale date, renewal, override details and the small-widget layout. A CarPlay widget follows in a separate PR.

A Live Activity only redraws when an update reaches it, so with no network
or a stopped app it cannot show that its data is old. staleDate is now 12
minutes after the reading and is sent in update pushes, so iOS can flag the
activity without the app. Renewal relies only on laRenewBy and
laRenewalFailed, so stale data no longer replaces the activity when the app
opens; an activity with no stored deadline is still replaced, since it
could never renew.

The small family, shown on CarPlay and in the Watch Smart Stack:

- A stale reading is struck out in red, with the BG and arrow grey.
- A status line, on by default, shows the update time, IOB and COB (or Not
  Looping in their place) and any active override with its insulin needs,
  range and time left. While it is on, IOB, COB and Override are not
  offered for the right slot; a stored choice of one of them comes back
  when the line is turned off. Turning it off also restores the original
  font sizes.
- A Tight CarPlay Layout switch, off by default, replaces the right slot
  with projected BG, IOB, COB and basal, and centres the bottom row. No API
  tells CarPlay from the Watch, so it also needs a width of at least 205
  points: the 240-wide CarPlay layouts, not the 170-wide one.

Both switches explain themselves in an info button.
@MtlPhil
MtlPhil force-pushed the pr/carplay-stale-status-line branch from 1e17855 to 3e15548 Compare November 16, 2026 02:54
@MtlPhil
MtlPhil marked this pull request as ready for review November 16, 2026 02:57
@bjorkert

Copy link
Copy Markdown
Member

Looks good overall, a few things I found:

  1. LiveActivityManager.swift:557-558 in startIfNeeded still picks the existing activity with activityState == .active. With the stale date now at reading + 12 min, .stale becomes a normal state, so a stale tracked activity is skipped and we fall through to another active one or activities.first. If there is more than one activity we can bind the wrong one, and endOrphanedActivities (called right after at :578) then ends the live one. Using the same .active || .stale check as firstUpdatableActivity (:1168) would fix it.

  2. The status line defaults to on (showSmallWidgetStatusLine() ... ?? true). Existing CarPlay/Watch users who have IOB, COB or Override in the right slot lose that slot and get the smaller font without having chosen it. Maybe default to off for existing installs, or keep their slot choice.

  3. Small one: the comment in APNSClient.swift:147 still says "The stale date (8 h)", which no longer holds.

- startIfNeeded now treats a .stale activity as updatable, like
  firstUpdatableActivity. With the stale date at reading + 12 min, .stale is
  a normal state, so skipping it could bind the wrong activity and then end
  the live one as an orphan.
- The status line now starts off when the right slot holds IOB, COB or
  Override, so those users keep their slot and the original font sizes. The
  value is stored the first time the slot changes, so picking a new slot
  never turns the line on or off by itself.
- The APNs expiry comment no longer refers to the old 8 h stale date.
@MtlPhil

MtlPhil commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All three are fixed in 57bd2ba:

  • startIfNeeded skipping a stale activity: Good catch. It now uses the same check as firstUpdatableActivity (.active or .stale), and both places call one shared helper so they can't drift apart again. A stale tracked activity is now reused instead of being passed over and then ended as an orphan.
  • Status line default: It now starts off when the right slot already holds IOB, COB or Override, so those users keep their slot and the original font sizes until they turn the line on. Everyone else still gets it by default. The value is saved the first time the slot changes, so picking a different slot never turns the line on or off by itself. I updated the PR description to match.
  • APNs comment: Updated. It no longer mentions the 8 h stale date.

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