From 0f32a8ee33a62e7d516c0a3dc48fb3c1ed9f75f9 Mon Sep 17 00:00:00 2001 From: Cryptokid92 <114345066+Cryptokid92@users.noreply.github.com> Date: Sat, 29 Aug 2026 23:10:51 +0200 Subject: [PATCH 1/5] feat(macutil): group Tweaks by category Tweaks tab groups Safe and Caution rows by Tweak.Category. Safe and Caution stay separate. Empty Apply writes nothing. --- MacUtilGUI/ViewModels/TweakGroupViewModel.fs | 22 ++++++++++++++++++++ MacUtilGUI/ViewModels/TweakRowViewModel.fs | 1 + 2 files changed, 23 insertions(+) create mode 100644 MacUtilGUI/ViewModels/TweakGroupViewModel.fs diff --git a/MacUtilGUI/ViewModels/TweakGroupViewModel.fs b/MacUtilGUI/ViewModels/TweakGroupViewModel.fs new file mode 100644 index 0000000..1d91b93 --- /dev/null +++ b/MacUtilGUI/ViewModels/TweakGroupViewModel.fs @@ -0,0 +1,22 @@ +namespace MacUtilGUI.ViewModels + +open System.Collections.ObjectModel + +type TweakGroupViewModel(name: string, rows: TweakRowViewModel seq) = + inherit ViewModelBase() + + let tweaks = ObservableCollection(rows) + + member _.Name = name + + member _.Tweaks = tweaks + + member this.AllSelected + with get () = + tweaks.Count > 0 + && Seq.forall (fun (row: TweakRowViewModel) -> row.IsChecked) tweaks + and set v = + for row in tweaks do + row.IsChecked <- v + + this.OnPropertyChanged("AllSelected") diff --git a/MacUtilGUI/ViewModels/TweakRowViewModel.fs b/MacUtilGUI/ViewModels/TweakRowViewModel.fs index 388871a..a44ba8c 100644 --- a/MacUtilGUI/ViewModels/TweakRowViewModel.fs +++ b/MacUtilGUI/ViewModels/TweakRowViewModel.fs @@ -10,6 +10,7 @@ type TweakRowViewModel(tweak: Tweak, isChecked: bool) = member _.Id = tweak.Id member _.Content = tweak.Content member _.Description = tweak.Description + member _.Category = tweak.Category member _.Tweak = tweak member this.IsChecked From 4965d2146f246d00a3afba0246b07d79f06c2623 Mon Sep 17 00:00:00 2001 From: Cryptokid92 <114345066+Cryptokid92@users.noreply.github.com> Date: Sat, 29 Aug 2026 23:11:39 +0200 Subject: [PATCH 2/5] feat(macutil): compile TweakGroupViewModel before MainWindowViewModel --- MacUtilGUI/MacUtilGUI.fsproj | 1 + 1 file changed, 1 insertion(+) diff --git a/MacUtilGUI/MacUtilGUI.fsproj b/MacUtilGUI/MacUtilGUI.fsproj index 9566ce7..c95a463 100644 --- a/MacUtilGUI/MacUtilGUI.fsproj +++ b/MacUtilGUI/MacUtilGUI.fsproj @@ -52,6 +52,7 @@ + From 14b287e68dd974ea88f2f719f9b05f0cc06c303e Mon Sep 17 00:00:00 2001 From: Cryptokid92 <114345066+Cryptokid92@users.noreply.github.com> Date: Sat, 29 Aug 2026 23:12:40 +0200 Subject: [PATCH 3/5] test(macutil): add TweakGroupsByCategory --- MacUtilGUI.Tests/TweakTabTests.fs | 95 +++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/MacUtilGUI.Tests/TweakTabTests.fs b/MacUtilGUI.Tests/TweakTabTests.fs index 04c85d0..e14a21d 100644 --- a/MacUtilGUI.Tests/TweakTabTests.fs +++ b/MacUtilGUI.Tests/TweakTabTests.fs @@ -1,5 +1,7 @@ namespace MacUtilGUI.Tests +open System +open System.IO open Xunit open MacUtilGUI.Models open MacUtilGUI.Services @@ -24,6 +26,24 @@ module TweakTabTests = for row in vm.CautionTweaks do row.IsChecked <- false + let private repoRoot () = + let rec walk dir = + if String.IsNullOrEmpty dir then + None + elif File.Exists(Path.Combine(dir, "MacUtilGUI", "Views", "MainWindow.axaml")) then + Some dir + else + let parent = Directory.GetParent dir + + if isNull parent then None else walk parent.FullName + + match walk AppContext.BaseDirectory with + | Some dir -> dir + | None -> + match walk (Directory.GetCurrentDirectory()) with + | Some dir -> dir + | None -> failwith "repo root not found" + [] let TweakRowUncheckedWhenAbsent () = let client = FakeDefaultsClient() @@ -84,3 +104,78 @@ module TweakTabTests = Assert.True(client.Read("com.apple.finder", "ShowPathbar").IsNone) Assert.False(pathBar.IsChecked) Assert.True(ActionEngine.detect client extensions.Tweak) + + [] + let TweakGroupsByCategory () = + let client = FakeDefaultsClient() + let vm = makeVm client + + let safeNames = + vm.SafeTweakGroups |> Seq.map (fun group -> group.Name) |> Seq.toList + + Assert.Equal([ "Finder"; "Dock"; "Keyboard"; "Screenshots"; "Privacy" ], safeNames) + + let cautionNames = + vm.CautionTweakGroups |> Seq.map (fun group -> group.Name) |> Seq.toList + + Assert.Equal([ "Keyboard"; "Screenshots"; "Privacy" ], cautionNames) + + Assert.Equal(vm.SafeTweaks.Count, vm.SafeTweakGroups |> Seq.sumBy (fun group -> group.Tweaks.Count)) + Assert.Equal(vm.CautionTweaks.Count, vm.CautionTweakGroups |> Seq.sumBy (fun group -> group.Tweaks.Count)) + + Assert.False( + vm.CautionTweakGroups + |> Seq.exists (fun group -> group.Name = "Finder" || group.Name = "Dock") + ) + + let groupedSafe = + vm.SafeTweakGroups |> Seq.collect (fun group -> group.Tweaks) |> Seq.toList + + Assert.Equal(vm.SafeTweaks.Count, groupedSafe.Length) + + for row in vm.SafeTweaks do + Assert.Contains(row, groupedSafe) + + let finder = vm.SafeTweakGroups |> Seq.find (fun group -> group.Name = "Finder") + finder.AllSelected <- true + Assert.True(finder.Tweaks |> Seq.forall (fun row -> row.IsChecked)) + Assert.True(finder.AllSelected) + + for row in vm.CautionTweaks do + Assert.False(row.IsChecked) + + finder.AllSelected <- false + Assert.True(finder.Tweaks |> Seq.forall (fun row -> not row.IsChecked)) + Assert.False(finder.AllSelected) + + vm.SelectStandard() + let standard = Set.ofList (catalog ()).Presets.["Standard"] + + for row in vm.SafeTweaks do + Assert.Equal(standard.Contains row.Id, row.IsChecked) + + if row.IsChecked then + Assert.True(row.Category = "Finder" || row.Category = "Dock") + + for row in vm.CautionTweaks do + Assert.False(row.IsChecked) + + uncheckAll vm + let writesBefore = client.WriteCount + vm.ApplySelected() + Assert.Equal(writesBefore, client.WriteCount) + Assert.Equal("Nothing is selected.", vm.StatusText) + Assert.Empty(vm.SelectedIds) + + let axaml = + File.ReadAllText(Path.Combine(repoRoot (), "MacUtilGUI", "Views", "MainWindow.axaml")) + + Assert.Contains("SafeTweakGroups", axaml) + Assert.Contains("CautionTweakGroups", axaml) + Assert.Contains("TweakGroupViewModel", axaml) + Assert.DoesNotContain("ItemsSource=\"{Binding SafeTweaks}\"", axaml) + Assert.DoesNotContain("ItemsSource=\"{Binding CautionTweaks}\"", axaml) + Assert.Contains("ItemsSource=\"{Binding AppGroups}\"", axaml) + Assert.Contains("Maintenance", axaml) + Assert.Contains("Updates", axaml) + Assert.Contains("#1C1C1E", axaml) From bf811313e03c8f4131d18dbdccdc106f6e0b5bf7 Mon Sep 17 00:00:00 2001 From: Cryptokid92 <114345066+Cryptokid92@users.noreply.github.com> Date: Sat, 29 Aug 2026 23:44:33 +0200 Subject: [PATCH 4/5] feat(macutil): group Safe and Caution tweaks by Category --- MacUtilGUI/ViewModels/MainWindowViewModel.fs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MacUtilGUI/ViewModels/MainWindowViewModel.fs b/MacUtilGUI/ViewModels/MainWindowViewModel.fs index 9e34bb4..4dbb78b 100644 --- a/MacUtilGUI/ViewModels/MainWindowViewModel.fs +++ b/MacUtilGUI/ViewModels/MainWindowViewModel.fs @@ -34,6 +34,8 @@ type MainWindowViewModel let mutable searchText: string = "" let safeTweaks = ObservableCollection() let cautionTweaks = ObservableCollection() + let safeTweakGroups = ObservableCollection() + let cautionTweakGroups = ObservableCollection() let allApps = ResizeArray() let apps = ObservableCollection() let appGroups = ObservableCollection() @@ -232,6 +234,12 @@ type MainWindowViewModel | "Privacy" -> 4 | _ -> 5 + let fillTweakGroups (source: TweakRowViewModel seq) (target: ObservableCollection) = + source + |> Seq.groupBy (fun (row: TweakRowViewModel) -> row.Category) + |> Seq.sortBy (fun (category, _) -> categoryRank category, category) + |> Seq.iter (fun (category, rows) -> target.Add(TweakGroupViewModel(category, rows))) + do catalog.Tweaks |> Map.toSeq @@ -244,6 +252,9 @@ type MainWindowViewModel | Risk.Safe -> safeTweaks.Add(row) | Risk.Caution -> cautionTweaks.Add(row)) + fillTweakGroups safeTweaks safeTweakGroups + fillTweakGroups cautionTweaks cautionTweakGroups + catalog.Apps |> Map.toSeq |> Seq.map snd @@ -277,6 +288,10 @@ type MainWindowViewModel member _.CautionTweaks = cautionTweaks + member _.SafeTweakGroups = safeTweakGroups + + member _.CautionTweakGroups = cautionTweakGroups + member _.Apps = apps member _.AppGroups = appGroups From 9b718b1aa9b1f4fbdeee6d91225645c98a94964f Mon Sep 17 00:00:00 2001 From: Cryptokid92 <114345066+Cryptokid92@users.noreply.github.com> Date: Sun, 30 Aug 2026 00:01:43 +0200 Subject: [PATCH 5/5] feat(macutil): bind Tweaks expanders to category groups --- MacUtilGUI/Views/MainWindow.axaml | 94 +++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 24 deletions(-) diff --git a/MacUtilGUI/Views/MainWindow.axaml b/MacUtilGUI/Views/MainWindow.axaml index 09e6d95..52684f3 100644 --- a/MacUtilGUI/Views/MainWindow.axaml +++ b/MacUtilGUI/Views/MainWindow.axaml @@ -49,20 +49,43 @@ Classes="macos-title" FontSize="18" Margin="0,0,0,12"/> - + - - + - - - - - + + + + + + + + + + + + + + + + + + + @@ -70,20 +93,43 @@ Classes="macos-caution" FontSize="16" Margin="0,20,0,12"/> - + - - + - - - - - + + + + + + + + + + + + + + + + + + +