Conversation
RemoteCommandTracker keeps one pending/done state per key (Trio meal id or Loop sync identifier) with a 60 s timeout, and resolves it from the AID app's return push through two thin adapters: TRC by command_id, Loop by sync_identifier. Loop carb delete/edit require LoopFollow's return credentials, like Trio, since the push is the only confirmation. The detail view reads busy / failure message from the tracker and dismisses on a success transition it observes itself, so a terminal state left from an earlier visit never dismisses a freshly opened view.
An FPU child row offers Edit only when its root meal is loaded; the edit sheet is then prefilled with the root's macros and time and addresses the root's id. Delete stays available for every child and targets the whole meal. The view model builds the fpuID → root lookup once per regroup.
A Nightscout carb document from Trio is an FPU child exactly when its fpuID equals its id; a document without fpuID is a root meal.
Carbs, bolus, carb delete and carb edit share commandHeader for the otp, remote-address, notes, entered-by, sent-at, expiration and alert fields. The builders are static and take the send time, so tests pin the exact key set and values of each payload. A carb edit always carries carbs-edit-entry, carbs-edit-absorption-time and carbs-edit-start-time; carbs-edit-food-type is sent only when set.
LabeledValueRow renders the label/value rows in the treatment detail sections and both edit sheets. A Trio meal without carbs is listed as "Meal" with its fat and protein grams as subtitle. When Trio Remote Control is active but the Trio build's profile does not advertise the meal commands, the Meal section footer says a newer Trio version is needed.
A patched Loop lists carbs-delete and carbs-edit under loop.testingDetails.remoteCommands in every devicestatus upload. DeviceStatusLoop stores that list in loopRemoteCommands, clearing it when the key is absent, and the treatment detail offers the Loop carb remote actions only when both commands are advertised. With Loop APNS active but the commands missing, the carb entry section explains that the remote carb edit customization is needed.
This was referenced Sep 26, 2026
* Add ability to double-click carbs to enter Treatments screen * Keep the carb detail sheet across remounts and share carb treatment construction (#758) * Share carb Treatment construction and root-meal lookup Treatment.carb builds a carb entry for both the treatments list and the chart's detail sheet, with one id fallback for entries without a Nightscout _id. Treatment.rootMealsByFPUID and rootMeal(in:) back the FPU-child root lookup in both places. * Refresh treatments when a remote meal command completes The chart's carb marks follow a remote meal edit or delete from any screen by running the treatments task as soon as the command resolves. * Keep the carb detail sheet in the chart shell BGChartView owns the selected carb and its sheet, outside the subtree that is remounted on foregrounding, so an open sheet survives a trip to Notification Center or the background. Double-tap hit-tests carb marks only, so a nearby bolus cannot shadow the carb it sits next to. --------- Co-authored-by: Jonas Björkert <jonas@bjorkert.se>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Edit and Delete for carb entries in the Treatments detail view, for Trio (via Trio Remote Control) and Loop (via Loop APNS). Companion Trio PR: nightscout/Trio#1579. Loop needs the remote_carb_edit customization: loopandlearn/customization#87.
Thanks to @aug0211 for #742, which shaped what this needed to cover. This takes the same idea with a smaller protocol.
Trio
id, for a meal root or any of its FPU entries. FPU rows show which meal they belong to and link to the root; editing from an FPU row uses the root's values.delete_meal/edit_mealin its Nightscout profile. Older Trio builds get a footer saying a newer version is needed.command_typeedit_meal/delete_meal,meal_id,command_id(also the APNs collapse id), and for edit explicitcarbs,fat,protein,scheduled_time.Loop
syncIdentifier. Delete sendscarbs-delete; edit sendscarbs-editwithcarbs-edit-entry,carbs-edit-absorption-time,carbs-edit-start-time(always) andcarbs-edit-food-type(when set). OTP,sent-atandexpirationas for carbs today.loop.testingDetails.remoteCommands), which the customization does every loop cycle. Otherwise a footer says the customization is needed.Acks
One
RemoteCommandTrackerkeyed by meal id or syncIdentifier: pending → done, 60 s timeout, then the list refreshes. Trio acks match oncommand_id, Loop acks onsync_identifier. Both paths require LoopFollow's own APNS credentials so the app can confirm the result.Other
id,fpuID, fat, protein and note for Trio entries andsyncIdentifierfor Loop entries.MealViewand reused by the edit sheet; prefilled values stay editable above the guardrail maxima.LOOPFOLLOW_APNS_BASE_URLfor a local APNs stand-in.Verified in the simulator against a mock Nightscout and a fake APNs endpoint, with acks delivered via
simctl push: delete and edit for Trio and Loop, not_found, timeout, the FPU-child edit path, and gating by profile, device and remote type.Screenshots
Trio
Loop