Centralize override and temp target activation - #1482
Open
bjorkert wants to merge 1 commit into
Open
Conversation
Every entry point routes activation and cancellation through AdjustmentManager, which performs the whole sequence in one Core Data transaction: end every enabled adjustment and record each as a run entry, enable the requested one, then apply the side effects in a fixed order. Commands are serialized, so two arriving at once cannot interleave. The run entry carries the elapsed duration to Nightscout and draws the finished band on the home chart. uploadOverrideRuns deletes the entry at the run's own created_at and re-posts it there, so the cleanup holds for a preset row whose date moves on every activation, and the run upload window keys on endDate so an adjustment that ran for more than a day still retracts its placeholder. deleteNightscoutOverride filters on event type. APSManager.recomputeDetermination() claims the loop guard for a determination-only run. It yields to the loop, which it never delays, and both the manager and the Adjustments view models go through it. A custom, non-preset adjustment is stored disabled and activated by object ID, so storeTempTarget returns the inserted row's NSManagedObjectID. The watch acknowledges a command from the returned outcome, and its failure acknowledgment applies only to messages carrying none of the recognized payloads. A remote cancel with nothing running is the state the command asked for.
bjorkert
requested review from
AndreasStokholm,
MikePlante1,
Sjoerd-Bo3,
bjornoleh,
dnzxy,
kingst,
marionbarker,
marv-out and
t1dude
as code owners
September 8, 2026 17:59
Contributor
Not sure if I read this correctly, but does this mean it will also fix #1146? |
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.
This rewrite was done because overrides activated from the watch were not sent to Nightscout until they were cancelled. The change has successfully been tested in real-world use for several days with no issues.
Every entry point routes activation and cancellation through AdjustmentManager, which performs the whole sequence in one Core Data transaction: end every enabled adjustment and record each as a run entry, enable the requested one, then apply the side effects in a fixed order. Commands are serialized, so two arriving at once cannot interleave.
The run entry carries the elapsed duration to Nightscout and draws the finished band on the home chart. uploadOverrideRuns deletes the entry at the run's own created_at and re-posts it there, so the cleanup holds for a preset row whose date moves on every activation, and the run upload window keys on endDate so an adjustment that ran for more than a day still retracts its placeholder. deleteNightscoutOverride filters on event type.
APSManager.recomputeDetermination() claims the loop guard for a determination-only run. It yields to the loop, which it never delays, and both the manager and the Adjustments view models go through it.
A custom, non-preset adjustment is stored disabled and activated by object ID, so storeTempTarget returns the inserted row's NSManagedObjectID.
The watch acknowledges a command from the returned outcome, and its failure acknowledgment applies only to messages carrying none of the recognized payloads. A remote cancel with nothing running is the state the command asked for.