Skip to content

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

Ask how it went after play, on the strip

Gauthier Piarrette1f1130e864c9
diff --git a/Sources/HighballApp/ActivityStrip.swift b/Sources/HighballApp/ActivityStrip.swift
index c7f12c4..3dfdc01 100644
--- a/Sources/HighballApp/ActivityStrip.swift
+++ b/Sources/HighballApp/ActivityStrip.swift
@@ -9,7 +9,7 @@ struct ActivityStrip: View {
@Environment(AppState.self) private var state
var body: some View {
- if state.busy || state.doneState != nil || !state.runningSessions.isEmpty || !steamBottles.isEmpty {
+ if state.busy || state.doneState != nil || state.postPlay != nil || !state.runningSessions.isEmpty || !steamBottles.isEmpty {
VStack(spacing: 0) {
Divider()
VStack(spacing: 0) {
@@ -18,6 +18,7 @@ struct ActivityStrip: View {
} else if let done = state.doneState {
doneRow(done)
}
+ if let record = state.postPlay { postPlayRow(record) }
ForEach(state.runningSessions) { session in
sessionRow(session)
}
@@ -116,6 +117,24 @@ struct ActivityStrip: View {
.padding(.horizontal, 14).padding(.vertical, 8)
}
+ /// Asked after play, never before (UX plan §3.5). Both answers open a prefilled form in the
+ /// browser: a compatibility report for the database, or a problem report with the log.
+ private func postPlayRow(_ record: SessionRecord) -> some View {
+ HStack(spacing: 10) {
+ Image(systemName: "questionmark.circle").foregroundStyle(.secondary)
+ Text(String(format: L("How did %@ go?"), record.title)).font(.callout.weight(.medium)).lineLimit(1)
+ Text(String(format: L("%d min"), record.seconds / 60)).font(.caption.monospacedDigit()).foregroundStyle(.secondary)
+ Spacer(minLength: 12)
+ Button(L("It played fine")) { state.reportPlay(record) }.controlSize(.small)
+ Button(L("Had problems")) {
+ state.postPlay = nil
+ NSWorkspace.shared.open(BugReport.url(version: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "dev"))
+ }.controlSize(.small)
+ Button(L("Not now")) { state.postPlay = nil }.controlSize(.small).buttonStyle(.link)
+ }
+ .padding(.horizontal, 14).padding(.vertical, 8)
+ }
+
private func sessionRow(_ session: GameSession) -> some View {
HStack(spacing: 10) {
Circle().fill(HB.good).frame(width: 8, height: 8).padding(.horizontal, 4)
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index bb86eb9..0878ff0 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -683,6 +683,18 @@ final class AppState {
var runningSessions: [GameSession] = []
/// The last session that ended, for the post-play prompt to come.
var lastEndedSession: SessionRecord?
+ /// A finished session worth asking about: at least a minute of play (a shorter one is a
+ /// crash, and the early-exit alert already covers that). The strip asks once; Not now clears it.
+ var postPlay: SessionRecord?
+
+ /// Opens highball-db's report form prefilled from the session. The rating is theirs to give.
+ func reportPlay(_ record: SessionRecord) {
+ let engine = bottles.first { $0.name == record.bottle }?.settings.engineID ?? "?"
+ NSWorkspace.shared.open(PlayReport.url(title: record.title, appid: record.appid, renderer: record.renderer,
+ chip: Machine.chip(), macos: Machine.macOSVersion(), engine: engine,
+ minutes: record.seconds / 60))
+ postPlay = nil
+ }
private var sessionWatchers: [UUID: Task<Void, Never>] = [:]
func session(forAppID appid: Int) -> GameSession? { runningSessions.first { $0.appid == appid } }
@@ -710,9 +722,10 @@ final class AppState {
sessionWatchers[session.id]?.cancel()
sessionWatchers[session.id] = nil
let record = SessionRecord(title: session.title, bottle: session.bottleName, appid: session.appid,
- started: session.started, ended: Date(), reason: reason)
+ started: session.started, ended: Date(), reason: reason, renderer: session.renderer)
SessionWatch.append(record, to: paths.logs)
lastEndedSession = record
+ if record.seconds >= 60 { postPlay = record }
appendLog("\(session.title) \(reason) after \(record.seconds / 60) min")
}
@@ -892,7 +905,8 @@ final class AppState {
while waited < 360 {
if SessionWatch.isAlive(markers: markers, ps: SessionWatch.currentProcessList()) {
await MainActor.run {
- self.beginSession(GameSession(title: game.name, bottleName: bottle.name, appid: game.appid, markers: markers))
+ self.beginSession(GameSession(title: game.name, bottleName: bottle.name, appid: game.appid, markers: markers,
+ renderer: (renderer ?? bottle.settings.renderer).rawValue))
}
return
}
diff --git a/Sources/HighballKit/Paths.swift b/Sources/HighballKit/Paths.swift
index 8626a31..6b0c6c7 100644
--- a/Sources/HighballKit/Paths.swift
+++ b/Sources/HighballKit/Paths.swift
@@ -330,10 +330,8 @@ public enum BugReport {
/// `samplingLiveGames: false` skips the live-process sample (tests; callers that must not
/// block for the ~5 s a sample takes).
public static func url(version: String, paths: HighballPaths = HighballPaths(), samplingLiveGames: Bool = true) -> 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) ?? "?"
+ let chip = Machine.chip()
+ let macos = Machine.macOSVersion()
var logDigest = ""
// A game frozen right now is the one moment its stack is capturable — grab it first.
let samples = samplingLiveGames ? sampleRunningGames(paths: paths) : []
diff --git a/Sources/HighballKit/PlayReport.swift b/Sources/HighballKit/PlayReport.swift
new file mode 100644
index 0000000..c70224f
--- /dev/null
+++ b/Sources/HighballKit/PlayReport.swift
@@ -0,0 +1,37 @@
+import Foundation
+
+/// Facts about this Mac that every report carries.
+public enum Machine {
+ public static func chip() -> String {
+ (try? Shell.capture("/usr/sbin/sysctl", ["-n", "machdep.cpu.brand_string"]))?
+ .trimmingCharacters(in: .whitespacesAndNewlines) ?? "unknown chip"
+ }
+ public static func macOSVersion() -> String {
+ (try? Shell.capture("/usr/bin/sw_vers", ["-productVersion"]))?
+ .trimmingCharacters(in: .whitespacesAndNewlines) ?? "?"
+ }
+}
+
+/// A compatibility report for highball-db, prefilled from a finished session so "how did it go"
+/// costs one click and a rating (UX plan §3.5: Highball asks when you finish, never before).
+/// The rating is the player's to give; nothing here invents one.
+public enum PlayReport {
+ public static let template = "report.yml"
+
+ /// The issue URL for highball-db's report form, its fields prefilled by id. Query items use
+ /// the form's field ids, which GitHub reads into the matching inputs.
+ public static func url(title: String, appid: Int?, renderer: String?, chip: String, macos: String,
+ engine: String, minutes: Int) -> URL {
+ var comps = URLComponents(string: "https://github.com/gauthierpiarrette/highball-db/issues/new")!
+ var items = [URLQueryItem(name: "template", value: template),
+ URLQueryItem(name: "title", value: title)]
+ if let appid { items.append(URLQueryItem(name: "steam_appid", value: String(appid))) }
+ if let renderer { items.append(URLQueryItem(name: "renderer", value: renderer)) }
+ items += [URLQueryItem(name: "chip", value: chip),
+ URLQueryItem(name: "macos", value: macos),
+ URLQueryItem(name: "engine", value: engine),
+ URLQueryItem(name: "notes", value: "Played for \(minutes) min through Highball.")]
+ comps.queryItems = items
+ return comps.url!
+ }
+}
diff --git a/Sources/HighballKit/Sessions.swift b/Sources/HighballKit/Sessions.swift
index 61f5a1d..02149f4 100644
--- a/Sources/HighballKit/Sessions.swift
+++ b/Sources/HighballKit/Sessions.swift
@@ -11,8 +11,11 @@ public struct GameSession: Identifiable, Sendable, Equatable {
/// Substrings of the game's command line, in both path styles Wine reports.
public let markers: [String]
public let started: Date
- public init(id: UUID = UUID(), title: String, bottleName: String, appid: Int?, markers: [String], started: Date = Date()) {
+ /// The renderer the launch used, for the post-play report.
+ public let renderer: String?
+ public init(id: UUID = UUID(), title: String, bottleName: String, appid: Int?, markers: [String], started: Date = Date(), renderer: String? = nil) {
self.id = id; self.title = title; self.bottleName = bottleName; self.appid = appid; self.markers = markers; self.started = started
+ self.renderer = renderer
}
}
@@ -27,8 +30,10 @@ public struct SessionRecord: Codable, Sendable, Equatable {
public var seconds: Int { Int(ended.timeIntervalSince(started)) }
/// "ended" when the game went away on its own, "stopped" when Highball ended it.
public var reason: String
- public init(title: String, bottle: String, appid: Int?, started: Date, ended: Date, reason: String) {
+ public var renderer: String?
+ public init(title: String, bottle: String, appid: Int?, started: Date, ended: Date, reason: String, renderer: String? = nil) {
self.title = title; self.bottle = bottle; self.appid = appid; self.started = started; self.ended = ended; self.reason = reason
+ self.renderer = renderer
}
}
diff --git a/Tests/HighballKitTests/PlayReportTests.swift b/Tests/HighballKitTests/PlayReportTests.swift
new file mode 100644
index 0000000..3f05776
--- /dev/null
+++ b/Tests/HighballKitTests/PlayReportTests.swift
@@ -0,0 +1,36 @@
+import XCTest
+@testable import HighballKit
+
+final class PlayReportTests: XCTestCase {
+ func testFormFieldsArePrefilledById() throws {
+ let url = PlayReport.url(title: "Counter-Strike 2", appid: 730, renderer: "dxmt", chip: "Apple M1 Pro",
+ macos: "26.6.2", engine: "x64-sikarugir10.0_6-r1", minutes: 23)
+ let comps = try XCTUnwrap(URLComponents(url: url, resolvingAgainstBaseURL: false))
+ XCTAssertEqual(comps.host, "github.com")
+ XCTAssertEqual(comps.path, "/gauthierpiarrette/highball-db/issues/new")
+ let q = Dictionary(uniqueKeysWithValues: (comps.queryItems ?? []).map { ($0.name, $0.value ?? "") })
+ XCTAssertEqual(q["template"], "report.yml")
+ XCTAssertEqual(q["title"], "Counter-Strike 2")
+ XCTAssertEqual(q["steam_appid"], "730")
+ XCTAssertEqual(q["renderer"], "dxmt")
+ XCTAssertEqual(q["chip"], "Apple M1 Pro")
+ XCTAssertEqual(q["macos"], "26.6.2")
+ XCTAssertEqual(q["engine"], "x64-sikarugir10.0_6-r1")
+ XCTAssertEqual(q["notes"], "Played for 23 min through Highball.")
+ XCTAssertNil(q["rating"], "the rating is the player's to give")
+ }
+
+ func testUnknownAppIDAndRendererAreLeftOut() throws {
+ let url = PlayReport.url(title: "X", appid: nil, renderer: nil, chip: "c", macos: "m", engine: "e", minutes: 1)
+ let names = Set(URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.map(\.name) ?? [])
+ XCTAssertFalse(names.contains("steam_appid"))
+ XCTAssertFalse(names.contains("renderer"))
+ }
+
+ func testSessionRecordWithoutRendererStillDecodes() throws {
+ let old = Data(#"{"title":"T","bottle":"B","appid":1,"started":0,"ended":120,"reason":"ended"}"#.utf8)
+ let r = try JSONDecoder().decode(SessionRecord.self, from: old)
+ XCTAssertNil(r.renderer)
+ XCTAssertEqual(r.seconds, 120)
+ }
+}