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
An engine update no longer moves a GPTK 4 environment onto the default engine
Gauthier Piarrette0d1c8200d9ad
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex c3c5f83..cc047ee 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -829,6 +829,11 @@ final class AppState {// update happened to be component-only: on 2026-09-09 a 0.8.9 build walked bottles// from the Wine 11 engine onto its Wine 10 default because r1 to r2 was same-Wine.let installedNow = try engineStore.installedEngines()+ let known = Self.knownManifests+ let shipped = Set(known.flatMap { $0.components.keys })+ // Bottles whose engine offers something the new default does not (the GPTK 4 line's+ // D3DMetal 4): they go to their own line's newest revision instead, after this loop.+ var leftBehind: [(Bottle, InstalledEngine)] = []for var bottle in try bottleStore.list() where bottle.settings.engineID != fresh.id {guard let bottleEngine = installedNow.first(where: { $0.id == bottle.settings.engineID }) else {await MainActor.run { self.appendLog("bottle '\(bottle.name)' stays on \(bottle.settings.engineID): that engine is not installed here, so this build cannot tell whether its Wine matches") }@@ -838,6 +843,12 @@ final class AppState {await MainActor.run { self.appendLog("bottle '\(bottle.name)' stays on \(bottle.settings.engineID): the new engine has a different Wine build; switch it from the bottle's settings when you want") }continue}+ let lost = EngineStore.componentsLost(from: bottleEngine.manifest, to: fresh.manifest, shipped: shipped)+ guard lost.isEmpty else {+ await MainActor.run { self.appendLog("bottle '\(bottle.name)' stays on \(bottle.settings.engineID) for now: \(fresh.id) does not carry its \(lost.joined(separator: ", "))") }+ leftBehind.append((bottle, bottleEngine))+ continue+ }let runnerOld = WineRunner(paths: paths, engine: bottleEngine, bottle: bottle)try? runnerOld.kill()try? await Task.sleep(for: .seconds(2))@@ -845,6 +856,24 @@ final class AppState {try bottle.save()await MainActor.run { self.appendLog("bottle '\(bottle.name)' moved to \(fresh.id) (same Wine, no prefix refresh needed)") }}+ for (stayed, bottleEngine) in leftBehind {+ var bottle = stayed+ guard let next = EngineStore.successor(for: bottleEngine.manifest, among: known, shipped: shipped) else { continue }+ let target: InstalledEngine+ if let have = try engineStore.installedEngines().first(where: { $0.id == next.id && $0.isComplete }) {+ target = have+ } else {+ target = try await engineStore.install(next, accepted: accepted) { name, received, total in+ Task { @MainActor in self.reportDownload(name, received: received, total: total) }+ }+ }+ let runnerOld = WineRunner(paths: paths, engine: bottleEngine, bottle: bottle)+ try? runnerOld.kill()+ try? await Task.sleep(for: .seconds(2))+ bottle.settings.engineID = target.id+ try bottle.save()+ await MainActor.run { self.appendLog("bottle '\(bottle.name)' moved to \(target.id), the newer revision of its own engine (same Wine, nothing it had is lost)") }+ }// Clean up only the engine this update superseded. Anything else stays, including an// engine this build has never heard of: a newer Highball may have installed it, and// deleting it throws away a 300 MB download and strands every bottle on it.diff --git a/Sources/HighballKit/EngineStore.swift b/Sources/HighballKit/EngineStore.swiftindex 3458b01..05c0017 100644--- a/Sources/HighballKit/EngineStore.swift+++ b/Sources/HighballKit/EngineStore.swift@@ -95,9 +95,44 @@ public struct EngineStore: Sendable {/// component-only (2026-09-09, a 0.8.9 build moved Wine 11 bottles onto its Wine 10 default/// because r1 to r2 was same-Wine, and their prefixes are a different format)./// A bottle whose engine is not installed here returns false: this build cannot tell.- public static func canMoveBottle(on bottleEngine: EngineManifest?, to fresh: EngineManifest) -> Bool {- guard let bottleEngine else { return false }- return !EngineManifest.needsPrefixRefresh(from: bottleEngine, to: fresh)+ ///+ /// Same Wine is not enough on its own: the move must also keep what the bottle's engine+ /// offers. The GPTK 4 line (r6, r12, r14) shares the default line's Wine build and adds Apple's+ /// D3DMetal 4, and 0.10.0's update walked those bottles onto the default engine, taking+ /// D3DMetal 4 away without a word. `shipped` names every component this app still ships in any+ /// of its manifests: one the bottle's engine has and `fresh` lacks holds the bottle back, unless+ /// no manifest ships it any more (lsfg, withdrawn at its author's request, must not keep r7 and+ /// r9 bottles off every later engine).+ public static func canMoveBottle(on bottleEngine: EngineManifest?, to fresh: EngineManifest, shipped: Set<String>? = nil) -> Bool {+ guard let bottleEngine, !EngineManifest.needsPrefixRefresh(from: bottleEngine, to: fresh) else { return false }+ return componentsLost(from: bottleEngine, to: fresh, shipped: shipped).isEmpty+ }++ /// The components a move from `old` to `new` would take away, among those still shipped.+ public static func componentsLost(from old: EngineManifest, to new: EngineManifest, shipped: Set<String>?) -> [String] {+ guard let shipped else { return [] }+ return old.components.keys.filter { shipped.contains($0) && new.components[$0] == nil }.sorted()+ }++ /// Where a bottle the default engine's update left behind should go instead: among `known`,+ /// a later revision of the bottle's own engine line that runs on this macOS and takes the+ /// bottle there without a first boot and without losing a shipped component. Of those, the+ /// one adding the fewest components (the same variant, not a bigger one: the default line and+ /// the GPTK 4 line share revision numbers), then the newest. A GPTK 4 bottle on r14 gets r16+ /// this way when the default moves from r13 to r15, and an r13 bottle would get r15, not r16.+ public static func successor(for bottleEngine: EngineManifest, among known: [EngineManifest],+ shipped: Set<String>, macOS: String = EngineManifest.currentMacOS) -> EngineManifest? {+ let candidates = known.filter { m in+ m.id != bottleEngine.id+ && EngineManifest.isAtOrAfter(current: m.id, wanted: bottleEngine.id)+ && m.runs(onMacOS: macOS)+ && canMoveBottle(on: bottleEngine, to: m, shipped: shipped)+ }+ func added(_ m: EngineManifest) -> Int { m.components.keys.filter { bottleEngine.components[$0] == nil }.count }+ return candidates.min { a, b in+ if added(a) != added(b) { return added(a) < added(b) }+ return a.id.compare(b.id, options: .numeric) == .orderedDescending+ }}/// The one engine an update may delete: the default it just superseded, and only when nodiff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex 75fd7cc..90fa0c8 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -943,6 +943,39 @@ extension RegressionTests {"engine not installed here: this build cannot tell, so it leaves the bottle alone")}+ // 0.10.0's update moved r12 bottles (the GPTK 4 line: the default line's Wine build plus+ // Apple's D3DMetal 4) onto r13, the default, and D3DMetal 4 was gone without a word. Same Wine+ // is not enough: a move keeps every component the app still ships. The line's own newer+ // revision is where such a bottle goes instead, and a withdrawn component (lsfg) holds nobody back.+ func testAnUpdateNeverTakesAwayAShippedComponentAndFindsTheLinesOwnSuccessor() throws {+ func manifest(_ id: String, _ names: [String], macOS: String = "14.0") throws -> EngineManifest {+ let parts = (["wine"] + names).map { #""\#($0)":{"kind":"x","url":"https://x/\#($0)","sha256":"\#($0 == "wine" ? "aaaa" : $0)"}"# }+ let json = #"{"id":"\#(id)","displayName":"e","arch":"x86_64","minMacOS":"\#(macOS)","components":{\#(parts.joined(separator: ","))}}"#+ return try JSONDecoder().decode(EngineManifest.self, from: Data(json.utf8))+ }+ let r9 = try manifest("x64-sikarugir10.0_6-r9", ["dxmt", "lsfg"])+ let r13 = try manifest("x64-sikarugir10.0_6-r13", ["dxmt"])+ let r14 = try manifest("x64-sikarugir10.0_6-r14", ["dxmt", "d3dmetal"], macOS: "27.0")+ let r15 = try manifest("x64-sikarugir10.0_6-r15", ["dxmt", "winemac"])+ let r16 = try manifest("x64-sikarugir10.0_6-r16", ["dxmt", "d3dmetal", "winemac"], macOS: "27.0")+ let known = [r13, r14, r15, r16]+ let shipped = Set(known.flatMap { $0.components.keys })++ XCTAssertTrue(EngineStore.canMoveBottle(on: r13, to: r15, shipped: shipped), "the default line moves on")+ XCTAssertFalse(EngineStore.canMoveBottle(on: r14, to: r15, shipped: shipped),+ "THE BUG: a GPTK 4 bottle must not be walked onto the default and lose D3DMetal 4")+ XCTAssertEqual(EngineStore.componentsLost(from: r14, to: r15, shipped: shipped), ["d3dmetal"])+ XCTAssertTrue(EngineStore.canMoveBottle(on: r9, to: r15, shipped: shipped),+ "lsfg ships nowhere any more, so it must not keep an r9 bottle off the default")++ XCTAssertEqual(EngineStore.successor(for: r14, among: known, shipped: shipped, macOS: "27.0")?.id, "x64-sikarugir10.0_6-r16",+ "a GPTK 4 bottle goes to its own line's newer revision")+ XCTAssertEqual(EngineStore.successor(for: r13, among: known, shipped: shipped, macOS: "27.0")?.id, "x64-sikarugir10.0_6-r15",+ "the default line shares revision numbers with GPTK 4 and must not be moved onto it")+ XCTAssertNil(EngineStore.successor(for: r14, among: known, shipped: shipped, macOS: "26.6.2"),+ "no revision of the line runs below its floor, so the bottle stays where it is")+ }+// 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.func testUpdateRemovesOnlyTheEngineItSuperseded() throws {