@@ -222,8 +222,8 @@ validate_environment() {
222222 die " SettingsView.swift not found at expected path."
223223 fi
224224
225- if ! grep -q ' ForEach(pluginMenuItems\.filter {\$0\.section == \.configuration}) ' " $settings_file " ; then
226- die " Anchor not found in SettingsView.swift: ForEach(pluginMenuItems.filter { \$ 0.section == .configuration})
225+ if ! grep -q ' Diabetes Treatment ' " $settings_file " ; then
226+ die " Anchor not found in SettingsView.swift: Diabetes Treatment
227227 Your Loop version may be incompatible."
228228 fi
229229
@@ -426,8 +426,10 @@ with open(settings_path, "r") as f:
426426
427427lines = content.split("\n")
428428
429- # ─── Anchor 1: Insert feature rows BEFORE the ForEach(pluginMenuItems.filter configuration) ───
430- # This is inside configurationSection. We insert FoodFinder, LoopInsights, and AutoPresets rows.
429+ # ─── Anchor 1: Insert feature rows AFTER the Therapy Settings button ───
430+ # We anchor on "Diabetes Treatment" (the Therapy Settings descriptive text) so our
431+ # features appear right after Therapy Settings. If L&L Profiles is installed, it
432+ # inserts before the ForEach — so Profiles ends up BELOW our features.
431433
432434FEATURE_ROWS = """
433435 foodFinderSettingsRow
@@ -445,7 +447,7 @@ FEATURE_ROWS = """
445447 }
446448"""
447449
448- anchor1 = 'ForEach(pluginMenuItems.filter {$0.section == .configuration}) '
450+ anchor1 = 'Diabetes Treatment '
449451anchor1_idx = None
450452for i, line in enumerate(lines):
451453 if anchor1 in line:
@@ -456,11 +458,12 @@ if anchor1_idx is None:
456458 print(f"ERROR: Anchor 1 not found: {anchor1}", file=sys.stderr)
457459 sys.exit(1)
458460
459- # Insert the feature rows BEFORE the ForEach line
461+ # Insert the feature rows AFTER the Therapy Settings descriptive text line
460462feature_lines = FEATURE_ROWS.rstrip("\n").split("\n")
463+ insert_at = anchor1_idx + 2 # after the NavigationLink closing brace (line after "Diabetes Treatment")
461464for j, fl in enumerate(feature_lines):
462- lines.insert(anchor1_idx + j, fl)
463- print(f" Inserted {len(feature_lines)} lines before ForEach anchor (line {anchor1_idx + 1})")
465+ lines.insert(insert_at + j, fl)
466+ print(f" Inserted {len(feature_lines)} lines after Therapy Settings (line {anchor1_idx + 1})")
464467
465468# ─── Anchor 2: Insert computed properties BEFORE "private var cgmChoices:" ───
466469
@@ -479,18 +482,16 @@ COMPUTED_PROPS = """
479482 }
480483
481484 private var loopInsightsSection: some View {
482- Section {
483- NavigationLink(destination: LoopInsights_SettingsView(dataStoresProvider: viewModel.loopInsightsDataStores)) {
484- LargeButton(action: {},
485- includeArrow: false,
486- imageView: Image(systemName: "brain.head.profile")
487- .resizable()
488- .aspectRatio(contentMode: .fit)
489- .foregroundColor(Color(red: 26/255, green: 138/255, blue: 158/255))
490- .frame(width: 30),
491- label: NSLocalizedString("LoopInsights", comment: "LoopInsights settings button"),
492- descriptiveText: NSLocalizedString("AI-powered therapy settings analysis", comment: "LoopInsights settings descriptive text"))
493- }
485+ NavigationLink(destination: LoopInsights_SettingsView(dataStoresProvider: viewModel.loopInsightsDataStores)) {
486+ LargeButton(action: {},
487+ includeArrow: false,
488+ imageView: Image(systemName: "brain.head.profile")
489+ .resizable()
490+ .aspectRatio(contentMode: .fit)
491+ .foregroundColor(Color(red: 26/255, green: 138/255, blue: 158/255))
492+ .frame(width: 30),
493+ label: NSLocalizedString("LoopInsights", comment: "LoopInsights settings button"),
494+ descriptiveText: NSLocalizedString("AI-powered therapy settings analysis", comment: "LoopInsights settings descriptive text"))
494495 }
495496 }
496497
@@ -669,7 +670,7 @@ cleanup() {
669670 echo -e " ${BOLD} Next steps:${NC} "
670671 echo " 1. Open LoopWorkspace.xcworkspace in Xcode"
671672 echo " 2. Build and run (Cmd+R)"
672- echo " 3. In the Loop app: Settings → enable FoodFinder / LoopInsights"
673+ echo " 3. In Loop > Settings > Enable AutoPresets / FoodFinder / LoopInsights"
673674 echo " 4. Enter your AI API key in FoodFinder Settings"
674675 echo " "
675676 echo -e " ${BOLD} To uninstall:${NC} "
0 commit comments