Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

feat: report button, Steam first-update guidance, duplicate/repair bottles (#7)

Gauthier Piarrette3c707d6580c1
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 912db66..fd78cdd 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -164,7 +164,21 @@ final class AppState {
try? await Task.sleep(for: .seconds(2))
extra = ["WINEMSYNC": "0", "WINEESYNC": "0"]
}
- let result = try await runner.start(pin: pin, extraEnvironment: extra) { line in Task { @MainActor in self.appendLog(line) } }
+ let result: LaunchResult
+ if isSteamUI(pin) {
+ let (r, resumed) = try await runner.startResumingKnownSteamCrash(pin: pin, extraEnvironment: extra) { line in
+ Task { @MainActor in
+ self.appendLog(line)
+ if line.contains("relaunching so it resumes") {
+ self.stage = L("Steam crashed at a known spot — relaunching to resume the update")
+ }
+ }
+ }
+ result = r
+ if resumed { await MainActor.run { self.appendLog("resumed after the known crash") } }
+ } else {
+ result = try await runner.start(pin: pin, extraEnvironment: extra) { line in Task { @MainActor in self.appendLog(line) } }
+ }
if result.crashedEarly {
let current = pin.renderer ?? bottle.settings.renderer
let next: Renderer = current == .dxmt ? .d3dmetal : (current == .d3dmetal ? .dxvk : .dxmt)
@@ -243,6 +257,31 @@ final class AppState {
}
}
+ func duplicateBottle(_ bottle: Bottle) {
+ runBusy("Duplicating '\(bottle.name)'", showLogSheet: false) { [self] in
+ killBottle(bottle) // flush registry files before copying
+ try? await Task.sleep(for: .seconds(1))
+ let store = bottleStore, name = bottle.name
+ // The copy can be many GB — keep it off the main thread.
+ let copy = try await Task.detached { try store.duplicate(name) }.value
+ await MainActor.run { self.selectedBottle = copy.name }
+ }
+ }
+
+ func repairBottle(_ bottle: Bottle) {
+ guard let engine = engine(for: bottle) else { return }
+ runBusy("Repairing '\(bottle.name)' — re-running the Windows first boot") { [self] in
+ let runner = WineRunner(paths: paths, engine: engine, bottle: bottle)
+ try? runner.kill()
+ try? await Task.sleep(for: .seconds(2))
+ let r = try await runner.wineboot()
+ guard r.exitStatus == 0 else {
+ throw HighballError.processFailed(command: "wineboot -u", status: r.exitStatus, output: "see \(r.log.path)")
+ }
+ await MainActor.run { self.appendLog("bottle repaired — Windows environment refreshed") }
+ }
+ }
+
func setRetina(_ on: Bool, in bottle: Bottle) {
guard let engine = engine(for: bottle) else { return }
var copy = bottle
diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swift
index 0353e1c..f01556e 100644
--- a/Sources/HighballApp/BottleView.swift
+++ b/Sources/HighballApp/BottleView.swift
@@ -55,6 +55,17 @@ struct BottleView: View {
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 34) {
+ // Long operations used to be invisible unless the log sheet was open — the
+ // Steam first-update looked frozen for 15-25 min. Surface the stage inline.
+ if state.busy && !state.stage.isEmpty && !state.showLog {
+ HStack(spacing: 9) {
+ ProgressView().controlSize(.small)
+ Text(state.stage).font(.callout).foregroundStyle(.secondary)
+ Spacer()
+ }
+ .padding(.horizontal, 14).padding(.vertical, 9)
+ .background(RoundedRectangle(cornerRadius: 9).fill(HB.card.opacity(0.8)))
+ }
gamesSection
launchersSection
if !customPins.isEmpty { programsSection }
diff --git a/Sources/HighballApp/HighballApp.swift b/Sources/HighballApp/HighballApp.swift
index 2a6b866..9b2385c 100644
--- a/Sources/HighballApp/HighballApp.swift
+++ b/Sources/HighballApp/HighballApp.swift
@@ -23,6 +23,10 @@ struct HighballApp: App {
CheckForUpdatesView(updater: delegate.updaterController.updater)
// Cleanup after a crash or a "leave running" quit — no Activity Monitor needed.
Button(L("Stop All Windows Processes")) { state.killAllBottles() }
+ // Pre-filled GitHub issue: version, chip/macOS, newest log tail (issue #7).
+ Button(L("Report a Problem…")) {
+ NSWorkspace.shared.open(BugReport.url(version: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "dev"))
+ }
}
}
}
@@ -141,6 +145,8 @@ struct ContentView: View {
.listRowInsets(EdgeInsets(top: 1, leading: 6, bottom: 1, trailing: 6))
.contextMenu {
Button(L("Stop all processes")) { state.killBottle(bottle) }
+ Button(L("Duplicate bottle")) { state.duplicateBottle(bottle) }
+ Button(L("Repair bottle (re-run first boot)")) { state.repairBottle(bottle) }
Divider()
Button(L("Delete bottle…"), role: .destructive) { pendingDelete = bottle.name }
}
@@ -185,6 +191,10 @@ struct ContentView: View {
get: { state.errorMessage != nil },
set: { if !$0 { state.errorMessage = nil } })) {
Button("OK") { state.errorMessage = nil }
+ Button(L("Report this problem…")) {
+ state.errorMessage = nil
+ NSWorkspace.shared.open(BugReport.url(version: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "dev"))
+ }
} message: { Text(state.errorMessage ?? "") }
.alert(item: $state.crashSuggestion) { s in
Alert(title: Text("\(s.program) exited right away"),
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index dffd41e..c4ff87d 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -38,6 +38,12 @@ enum L10n {
"Texte et interface plus nets à la pleine résolution de votre écran. Les jeux exigeants peuvent ralentir — combinez avec la limite d'images par seconde.",
"Enabling Retina mode": "Activation du mode Retina",
"Disabling Retina mode": "Désactivation du mode Retina",
+ "Report a Problem…": "Signaler un problème…",
+ "Report this problem…": "Signaler ce problème…",
+ "Duplicate bottle": "Dupliquer la bouteille",
+ "Repair bottle (re-run first boot)": "Réparer la bouteille (relancer le premier démarrage)",
+ "Steam crashed at a known spot — relaunching to resume the update":
+ "Steam a planté à un endroit connu — relance pour reprendre la mise à jour",
// Bottle view
"Programs": "Programmes",
diff --git a/Sources/HighballKit/BottleStore.swift b/Sources/HighballKit/BottleStore.swift
index b007305..6fa3b2e 100644
--- a/Sources/HighballKit/BottleStore.swift
+++ b/Sources/HighballKit/BottleStore.swift
@@ -66,6 +66,25 @@ public struct BottleStore: Sendable {
return bottle
}
+ /// Copies a bottle under a new name (default "<name> copy", uniquified). Callers should stop
+ /// the bottle's wineserver first so the registry files on disk are flushed and consistent.
+ public func duplicate(_ name: String, as newName: String? = nil) throws -> Bottle {
+ let source = try get(name)
+ var target = newName ?? "\(name) copy"
+ if newName == nil {
+ var i = 2
+ while FileManager.default.fileExists(atPath: paths.bottle(target).path) { target = "\(name) copy \(i)"; i += 1 }
+ }
+ if let problem = Self.nameProblem(target) { throw HighballError.invalid(problem) }
+ let dest = paths.bottle(target)
+ guard !FileManager.default.fileExists(atPath: dest.path) else { throw HighballError.invalid("bottle '\(target)' already exists") }
+ try FileManager.default.copyItem(at: source.url, to: dest)
+ var copy = try Bottle.load(dest)
+ copy.settings.name = target
+ try copy.save()
+ return copy
+ }
+
public func delete(_ name: String) throws {
let url = paths.bottle(name)
guard FileManager.default.fileExists(atPath: url.appending(path: "bottle.json").path) else {
diff --git a/Sources/HighballKit/Paths.swift b/Sources/HighballKit/Paths.swift
index 0b28b51..fbb76ed 100644
--- a/Sources/HighballKit/Paths.swift
+++ b/Sources/HighballKit/Paths.swift
@@ -33,3 +33,37 @@ public struct HighballPaths: Sendable {
}
}
}
+
+/// Builds a pre-filled GitHub bug-report URL: system info and the newest log's tail land in
+/// the issue form (field ids: what/chip/version/log in .github/ISSUE_TEMPLATE/bug.yml), so
+/// every report arrives with the context that triage always needs.
+public enum BugReport {
+ public static func url(version: String, paths: HighballPaths = HighballPaths()) -> URL {
+ let chip = (try? Shell.capture("/usr/sbin/sysctl", ["-n", "machdep.cpu.brand_string"]))?
+ .trimmingCharacters(in: .whitespacesAndNewlines) ?? "unknown chip"
+ let macos = (try? Shell.capture("/usr/bin/sw_vers", ["-productVersion"]))?
+ .trimmingCharacters(in: .whitespacesAndNewlines) ?? "?"
+ var logTail = ""
+ if let files = try? FileManager.default.contentsOfDirectory(at: paths.logs, includingPropertiesForKeys: [.contentModificationDateKey]) {
+ let logs = files.filter { $0.pathExtension == "log" }
+ let newest = logs.max { a, b in
+ let da = (try? a.resourceValues(forKeys: [.contentModificationDateKey]))?.contentModificationDate ?? .distantPast
+ let db = (try? b.resourceValues(forKeys: [.contentModificationDateKey]))?.contentModificationDate ?? .distantPast
+ return da < db
+ }
+ if let newest, let text = try? String(contentsOf: newest, encoding: .utf8) {
+ var tail = text.split(separator: "\n").suffix(30).joined(separator: "\n")
+ if tail.count > 3000 { tail = String(tail.suffix(3000)) }
+ logTail = "\(newest.lastPathComponent):\n\(tail)"
+ }
+ }
+ var comps = URLComponents(string: "https://github.com/gauthierpiarrette/highball/issues/new")!
+ comps.queryItems = [
+ URLQueryItem(name: "template", value: "bug.yml"),
+ URLQueryItem(name: "chip", value: "\(chip), macOS \(macos)"),
+ URLQueryItem(name: "version", value: version),
+ URLQueryItem(name: "log", value: logTail),
+ ]
+ return comps.url!
+ }
+}
diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swift
index 4569ab0..90641b4 100644
--- a/Sources/HighballKit/WineRunner.swift
+++ b/Sources/HighballKit/WineRunner.swift
@@ -90,6 +90,22 @@ public struct WineRunner: Sendable {
return try await start(exe, arguments: pin.arguments, renderer: pin.renderer, extraEnvironment: env, onOutput: onOutput)
}
+ /// Steam's first self-update sometimes dies at a known Wine WoW64 spot and resumes cleanly
+ /// on relaunch (see recipes/launchers/steam.json knownIssues). Launches the pin and, if that
+ /// crash marker appears in the output, relaunches once so the update continues by itself.
+ public func startResumingKnownSteamCrash(pin: Pin, extraEnvironment: [String: String] = [:], onOutput: (@Sendable (String) -> Void)? = nil) async throws -> (result: LaunchResult, resumed: Bool) {
+ let collector = Collector()
+ let tap: @Sendable (String) -> Void = { line in collector.append(line); onOutput?(line) }
+ var result = try await start(pin: pin, extraEnvironment: extraEnvironment, onOutput: tap)
+ guard collector.lines.contains(where: { $0.contains("nested exception on signal stack") }) else {
+ return (result, false)
+ }
+ onOutput?("Steam's updater hit a known Wine crash — relaunching so it resumes…")
+ try? await Task.sleep(for: .seconds(3))
+ result = try await start(pin: pin, extraEnvironment: extraEnvironment, onOutput: onOutput)
+ return (result, true)
+ }
+
public func wineboot() async throws -> LaunchResult {
try await run(["wineboot", "-u"], renderer: .wined3d, label: "wineboot")
}
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index 5fe3a10..4279afc 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -7,7 +7,7 @@ struct Highball: AsyncParsableCommand {
static let configuration = CommandConfiguration(
commandName: "highball",
abstract: "Highball — run Windows games on Apple Silicon. Free, open, engine-agnostic.",
- subcommands: [Engine.self, Bottle.self, Run.self, Recipe.self, Tricks.self, Env.self, Report.self, Verify.self],
+ subcommands: [Engine.self, Bottle.self, Run.self, Recipe.self, Tricks.self, Env.self, Report.self, BugReportCommand.self, Verify.self],
defaultSubcommand: nil
)
}
@@ -70,7 +70,7 @@ struct Engine: AsyncParsableCommand {
// MARK: - gin bottle
struct Bottle: AsyncParsableCommand {
- static let configuration = CommandConfiguration(abstract: "Manage bottles (Wine prefixes).", subcommands: [List.self, Create.self, Delete.self, Set.self, Kill.self])
+ static let configuration = CommandConfiguration(abstract: "Manage bottles (Wine prefixes).", subcommands: [List.self, Create.self, Delete.self, Set.self, Kill.self, Duplicate.self, Repair.self])
struct List: AsyncParsableCommand {
func run() async throws {
@@ -143,6 +143,35 @@ struct Bottle: AsyncParsableCommand {
}
}
+ struct Duplicate: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(abstract: "Copy a bottle (stops it first so the copy is consistent).")
+ @Argument var name: String
+ @Argument(help: "Name for the copy (default: '<name> copy').") var newName: String?
+ func run() async throws {
+ let bs = BottleStore()
+ let b = try bs.get(name)
+ let eng = try EngineStore().engine(b.settings.engineID)
+ try? WineRunner(engine: eng, bottle: b).kill()
+ try? await Task.sleep(for: .seconds(1))
+ let copy = try bs.duplicate(name, as: newName)
+ print("duplicated '\(name)' → '\(copy.name)'")
+ }
+ }
+
+ struct Repair: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(abstract: "Re-run the Windows first boot (wineboot -u) to refresh a bottle.")
+ @Argument var name: String
+ func run() async throws {
+ let b = try BottleStore().get(name)
+ let eng = try EngineStore().engine(b.settings.engineID)
+ let runner = WineRunner(engine: eng, bottle: b)
+ try? runner.kill()
+ try? await Task.sleep(for: .seconds(2))
+ let r = try await runner.wineboot()
+ print(r.exitStatus == 0 ? "repaired \(name)" : "wineboot exited with \(r.exitStatus) — see \(r.log.path)")
+ }
+ }
+
struct Kill: AsyncParsableCommand {
@Argument var name: String
func run() async throws {
@@ -175,7 +204,11 @@ struct Run: AsyncParsableCommand {
var p = pin
if let renderer { p.renderer = renderer }
p.arguments += arguments
- result = try await runner.start(pin: p, onOutput: out)
+ if p.path.lowercased().hasSuffix("steam/steam.exe") {
+ result = try await runner.startResumingKnownSteamCrash(pin: p, onOutput: out ?? { _ in }).result
+ } else {
+ result = try await runner.start(pin: p, onOutput: out)
+ }
} else if program.contains(":") || program.contains("\\") {
result = try await runner.start(b.resolve(windowsPath: program), arguments: arguments, renderer: renderer, onOutput: out)
} else if FileManager.default.fileExists(atPath: program) {
@@ -361,4 +394,11 @@ func loadRecipe(_ idOrPath: String) throws -> HighballKit.Recipe {
""")
}
+struct BugReportCommand: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(commandName: "bugreport", abstract: "Print a pre-filled GitHub bug-report URL (system info + newest log tail).")
+ func run() async throws {
+ print(BugReport.url(version: "CLI").absoluteString)
+ }
+}
+
extension HighballKit.Renderer: ExpressibleByArgument {}