Add AutoPresets feature: automatically activate your Loop override presets during walking/running activity#2402
Open
taylorpatterson-T1D wants to merge 1 commit intoLoopKit:devfrom
Open
Conversation
…ivity CoreMotion-based activity detection that automatically applies user-selected override presets when walking or running is detected. 7 new files, 2 modified. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Problem That We're Solving
People with Type 1 diabetes who use Loop often need to manually activate an override preset before physical activity like walking or running. This is easy to forget, especially for spontaneous activity — a walk with the dog, touring a new city on travel, or an unplanned errand on foot. Forgetting to activate an exercise preset can lead to lows, since Loop's algorithm doesn't know the user is moving and continues dosing at normal rates.
There is currently no way in Loop to automatically respond to real-world physical activity by adjusting insulin delivery. Users must either remember to manually activate a preset before every walk or run, or accept the risk of going low. This is a big quality-of-life gap, especially for active users who move throughout the day.
New Feature's Impact
AutoPresets adds automatic, hands-free override preset activation based on real-time walking and running detection using Apple's CoreMotion framework. When the user starts walking or running, Loop detects the activity and activates the preset they've chosen for that activity type. When they stop, Loop automatically deactivates it.
What it does
User-configurable settings
How detection works
Safety considerations
TemporaryScheduleOverridesystem — no new insulin delivery pathwaysArchitecture
Loop/Loop/following Loop's layer-based architecture (Views, Managers, Models)SettingsView.swift— NavigationLink to the new settings screenLoopDataManager.swift— ~40-line delegate extension for preset activation/deactivationNew files
|
AutoPresetsSettingsView.swift|Views/| SwiftUI settings UI ||
AutoPresetsCoordinator.swift|Managers/| Main coordinator — activity detection and preset activation logic ||
AutoPresetsDelegate.swift|Managers/| Protocol for communicating with LoopDataManager ||
AutoPresetsStorage.swift|Managers/| UserDefaults persistence ||
AutoPresetsLogger.swift|Managers/| Debug logging infrastructure ||
ActivityDetectionManager.swift|Managers/| CoreMotion wrapper (CMPedometer, CMMotionActivityManager) ||
AutoPresetsModels.swift|Models/| Data models (ActivityType, Settings, LogEntry, etc.) |Screenshots
Video Demo
https://youtube.com/shorts/H45iZCnL2XQ
Test Plan
Requesting review from @marionbarker