diff --git a/App/AppState.swift b/App/AppState.swift index abc0717..c1aa479 100644 --- a/App/AppState.swift +++ b/App/AppState.swift @@ -38,11 +38,17 @@ final class AppState { } } + /// A user-configured binary path from settings, or nil to auto-detect (empty = auto). + static func storedPath(_ key: String) -> String? { + let value = UserDefaults.standard.string(forKey: key) + return (value?.isEmpty == false) ? value : nil + } + init( containerEngine: ContainerEngine = SDKContainerEngine(), - composeEngine: ComposeEngine = CLIComposeEngine(), - serviceHealth: ServiceHealthChecking = CLIServiceHealth(), - creator: ContainerCreating = CLIContainerCreator(), + composeEngine: ComposeEngine = CLIComposeEngine(binaryPath: AppState.storedPath("composeBinaryPath")), + serviceHealth: ServiceHealthChecking = CLIServiceHealth(binaryPath: AppState.storedPath("containerBinaryPath")), + creator: ContainerCreating = CLIContainerCreator(binaryPath: AppState.storedPath("containerBinaryPath")), store: RegistryStore = RegistryStore() ) { self.containerEngine = containerEngine diff --git a/App/Views/SettingsWindow.swift b/App/Views/SettingsWindow.swift index d6b075f..dbda8de 100644 --- a/App/Views/SettingsWindow.swift +++ b/App/Views/SettingsWindow.swift @@ -8,6 +8,8 @@ struct SettingsWindow: View { @AppStorage("pollOpen") private var pollOpen = 2.0 @AppStorage("pollClosed") private var pollClosed = 15.0 @AppStorage("groupByNamePrefix") private var groupByNamePrefix = false + @AppStorage("containerBinaryPath") private var containerBinaryPath = "" + @AppStorage("composeBinaryPath") private var composeBinaryPath = "" @State private var working = false var body: some View { @@ -39,6 +41,17 @@ struct SettingsWindow: View { } } + Section("Binaries") { + LabeledContent("container") { + TextField("auto-detected", text: $containerBinaryPath).frame(maxWidth: 240) + } + LabeledContent("container-compose") { + TextField("auto-detected", text: $composeBinaryPath).frame(maxWidth: 240) + } + Text("Override only if your binaries aren't in a standard location. Empty = auto-detect. Applies on relaunch.") + .font(.caption).foregroundStyle(.secondary) + } + Section("Stacks") { Toggle("Group external containers by name prefix", isOn: $groupByNamePrefix) Text("Off: only stacks you launch through Consai are grouped (reliable). On: containers that share a `name-` prefix are grouped as inferred stacks — can mis-group unrelated containers.")