Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
Settings can remove engines no environment uses. Only the engine an update supersedes was removed on its own, so every other one stayed until its folder was cleared by hand (asked for by Hayden on Discord). The Engine pane lists the engines that are neither the default nor any environment's engine, oldest first, with their size on disk, each with a Remove button behind a confirmation. Removing reads the environments from disk again first and keeps an engine one moved onto since. A recipe that asks for a removed engine downloads it again. EngineStore.removableEngines carries the rule and RegressionTests covers it. 592 tests pass on the M4; the pane itself was not clicked through (no Accessibility on the M4).
Gauthier Piarrette039b7dc30e96
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex 04ba43c..b9d4f8a 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -2674,6 +2674,28 @@ final class AppState {} catch { fail(error, bottle: copy) }}+ /// Engines Settings offers to remove: not the default, and no environment's engine.+ var removableEngines: [InstalledEngine] {+ EngineStore.removableEngines(installed: engines, referencedIDs: Set(bottles.map(\.settings.engineID)),+ defaultID: defaultEngine?.id)+ }++ /// Removes an engine no environment uses, after the owner confirmed it in Settings. The+ /// environments are read again from disk first, so one moved onto the engine since the list+ /// was drawn keeps it.+ func removeEngine(_ id: String) {+ guard let engine = removableEngines.first(where: { $0.id == id }) else { return }+ runBusy(String(format: L("Removing engine %@"), id)) { [self] in+ let referenced = Set(try bottleStore.list().map(\.settings.engineID))+ guard !referenced.contains(id) else {+ throw HighballError.failed("Engine \(id) is used by an environment again, so it stays.")+ }+ let root = engine.root+ try await Task.detached { try FileManager.default.removeItem(at: root) }.value+ await MainActor.run { self.appendLog("engine \(id) removed from Settings (no environment used it)"); self.refresh() }+ }+ }+func deleteBottle(_ name: String) {// The row and its Delete item stay on screen for the whole operation, so without this a// second click started a second delete and the loser reported "missing" for a delete thatdiff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swiftindex 6e5d1f2..355f4be 100644--- a/Sources/HighballApp/L10n.swift+++ b/Sources/HighballApp/L10n.swift@@ -590,6 +590,11 @@ enum L10n {"Its last run asked Windows for a fullscreen size this Mac did not switch to. That is what leaves a game small in a corner, or with the mouse landing away from what it draws. Highball can have Wine report the change as done and scale the game to the screen instead. This game only; undo it under Game settings on its page.": "Sa dernière session a demandé à Windows une résolution plein écran que ce Mac n'a pas appliquée. C'est ce qui laisse un jeu petit dans un coin, ou avec la souris qui tombe à côté de ce qui est dessiné. Highball peut faire répondre à Wine que le changement a eu lieu et adapter l'image à l'écran. Pour ce jeu seulement, annulable dans Réglages du jeu sur sa page.","Remove %@?": "Supprimer %@ ?","Remove": "Supprimer",+ "Engines no environment uses": "Moteurs qu'aucun environnement n'utilise",+ "Remove…": "Supprimer…",+ "Removing one frees its disk space. If a game asks for it again later, Highball downloads it then.": "En supprimer un libère son espace disque. Si un jeu le demande plus tard, Highball le télécharge à nouveau.",+ "Removing engine %@": "Suppression du moteur %@",+ "Remove engine %@? No environment uses it.": "Supprimer le moteur %@ ? Aucun environnement ne l'utilise.","Removing %@": "Suppression de %@","%@ removed": "%@ supprimé","Steam and the Epic tools do their own uninstalling, so their libraries stay right.": "Steam et les outils Epic font eux-mêmes la désinstallation, pour que leurs bibliothèques restent justes.",diff --git a/Sources/HighballApp/SettingsView.swift b/Sources/HighballApp/SettingsView.swiftindex bc7715b..81c6edf 100644--- a/Sources/HighballApp/SettingsView.swift+++ b/Sources/HighballApp/SettingsView.swift@@ -240,6 +240,8 @@ struct EnginePane: View {/// The updater delegate reads the same key: AppStorage so the switch redraws when flipped.@AppStorage(UpdateChannels.betaDefaultsKey) private var betaUpdates = false@State private var showLicense = false+ @State private var pendingRemove: String?+ @State private var engineSizes: [String: String] = [:]var body: some View {@Bindable var state = state@@ -295,10 +297,42 @@ struct EnginePane: View {Text(String(format: L("Installed engines: %@. An environment's engine is chosen on its own page."), state.engines.map(\.id).joined(separator: ", "))).font(.caption).foregroundStyle(.secondary)}+ let removable = state.removableEngines+ if !removable.isEmpty {+ GroupBox {+ VStack(alignment: .leading, spacing: 6) {+ Text(L("Engines no environment uses")).font(.headline)+ ForEach(removable, id: \.id) { engine in+ HStack {+ Text(engine.id).font(.caption.monospaced())+ if let size = engineSizes[engine.id] { Text(size).font(.caption).foregroundStyle(.secondary) }+ Spacer()+ Button(L("Remove…"), role: .destructive) { pendingRemove = engine.id }+ .controlSize(.small).disabled(state.busy)+ }+ }+ Text(L("Removing one frees its disk space. If a game asks for it again later, Highball downloads it then."))+ .font(.caption).foregroundStyle(.secondary)+ }.frame(maxWidth: .infinity, alignment: .leading)+ }+ .task(id: removable.map(\.id)) {+ let roots = removable.map { ($0.id, $0.root) }+ let sizes = await Task.detached {+ Dictionary(uniqueKeysWithValues: roots.map { ($0.0, ByteCountFormatter.string(fromByteCount: EngineStore.diskBytes(of: $0.1), countStyle: .file)) })+ }.value+ engineSizes = sizes+ }+ }Spacer()}.padding(20).sheet(isPresented: $showLicense) { GPTKLicenseSheet() }+ .confirmationDialog(String(format: L("Remove engine %@? No environment uses it."), pendingRemove ?? ""),+ isPresented: .init(get: { pendingRemove != nil }, set: { if !$0 { pendingRemove = nil } }),+ titleVisibility: .visible) {+ Button(L("Remove"), role: .destructive) { if let id = pendingRemove { state.removeEngine(id) }; pendingRemove = nil }+ Button(L("Cancel"), role: .cancel) { pendingRemove = nil }+ }}}diff --git a/Sources/HighballKit/EngineStore.swift b/Sources/HighballKit/EngineStore.swiftindex 399d02c..c6d4309 100644--- a/Sources/HighballKit/EngineStore.swift+++ b/Sources/HighballKit/EngineStore.swift@@ -150,6 +150,29 @@ public struct EngineStore: Sendable {return installed.first { $0.id == oldID }}+ /// The engines the owner may remove from Settings: installed, not the default, and no+ /// environment's engine. Only the engine an update supersedes goes on its own+ /// (engineToRemoveAfterUpdate), so every other one stayed until the folder was cleared by hand+ /// (Hayden asked for a way on Discord, 2026-10-23). A recipe that asks for one again+ /// downloads it then. Oldest first.+ public static func removableEngines(installed: [InstalledEngine], referencedIDs: Set<String>,+ defaultID: String?) -> [InstalledEngine] {+ installed.filter { $0.id != defaultID && !referencedIDs.contains($0.id) }+ .sorted { $0.id.compare($1.id, options: .numeric) == .orderedAscending }+ }++ /// The bytes an engine's folder takes on disk, for the Settings row. Zero when it can't be read.+ public static func diskBytes(of root: URL) -> Int64 {+ let keys: Set<URLResourceKey> = [.totalFileAllocatedSizeKey, .isRegularFileKey]+ guard let walk = FileManager.default.enumerator(at: root, includingPropertiesForKeys: Array(keys)) else { return 0 }+ var total: Int64 = 0+ for case let url as URL in walk {+ guard let values = try? url.resourceValues(forKeys: keys), values.isRegularFile == true else { continue }+ total += Int64(values.totalFileAllocatedSize ?? 0)+ }+ return total+ }+/// The engine to offer when a program fails on `currentID`: the default engine when the/// bottle is not on it (the newer one, usually), else the newest other installed engine./// nil with a single engine installed.diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex 05d6311..c6785c6 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -1011,6 +1011,22 @@ extension RegressionTests {// The same incident, second half: cleanup removed an engine the running build had never heard// of. Only the superseded default may go, and only when nothing runs on it.+ /// Hayden (Discord, 2026-10-23): no way to clear old engines out. Settings offers the ones no+ /// environment uses, never the default, oldest first.+ func testSettingsOffersOnlyEnginesNoEnvironmentUses() throws {+ func engine(_ id: String) throws -> InstalledEngine {+ let json = #"{"id":"\#(id)","displayName":"e","arch":"x86_64","minMacOS":"14.0","components":{}}"#+ return InstalledEngine(manifest: try JSONDecoder().decode(EngineManifest.self, from: Data(json.utf8)),+ root: URL(fileURLWithPath: "/tmp/\(id)"))+ }+ let all = try ["x64-sikarugir10.0_6-r28", "x64-sikarugir10.0_6-r5", "x64-crossover26.3-r27", "x64-sikarugir10.0_6-r21"].map(engine)+ let removable = EngineStore.removableEngines(installed: all, referencedIDs: ["x64-crossover26.3-r27"],+ defaultID: "x64-sikarugir10.0_6-r28").map(\.id)+ XCTAssertEqual(removable, ["x64-sikarugir10.0_6-r5", "x64-sikarugir10.0_6-r21"], "unused, oldest first")+ XCTAssertTrue(EngineStore.removableEngines(installed: all, referencedIDs: Set(all.map(\.id)), defaultID: nil).isEmpty,+ "every engine in use: nothing to offer")+ }+func testUpdateRemovesOnlyTheEngineItSuperseded() throws {func engine(_ id: String) throws -> InstalledEngine {let json = #"{"id":"\#(id)","displayName":"e","arch":"x86_64","minMacOS":"14.0","components":{}}"#