Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fcdc4bb
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 29, 2026
6497439
fix(macutil): drop unused App.axaml panel styles
Cryptokid92 Aug 29, 2026
5d9f5e3
fix(macutil): split status by AppTab
Cryptokid92 Aug 29, 2026
ea382f5
fix(macutil): bind each tab footer to its own status
Cryptokid92 Aug 29, 2026
1b5735a
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 29, 2026
55419f8
test(macutil): prove per-tab status and trim-safe export
Cryptokid92 Aug 29, 2026
bab9676
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 29, 2026
6cb72db
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 29, 2026
3eacab4
test(macutil): add ExportTrimSafe and PerTabStatusDoesNotLeak
Cryptokid92 Aug 29, 2026
bd9c7cd
test(macutil): add ExportTrimSafe and PerTabStatusDoesNotLeak
Cryptokid92 Aug 29, 2026
4c0cfa5
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 29, 2026
c4034ee
test(macutil): cover per-tab status and trim-safe export
Cryptokid92 Aug 29, 2026
c8bf34f
test(macutil): prove exportIds without reflection Serialize
Cryptokid92 Aug 29, 2026
51b2bba
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 29, 2026
968e90d
test(macutil): assert per-tab status does not leak
Cryptokid92 Aug 29, 2026
54b4a7f
test(macutil): lock Utf8JsonWriter export against trimmed reflection
Cryptokid92 Aug 29, 2026
adaebee
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 30, 2026
f8b0e56
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 30, 2026
891c951
test(macutil): fix triple-quoted JSON fixtures in ExportTrimSafe
Cryptokid92 Aug 30, 2026
51972f0
fix(macutil): per-tab status and trim-safe export
Cryptokid92 Aug 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions MacUtilGUI.Tests/InstallTabTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ module InstallTabTests =

vm.InstallSelected()
Assert.Empty(brew.InstallCalls)
Assert.Equal("Nothing is selected.", vm.StatusText)
Assert.Equal("Nothing is selected.", vm.InstallStatus)
Assert.Equal("", vm.TweaksStatus)
Assert.Empty(vm.SelectedAppIds)

[<Fact>]
Expand All @@ -60,7 +61,8 @@ module InstallTabTests =

vm.UninstallSelected()
Assert.Empty(brew.UninstallCalls)
Assert.Equal("Nothing is selected.", vm.StatusText)
Assert.Equal("Nothing is selected.", vm.InstallStatus)
Assert.Equal("", vm.TweaksStatus)
Assert.Empty(vm.SelectedAppIds)

[<Fact>]
Expand Down
1 change: 1 addition & 0 deletions MacUtilGUI.Tests/MacUtilGUI.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion MacUtilGUI.Tests/MaintenanceTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ module MaintenanceTests =
let brew = RecordingBrew("/tmp/macutil-not-used")
let vm = makeVm brew
vm.RunBrewCleanup()
Assert.Equal("Ran brew cleanup.", vm.StatusText)
Assert.Equal("Ran brew cleanup.", vm.MaintenanceStatus)
Assert.Equal("", vm.TweaksStatus)
Assert.Equal("", vm.InstallStatus)
Assert.Equal(1, brew.CleanupCalls.Length)
Assert.NotEmpty(vm.SafeTweaks)
Assert.Equal(26, Seq.length vm.AllApps)
Expand Down
75 changes: 74 additions & 1 deletion MacUtilGUI.Tests/PresetTests.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace MacUtilGUI.Tests

open System
open System.IO
open System.Text.Json
open System.Text.Json.Nodes
open Xunit
open MacUtilGUI.Models
Expand Down Expand Up @@ -86,7 +88,8 @@ module PresetTests =
Assert.False(vm.ImportJson json)
Assert.True(pathBar.IsChecked)
Assert.Equal(writesBefore, client.WriteCount)
Assert.Contains("Unknown tweak id", vm.StatusText)
Assert.Contains("Unknown tweak id", vm.TweaksStatus)
Assert.Equal("", vm.InstallStatus)

let path = Path.GetTempFileName()
File.WriteAllText(path, json)
Expand Down Expand Up @@ -159,3 +162,73 @@ module PresetTests =
Assert.True(vm.ImportJson json)
Assert.True((findRow vm.SafeTweaks "finder-path-bar").IsChecked)
Assert.False((findRow vm.SafeTweaks "finder-show-hidden").IsChecked)

let private findPresetService () =
let rec walk dir =
if String.IsNullOrEmpty dir then
None
else
let candidate = Path.Combine(dir, "MacUtilGUI", "Services", "PresetService.fs")

if File.Exists candidate then
Some candidate
else
let parent = Directory.GetParent dir

if isNull parent then None else walk parent.FullName

match walk AppContext.BaseDirectory with
| Some path -> path
| None ->
match walk (Directory.GetCurrentDirectory()) with
| Some path -> path
| None -> failwith "PresetService.fs not found"

[<Fact>]
let ExportTrimSafe () =
let loaded = catalog ()
let ids = [ "finder-path-bar"; "finder-show-extensions" ]
let json = PresetService.exportIds ids
Assert.Equal("""["finder-path-bar","finder-show-extensions"]""", json)

match PresetService.parseImport loaded json with
| Ok parsed -> Assert.Equal<string list>(ids, parsed)
| Error msg -> Assert.Fail msg

Assert.Equal("[]", PresetService.exportIds [])

let quoted = PresetService.exportIds [ "quote\"slash\\" ]
use doc = JsonDocument.Parse(quoted)
Assert.Equal(JsonValueKind.Array, doc.RootElement.ValueKind)
let quotedEl = doc.RootElement.EnumerateArray() |> Seq.exactlyOne
Assert.Equal("quote\"slash\\", quotedEl.GetString())

let src = File.ReadAllText(findPresetService ())
Assert.DoesNotContain("JsonSerializer.Serialize", src)
Assert.Contains("Utf8JsonWriter", src)

let reflectionThrew =
try
JsonSerializer.Serialize([| "finder-path-bar" |]) |> ignore
false
with
| :? NotSupportedException -> true
| :? InvalidOperationException as ex -> ex.Message.Contains("Reflection-based serialization")

Assert.True(reflectionThrew, "reflection Serialize of string[] must be disabled")

let client = FakeDefaultsClient()
let killer = FakeProcessKiller()
ActionEngine.apply client killer loaded.Tweaks.["finder-path-bar"]
let code, stdout, err = runCli loaded client killer [| "export" |]
Assert.Equal(0, code)
Assert.Equal("", err)
use exported = JsonDocument.Parse(stdout.Trim())
Assert.Equal(JsonValueKind.Array, exported.RootElement.ValueKind)

let cliIds =
exported.RootElement.EnumerateArray()
|> Seq.map (fun el -> el.GetString())
|> Set.ofSeq

Assert.Contains("finder-path-bar", cliIds)
41 changes: 39 additions & 2 deletions MacUtilGUI.Tests/TweakTabTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ module TweakTabTests =
let writesBefore = client.WriteCount
vm.ApplySelected()
Assert.Equal(writesBefore, client.WriteCount)
Assert.Equal("Nothing is selected.", vm.StatusText)
Assert.Equal("Nothing is selected.", vm.TweaksStatus)
Assert.Equal("", vm.InstallStatus)
Assert.Empty(vm.SelectedIds)

let pathBar = findRow vm.SafeTweaks "finder-path-bar"
Expand Down Expand Up @@ -164,7 +165,8 @@ module TweakTabTests =
let writesBefore = client.WriteCount
vm.ApplySelected()
Assert.Equal(writesBefore, client.WriteCount)
Assert.Equal("Nothing is selected.", vm.StatusText)
Assert.Equal("Nothing is selected.", vm.TweaksStatus)
Assert.Equal("", vm.InstallStatus)
Assert.Empty(vm.SelectedIds)

let axaml =
Expand All @@ -179,3 +181,38 @@ module TweakTabTests =
Assert.Contains("Maintenance", axaml)
Assert.Contains("Updates", axaml)
Assert.Contains("#1C1C1E", axaml)
Assert.Contains("{Binding TweaksStatus}", axaml)
Assert.Contains("{Binding InstallStatus}", axaml)
Assert.Contains("{Binding MaintenanceStatus}", axaml)
Assert.Contains("{Binding UpdatesStatus}", axaml)
Assert.DoesNotContain("{Binding StatusText}", axaml)

let appAxaml =
File.ReadAllText(Path.Combine(repoRoot (), "MacUtilGUI", "App.axaml"))

Assert.DoesNotContain("macos-terminal", appAxaml)
Assert.DoesNotContain("macos-left-panel", appAxaml)
Assert.DoesNotContain("macos-right-panel", appAxaml)

[<Fact>]
let PerTabStatusDoesNotLeak () =
let client = FakeDefaultsClient()
let vm = makeVm client
uncheckAll vm

let pathBar = findRow vm.SafeTweaks "finder-path-bar"
pathBar.IsChecked <- true
vm.ApplySelected()
Assert.Equal("Applied 1 tweak(s).", vm.TweaksStatus)
Assert.Equal("", vm.InstallStatus)
Assert.Equal("", vm.MaintenanceStatus)
Assert.Equal("", vm.UpdatesStatus)

for row in vm.AllApps do
row.IsChecked <- false

vm.InstallSelected()
Assert.Equal("Nothing is selected.", vm.InstallStatus)
Assert.Equal("Applied 1 tweak(s).", vm.TweaksStatus)
Assert.Equal("", vm.MaintenanceStatus)
Assert.Equal("", vm.UpdatesStatus)
6 changes: 4 additions & 2 deletions MacUtilGUI.Tests/UpdateServiceTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,15 @@ module UpdateServiceTests =

vm.UpdateHomebrew()
Assert.Empty(brew.UpgradeCalls)
Assert.Equal("Nothing is selected.", vm.StatusText)
Assert.Equal("Nothing is selected.", vm.UpdatesStatus)
Assert.Equal("", vm.TweaksStatus)

let wget = Seq.exactlyOne vm.BrewOutdated
wget.IsChecked <- true
vm.UpdateHomebrew()
Assert.Equal<string list>([ [ "upgrade"; "wget" ] ], brew.UpgradeCalls)
Assert.Equal("Updated 1 Homebrew package(s).", vm.StatusText)
Assert.Equal("Updated 1 Homebrew package(s).", vm.UpdatesStatus)
Assert.Equal("", vm.InstallStatus)

let axaml =
File.ReadAllText(Path.Combine(root, "MacUtilGUI", "Views", "MainWindow.axaml"))
Expand Down
24 changes: 0 additions & 24 deletions MacUtilGUI/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@
<Setter Property="FontWeight" Value="Medium"/>
</Style>

<!-- Terminal styles (identical in both themes) -->
<Style Selector="ScrollViewer.macos-terminal">
<Setter Property="Background" Value="#000000"/>
</Style>

<Style Selector="TextBlock.macos-terminal">
<Setter Property="Background" Value="#000000"/>
<Setter Property="Foreground" Value="#00FF00"/>
<Setter Property="FontFamily" Value="SF Mono,Monaco,Inconsolata,Consolas,monospace"/>
<Setter Property="FontSize" Value="13"/>
</Style>

<!-- macOS Window Controls -->
<Style Selector="Button.macos-window-control">
<Setter Property="BorderThickness" Value="0"/>
Expand All @@ -84,18 +72,6 @@
<Setter Property="BoxShadow" Value="0 1 3 0 #00000075"/>
</Style>

<Style Selector="Border.macos-left-panel">
<Setter Property="Background" Value="#772C2C2E"/>
<Setter Property="BorderBrush" Value="#CC3A3A3C"/>
<Setter Property="BoxShadow" Value="0 1 3 0 #00000000"/>
</Style>

<Style Selector="Border.macos-right-panel">
<Setter Property="Background" Value="#992C2C2E"/>
<Setter Property="BorderBrush" Value="#CC3A3A3C"/>
<Setter Property="BoxShadow" Value="0 1 3 0 #00000000"/>
</Style>

<Style Selector="Border.macos-content">
<Setter Property="Background" Value="#0D1C1C1E"/>
<Setter Property="BorderBrush" Value="#403A3A3C"/>
Expand Down
13 changes: 12 additions & 1 deletion MacUtilGUI/Services/PresetService.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace MacUtilGUI.Services

open System
open System.IO
open System.Text
open System.Text.Json
open System.Text.Json.Nodes
open MacUtilGUI.Models
Expand All @@ -13,7 +15,16 @@ module PresetService =
| None -> Error $"Unknown preset '{name}'"

let exportIds (ids: string list) =
JsonSerializer.Serialize(Array.ofList ids)
use stream = new MemoryStream()
use writer = new Utf8JsonWriter(stream)
writer.WriteStartArray()

for id in ids do
writer.WriteStringValue id

writer.WriteEndArray()
writer.Flush()
Encoding.UTF8.GetString(stream.ToArray())

let parseImport (catalog: Catalog) (json: string) =
try
Expand Down
Loading
Loading