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
Show the last launch log opens the log a Steam game's lines are in. For a Steam game it opened the environment's newest steam.exe log, and a steam.exe asked of a Steam that already runs (opening Steam's window, a Play the running client serves) hands the request over and exits at once, leaving a log of only its header and exit line. A player who opened Steam again after Forza Horizon 5 crashed got exactly that empty log instead of the crash (2026-10-07). The page now opens the newest log with output, which is the client the game ran under, and falls back to the newest when none has any. The had-problems flow reads the same log for its fullscreen-size check. Checked against the M4's real logs: the steam://validate hand-off has only header lines, every client log has output. 492 tests green (2026-10-07).
Gauthier Piarrette1edc452f4146
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex a224c3e..2c05357 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -2009,7 +2009,12 @@ final class AppState {default: return nil}let names = (try? FileManager.default.contentsOfDirectory(atPath: paths.logs.path)) ?? []- return LaunchLogs.newest(names: names, bottle: bottleName, executable: executable).map { paths.logs.appending(path: $0) }+ // A Steam game's lines are in the log of the client that ran it, not in the empty one a+ // later "open Steam" handed over to that client (LaunchLogs.newestWithOutput).+ let name = item.source == .steam+ ? LaunchLogs.newestWithOutput(names: names, bottle: bottleName, executable: executable) { LaunchLogs.hasOutput(paths.logs.appending(path: $0)) }+ : LaunchLogs.newest(names: names, bottle: bottleName, executable: executable)+ return name.map { paths.logs.appending(path: $0) }}private var sessionWatchers: [UUID: Task<Void, Never>] = [:]diff --git a/Sources/HighballKit/EnvText.swift b/Sources/HighballKit/EnvText.swiftindex ff26ba4..15b2037 100644--- a/Sources/HighballKit/EnvText.swift+++ b/Sources/HighballKit/EnvText.swift@@ -72,6 +72,31 @@ public extension BottleSettings {/// share a second. The stamp sorts, so the newest name is the newest launch.public enum LaunchLogs {public static func newest(names: [String], bottle: String, executable: String) -> String? {+ newestFirst(names: names, bottle: bottle, executable: executable).first+ }++ /// The newest of these logs that holds program output, else the newest. steam.exe asked of a+ /// Steam that already runs hands the request over and exits at once, leaving a log of its+ /// header and exit line only, while the game's lines go to the log of the client that serves+ /// it. Opening Steam's window after a crash made "Show the last launch log" open such an+ /// empty log instead of the crash (a player's Forza Horizon 5 log, 2026-10-07).+ public static func newestWithOutput(names: [String], bottle: String, executable: String,+ hasOutput: (String) -> Bool) -> String? {+ let logs = newestFirst(names: names, bottle: bottle, executable: executable)+ return logs.first(where: hasOutput) ?? logs.first+ }++ /// True when the log has a line besides the header and the exit line, which start with "#".+ /// Only the first 64 KB are read: a header is a few hundred bytes.+ public static func hasOutput(_ url: URL) -> Bool {+ guard let handle = try? FileHandle(forReadingFrom: url) else { return false }+ defer { try? handle.close() }+ let text = String(decoding: (try? handle.read(upToCount: 65_536)) ?? Data(), as: UTF8.self)+ return text.split(whereSeparator: \.isNewline).contains { !$0.hasPrefix("#") && !$0.allSatisfy(\.isWhitespace) }+ }++ /// One program's logs in one environment, newest first.+ static func newestFirst(names: [String], bottle: String, executable: String) -> [String] {let mid = "-\(bottle)-\(executable)"let pattern = "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{6}Z" + NSRegularExpression.escapedPattern(for: mid) + "(-[0-9]+)?\\.log$"// "-2.log" follows ".log" inside one second, which plain string order gets backwards.@@ -83,6 +108,6 @@ public enum LaunchLogs {return (stem, 1)}return names.filter { $0.range(of: pattern, options: .regularExpression) != nil }- .max { a, b in let ka = key(a), kb = key(b); return ka.0 == kb.0 ? ka.1 < kb.1 : ka.0 < kb.0 }+ .sorted { a, b in let ka = key(a), kb = key(b); return ka.0 == kb.0 ? ka.1 > kb.1 : ka.0 > kb.0 }}}diff --git a/Tests/HighballKitTests/EnvTextTests.swift b/Tests/HighballKitTests/EnvTextTests.swiftindex 49c8062..fea9fa9 100644--- a/Tests/HighballKitTests/EnvTextTests.swift+++ b/Tests/HighballKitTests/EnvTextTests.swift@@ -51,4 +51,40 @@ final class EnvTextTests: XCTestCase {XCTAssertNil(LaunchLogs.newest(names: names, bottle: "Gaming", executable: "acs.exe"))XCTAssertNil(LaunchLogs.newest(names: names, bottle: "steam", executable: "steam.exe"), "an environment name that is a suffix of another must not match")}++ /// Opening Steam's window after a game crashed handed the request to the running client and+ /// left a newer, empty log; the game's page must still open the log with the crash in it.+ func testTheLastLaunchLogSkipsAnEmptyHandOver() {+ let play = "2026-10-07T181512Z-Games-steam.exe.log", open = "2026-10-07T181930Z-Games-steam.exe.log"+ let older = "2026-10-06T100000Z-Games-steam.exe.log", sameSecond = "2026-10-07T181930Z-Games-steam.exe-2.log"+ let names = [older, play, open, "2026-10-07T182000Z-Games-reg.exe.log"]+ XCTAssertEqual(LaunchLogs.newestWithOutput(names: names, bottle: "Games", executable: "steam.exe") { $0 != open }, play)+ XCTAssertEqual(LaunchLogs.newestWithOutput(names: names + [sameSecond], bottle: "Games", executable: "steam.exe") { $0 != open }, sameSecond,+ "a later launch in the same second that has output is the newest")+ XCTAssertEqual(LaunchLogs.newestWithOutput(names: names, bottle: "Games", executable: "steam.exe") { _ in false }, open,+ "when no log has output, the newest as before")+ XCTAssertNil(LaunchLogs.newestWithOutput(names: names, bottle: "Gaming", executable: "steam.exe") { _ in true })+ }++ func testALogOfHeaderAndExitLineOnlyHasNoOutput() throws {+ let dir = FileManager.default.temporaryDirectory.appending(path: "hb-logs-\(UUID().uuidString)")+ try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)+ defer { try? FileManager.default.removeItem(at: dir) }+ let header = """+ # gin x64-sikarugir10.0_6-r21 bottle=Games renderer=d3dmetal+ # wine /Users/x/Library/Application Support/Highball/bottles/Games/drive_c/Program Files (x86)/Steam/steam.exe steam://open/main+ # sync=msync winver=win11 dpi=96 dxvkAsync=false frameGen=off+ # audio out=48000 Hz+ # dxvk.enableAsync = False++ """+ let handOver = dir.appending(path: "a.log"), crash = dir.appending(path: "b.log"), empty = dir.appending(path: "c.log")+ try (header + "# exit=0 after 0s\n").write(to: handOver, atomically: true, encoding: .utf8)+ try (header + "0124:err:seh:NtRaiseException Unhandled exception code c0000005\n# exit=0 after 61s\n").write(to: crash, atomically: true, encoding: .utf8)+ try "".write(to: empty, atomically: true, encoding: .utf8)+ XCTAssertFalse(LaunchLogs.hasOutput(handOver))+ XCTAssertTrue(LaunchLogs.hasOutput(crash))+ XCTAssertFalse(LaunchLogs.hasOutput(empty))+ XCTAssertFalse(LaunchLogs.hasOutput(dir.appending(path: "missing.log")))+ }}