Skip to content

[4/6] Rebuild Add carbs around a live preview of the meal - #2640

Open
Nutcasey wants to merge 5 commits into
LoopKit:next-devfrom
Nutcasey:redesign-4-add-carbs
Open

Nutcasey wants to merge 5 commits into
LoopKit:next-devfrom
Nutcasey:redesign-4-add-carbs

Conversation

@Nutcasey

@Nutcasey Nutcasey commented Nov 1, 2026 •

Copy link
Copy Markdown

Part 4 of 6 splitting #2621. Builds on parts 1–3 (#2637, #2638, #2639). Review commit f8b498e6.

The new interface's Add carbs leads with the amount in large type, over a chart of how the meal will absorb. The chart redraws as the amount, speed and eaten time change. Under it:

  • Favourite foods as chips.
  • Speed: Fast, Medium, Slow, or Other with its own emoji and time.
  • Eaten: Now, 15 or 30 minutes ago, an hour ago, or an exact time.

Warnings, and Continue to the bolus screen, work as before. Editing a carb entry from the Logbook uses the same screen. The classic interface keeps the classic form.

Choosing a speed after a favourite lets the favourite go but keeps its amount. CarbEntryViewModel applied a favourite selection on the next run-loop turn, which could reset an amount or speed set straight after it. It now applies the selection at once, with a regression test.

Add carbs, empty Medium, eaten an hour ago Fast, 15 minutes ago Editing from the Logbook

Differences from #2621: two fixes found while testing this part

  • A favourite showed 0 g. Picking a favourite left the amount at "0 g" while the model held 35 g and Continue was enabled, so a meal could be entered without being shown. The field only synced when unfocused, and it auto-focuses on open; the tap's unfocus hadn't applied when the change arrived. It now syncs whenever the field doesn't already show the model's amount. Typing is unaffected, including a trailing decimal separator in en, de, fr and ar.
  • An entry older than 12 hours showed the wrong time. Editing such an entry from the Logbook showed the picker's clamped limit (02:10) instead of its time (21:35). The eaten range now reaches back to the entry's own time.

Testing

On the loop simulator, through XCUITest, with before and after screenshots:

  • Favourite → 35 g. Fast → still 35 g, absorbed in 30 minutes. Typing 4.5 keeps the decimal.
  • Logbook → edit a 31 October entry → "31 Oct 2026, 21:35".

LoopTests (450 run on this part, on next-dev 5ee95cc6): all pass except BolusEntryViewModelTests.testCarbEntryDateAndAbsorptionTimeString and …String2, which fail the same way on plain next-dev ("12:00 PM" against "12:00"). Xcode's hosted test run stalls at test-host launch on this machine, so these ran in the app bundle under Xcode's simulator XCTest agent, with next-dev's test classes except the HealthKit-hosted DeviceDataManagerTests. Every part was built on its own, in order, on the loop simulator.

The series

#2621 is split into six PRs, in the order Pete suggested: statistics and Trends first, then the Logbook, then the home screen. Add carbs, the widget and Live Activity, and the appearance options follow as their own parts. Each part builds on the one before it and targets next-dev (5ee95cc6, after #2635), so a PR shows the earlier parts' commits too. Review only the last commit of each PR (part 1 has two: Trends, then what came across from Statistics). #2621 stays open as the combined reference until the series lands.

  1. [1/6] Add a Trends screen for glucose, insulin and Loop status #2637 Trends, opened from Settings
  2. [2/6] Add a Logbook of the last 7 days #2638 Logbook, opened from Settings
  3. [3/6] Add the Now home screen with Now, Trends, Logbook and Settings tabs #2639 Now home screen with Now, Trends, Logbook and Settings tabs, and the New Interface toggle
  4. [4/6] Rebuild Add carbs around a live preview of the meal #2640 Redesigned Add carbs
  5. [5/6] Restyle the widget, Dynamic Island and Live Activity for the new interface #2641 Widget, Dynamic Island and Live Activity
  6. [6/6] Add Day and Night app icons and an appearance setting #2642 Day and Night app icons and the appearance setting

The six parts together match #2621 apart from the changes listed under "Differences from #2621" in each part.

Merging. Merged in order with merge commits, all six apply cleanly. With squash merges, each next PR needs a rebase onto next-dev once the previous one lands, because it still carries the earlier part's original commit. I've checked that every one of those rebases applies cleanly and that the end result is identical to part 6. I'll rebase each PR as the one before it merges.

Strings. Each part adds only its own catalogue entries, with their translations in Loop's languages, and fills in translations for the existing keys it starts using. GitHub's line diff of Localizable.xcstrings can show deletions where Xcode's ordering interleaves new keys. Parsed as JSON, no part removes or rewrites any existing entry.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QHnVP7ynB62LNuuYMy3yvH

Trends reviews one period at a time (a day, 7, 14, 30 or 90 days) on
one screen: summary tiles (average with SD and CV, GMI, insulin, carbs
and boluses per day, Loop active), time in range, the daily pattern
(AGP), basal and bolus, insulin per day and Loop status with its gaps.
A one-day period leads with that day's timeline. Tapping a day opens
a day page with the insulin timeline and active insulin and carbs,
stepping a day at a time. The period exports as a PDF report or a CSV
with one row per day.

Inside Loop's 7 days the figures come from Loop's own stores, so manual
and automatic boluses, temp basals, historical targets and presets are
known. Older days come from Apple Health. Closed and open loop are
recorded from launch, because Loop's automation history only covers
36 hours.

Trends opens from Settings, beside Statistics, as a sheet with its own
navigation and a Done button. Statistics and Current Setup are
unchanged.

This is part 1 of 6 splitting LoopKit#2621.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHnVP7ynB62LNuuYMy3yvH
@Nutcasey
Nutcasey force-pushed the redesign-4-add-carbs branch from 3537d7e to 3531385 Compare November 1, 2026 15:30
Nutcasey and others added 4 commits November 1, 2026 20:44
Trends now carries everything Statistics shows that it lacked, so it
can take Statistics' place:

- Consensus goals: average under 8.6 mmol/L (154 mg/dL), GMI under 7%
  and CV 36% or less under the summary tiles; time in range over 70%,
  under 25% above and 4% below, under 5% very high and 1% very low,
  and CGM active over 70% on the Time in range card.
- Scheduled basal under Basal in Basal and bolus: the schedule that
  applied over the same days (the stored profile with presets), or
  today's schedule where the profile history doesn't reach.
- "Usually X U by HH:MM": today's insulin against the median by this
  time over the last 14 days, from InsulinDeliveryHistory as on
  Statistics. Under Total so far on today's Day view, and under the
  Insulin per day chart on longer periods ending today.
- "CGM data covers 5 of 14 days." under Summary when readings start
  partway through the period.
- Typed-in (fingerstick) readings are left out of every figure, as on
  Statistics. The day timeline still draws them.

Each new line reuses a pattern already on the screen: the Aim
footnote, the indented line under Bolus, and the muted footnote.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHnVP7ynB62LNuuYMy3yvH
The Logbook lists Loop's 7 days newest first, a section per day with
its insulin and carb totals and the day's basal and bolus split.
Rows cover manual and automatic boluses, carbs, basal adjustments,
suspends and resumes, site changes and pump alarms. Runs of automatic
boluses fold into one row that opens the list of doses, and a day's
basal adjustments open as their own list. Filters narrow it to
boluses, basal, carbs or what Loop did automatically.

Carb entries can be edited or deleted with a swipe when Loop's own
carb editor would allow it, and doses can be deleted. Editing opens
Loop's existing carb entry screen in a sheet, which keeps the bolus
screen that can follow it clear of anything underneath.

The Logbook opens from Settings, beside Trends, as a sheet with its
own navigation and a Done button.

This is part 2 of 6 splitting LoopKit#2621, and builds on part 1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHnVP7ynB62LNuuYMy3yvH
Now replaces the classic status screen's HUD and charts with one
screen: the current glucose with its trend and target, Loop's state in
words, the pump and CGM, IOB, COB and the current basal against plan,
and Add carbs, Bolus and Presets. Under it, the next three hours with
Loop's prediction and today so far on one timeline. Device and Loop
problems are written out as notices that open the screen that fixes
them.

Now is StatusTableViewController's table with the new rows, so every
existing flow keeps working from it: bolus progress and cancel,
suspend and resume, alerts, presets, the insulin delivery log, carb
absorption, the prediction breakdown, pump and CGM settings, the last
Loop error, deep links and activity restoration. The last-error check
compares with Loop's last completion rather than the HUD's, as Now
has no HUD.

Trends and the Logbook become tabs. Settings stays a sheet: its tab
selects Now and presents Settings from there, as device and service
screens open through StatusTableViewController. Deep links select Now
first.

A New Interface toggle in Settings switches back to the classic status
screen with its action tabs, where Statistics, Trends and the Logbook
stay in Settings. The new interface is on by default.

This is part 3 of 6 splitting LoopKit#2621, and builds on parts 1 and 2.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHnVP7ynB62LNuuYMy3yvH
The new interface's Add carbs leads with the amount in large type over
a chart of how the meal will absorb, which redraws as the amount,
speed and eaten time change. Favourite foods sit under it as chips,
then the speed (Fast, Medium, Slow or Other with its own emoji and
time) and when it was eaten (Now, 15 or 30 minutes or an hour ago, or
an exact time). Warnings and Continue to the bolus screen are as
before. Editing a carb entry from the Logbook uses the same screen.

Choosing a speed after a favourite lets the favourite go but keeps its
amount. The view model applied a favourite selection on the next run
loop turn, which could reset an amount or speed set straight after
it; it now applies it at once, with a regression test.

The amount field follows the model whenever it doesn't already show
that amount, so a favourite fills it in even while the field still has
focus. An entry older than Loop's usual 12-hour window keeps its own
time in the eaten picker rather than showing the clamped limit. Letting
a favourite go resets the speed to Medium along with the absorption
time, so a speed chosen before the favourite can't stay highlighted
over a medium meal.

The classic interface keeps the classic carb entry screen.

This is part 4 of 6 splitting LoopKit#2621, and builds on parts 1 to 3.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHnVP7ynB62LNuuYMy3yvH
@Nutcasey
Nutcasey force-pushed the redesign-4-add-carbs branch from 3531385 to f8b498e Compare November 1, 2026 20:59
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.

1 participant