Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Settings: Copy diagnostics puts a short report on the clipboard (#69)

v0lumehia686a2e49717
diff --git a/frontend/README.md b/frontend/README.md
index 5a1cfcb9..7995c834 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -28,6 +28,14 @@ time left; the build log opens under it. **Stop** ends the script and every tool
it started (the build runs in a process group of its own), and so does quitting
the app.
+**Settings → Copy diagnostics** puts a short Markdown report on the clipboard, for a
+bug report: the app and macOS versions and the chip; the repository, its commit and
+branch and how far it is behind `upstream/main` and `origin/main` as of the last fetch
+(nothing is fetched); the Python and .NET the builds run with and the dependency
+check; this session's last build command and the last 50 lines of its log. The home
+folder is shown as `~`, a log line holding key material (`name = <hex>`, as in
+`prod.keys`) keeps only its name, and no environment variables are included.
+
A completed Mac build appears in the collection automatically and can be started
with **Play**. An iPhone build, by default, offers its unsigned IPA and the
sideloading and RomFS-copy instructions.
diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swift
index 26c3e95a..34b5590b 100644
--- a/frontend/Sources/NSPortBuilder/ContentView.swift
+++ b/frontend/Sources/NSPortBuilder/ContentView.swift
@@ -119,6 +119,7 @@ final class BuildModel: ObservableObject {
/// Where this build's folder actually is: --work-dir when the checkout has it, else the script's
/// default under the input folder (issue #5 — an upstream checkout has no --work-dir).
var effectiveWorkDir = ""
+ var lastBuildCommand: [String] = [] // this session's last build, for Copy diagnostics (Diagnostics.swift)
// ---- Installing on an iPhone or iPad (Xcode with a development certificate) ----
// Optional: with a paired device and a signing team chosen, the script prepares the game's Xcode project
@@ -825,6 +826,7 @@ final class BuildModel: ObservableObject {
// script's default, which is the same workDir unless a separate output folder was chosen.
effectiveWorkDir = hasWorkDir ? workDir : (inputDir as NSString).appendingPathComponent(tidHex + "_build")
say(String(format: t("msg.running"), py) + " " + args.joined(separator: " "))
+ lastBuildCommand = [py] + args
let p = Process()
p.executableURL = URL(fileURLWithPath: py)
@@ -2326,6 +2328,8 @@ struct BuilderView: View {
}
}
}
+ divider
+ row(m.t("diag.title"), detail: m.t("diag.note")) { DiagnosticsButton(m: m, width: Self.settingsButtonWidth) }
}
}
diff --git a/frontend/Sources/NSPortBuilder/Diagnostics.swift b/frontend/Sources/NSPortBuilder/Diagnostics.swift
new file mode 100644
index 00000000..7f3bab5c
--- /dev/null
+++ b/frontend/Sources/NSPortBuilder/Diagnostics.swift
@@ -0,0 +1,228 @@
+import AppKit
+import SwiftUI
+
+/// Copy diagnostics (#69): a short Markdown report for a bug report — the app, the Mac, the checkout and how far behind it
+/// is, the Python and .NET the builds really use, the dependency check, and the last build's command line with the end of
+/// its log. Written in English whatever the interface language, for whoever reads the issue.
+///
+/// Private by construction: the home folder is shown as ~, a log line that looks like key material (`name = <hex>`, the
+/// form of prod.keys and title.keys) has its value replaced, and nothing comes from the environment. The checkout's
+/// distance from main is what git already knows: nothing is fetched.
+struct Diagnostics {
+ struct Dependency: Equatable { var name: String; var present: Bool; var detail: String }
+
+ struct Inputs {
+ var appVersion: String
+ var macOS: String
+ var chip: String
+ var repoPath: String
+ var commit: String? // "<short hash> <subject>"
+ var branch: String?
+ var behind: [(ref: String, count: Int)] = [] // upstream/main, origin/main: the ones this checkout has
+ var lastFetch: Date?
+ var python: String
+ var pythonVersion: String?
+ var pythonIsVenv = false // the launcher's own venv (BuildModel.venvDir)
+ var dotnet: String
+ var dotnetVersion: String?
+ var depsChecked = true
+ var deps: [Dependency] = []
+ var lastCommand: [String] = [] // the last build's, this session
+ var log = "" // the build log the Builds page shows
+ var home = NSHomeDirectory()
+ }
+
+ static let logLines = 50
+
+ static func report(_ i: Inputs) -> String {
+ var out: [String] = ["### NX2Apple diagnostics", ""]
+ out.append("- App: NX2Apple \(i.appVersion)")
+ out.append("- macOS: \(i.macOS)")
+ out.append("- Chip: \(i.chip)")
+ out.append("- Repository: \(i.repoPath.isEmpty ? "not found" : i.repoPath)")
+ if let commit = i.commit {
+ var line = "- Commit: \(commit)" + (i.branch.map { " (branch \($0))" } ?? "")
+ if !i.behind.isEmpty {
+ line += "; " + i.behind.map { "\($0.count) behind \($0.ref)" }.joined(separator: ", ")
+ if let fetched = i.lastFetch { line += " as of the last fetch, " + stamp(fetched) }
+ }
+ out.append(line)
+ } else if !i.repoPath.isEmpty {
+ out.append("- Commit: not a git checkout")
+ }
+ out.append("- Python: \(i.python.isEmpty ? "not found" : i.python)"
+ + parenthesized([i.pythonVersion, i.pythonIsVenv ? "the launcher's venv" : nil]))
+ out.append("- .NET: \(i.dotnet.isEmpty ? "not found" : i.dotnet)" + parenthesized([i.dotnetVersion]))
+ if !i.depsChecked {
+ out.append("- Dependencies: not checked yet")
+ } else {
+ let missing = i.deps.filter { !$0.present }
+ out.append("- Dependencies: " + (missing.isEmpty ? "all present" : "\(missing.count) missing"))
+ for d in i.deps { out.append(" - \(d.present ? "ok" : "MISSING") \(d.name)" + (d.detail.isEmpty ? "" : ": \(d.detail)")) }
+ }
+ out.append("")
+ out.append("#### Last build")
+ out.append("")
+ if i.lastCommand.isEmpty {
+ out.append("No build in this session.")
+ } else {
+ out.append("````sh")
+ out.append(i.lastCommand.map(quoted).joined(separator: " "))
+ out.append("````")
+ }
+ let tail = tail(i.log)
+ if !tail.isEmpty {
+ out.append("")
+ out.append("Last \(tail.count) log lines:")
+ out.append("")
+ out.append("````text")
+ out += tail.map(redact)
+ out.append("````")
+ }
+ return shortenHome(out.joined(separator: "\n") + "\n", home: i.home)
+ }
+
+ /// The home folder as ~ wherever it starts a path, and only there: /Users/jo becomes ~, /Users/joanna stays.
+ static func shortenHome(_ text: String, home: String) -> String {
+ let home = home.hasSuffix("/") ? String(home.dropLast()) : home
+ guard home.count > 1, let re = try? NSRegularExpression(pattern: NSRegularExpression.escapedPattern(for: home) + "(?=/|$|[^A-Za-z0-9._-])",
+ options: [.anchorsMatchLines]) else { return text }
+ return re.stringByReplacingMatches(in: text, range: NSRange(text.startIndex..., in: text), withTemplate: "~")
+ }
+
+ /// A line that carries key material — `name = <16 or more hex digits>`, as in prod.keys and title.keys — keeps its
+ /// name and loses its value. A build ID or hash printed with a colon stays: it identifies the build, not a secret.
+ static func redact(_ line: String) -> String {
+ guard let re = try? NSRegularExpression(pattern: #"([A-Za-z0-9_\-]+\s*=\s*)(0x)?[0-9A-Fa-f]{16,}"#) else { return line }
+ return re.stringByReplacingMatches(in: line, range: NSRange(line.startIndex..., in: line), withTemplate: "$1[redacted]")
+ }
+
+ /// The log's last lines, without the trailing blank one.
+ static func tail(_ log: String, lines n: Int = logLines) -> [String] {
+ var lines = log.components(separatedBy: "\n")
+ while let last = lines.last, last.trimmingCharacters(in: .whitespaces).isEmpty { lines.removeLast() }
+ return Array(lines.suffix(n))
+ }
+
+ static func quoted(_ arg: String) -> String {
+ arg.isEmpty || arg.contains(where: { " '\"$\\".contains($0) }) ? "'" + arg.replacingOccurrences(of: "'", with: "'\\''") + "'" : arg
+ }
+
+ private static func parenthesized(_ parts: [String?]) -> String {
+ let p = parts.compactMap { $0 }.filter { !$0.isEmpty }
+ return p.isEmpty ? "" : " (" + p.joined(separator: ", ") + ")"
+ }
+
+ private static func stamp(_ date: Date) -> String {
+ let f = DateFormatter()
+ f.locale = Locale(identifier: "en_US_POSIX")
+ f.dateFormat = "yyyy-MM-dd HH:mm"
+ return f.string(from: date)
+ }
+
+ /// A dependency row in English: its name and what the check said (a path, or a message with its argument).
+ static func dependency(_ d: BuildModel.Dep) -> Dependency {
+ let en = { (key: String) in L10n.string(key, .en) }
+ var detail = d.detail
+ if let colon = detail.firstIndex(of: ":"), !detail.hasPrefix("/"), L10n.table[String(detail[..<colon])] != nil {
+ detail = String(format: en(String(detail[..<colon])), String(detail[detail.index(after: colon)...]))
+ } else if L10n.table[detail] != nil {
+ detail = en(detail)
+ }
+ return Dependency(name: en(d.name), present: d.present, detail: detail)
+ }
+
+ // ---- what the report is made of, read from this Mac (in the background: git, python and dotnet each run once) ----
+
+ static func chip() -> String {
+ var size = 0
+ guard sysctlbyname("machdep.cpu.brand_string", nil, &size, nil, 0) == 0, size > 0 else { return "unknown" }
+ var buffer = [CChar](repeating: 0, count: size)
+ guard sysctlbyname("machdep.cpu.brand_string", &buffer, &size, nil, 0) == 0 else { return "unknown" }
+ return String(cString: buffer)
+ }
+
+ /// The commit, branch and distance from main of a checkout, from its own refs.
+ static func git(_ repo: String) -> (commit: String?, branch: String?, behind: [(ref: String, count: Int)], lastFetch: Date?) {
+ guard !repo.isEmpty, FileManager.default.fileExists(atPath: repo + "/.git"), let git = BuildModel.gitBinary() else { return (nil, nil, [], nil) }
+ func run(_ args: [String]) -> String? {
+ let r = BuildModel.runQuiet([git, "-C", repo] + args, env: BuildModel.gitEnv())
+ let s = r.out.trimmingCharacters(in: .whitespacesAndNewlines)
+ return r.ok && !s.isEmpty ? s : nil
+ }
+ let commit = run(["log", "-1", "--format=%h %s"])
+ let branch = run(["rev-parse", "--abbrev-ref", "HEAD"])
+ let behind = ["upstream/main", "origin/main"].compactMap { ref -> (ref: String, count: Int)? in
+ guard run(["rev-parse", "--verify", "--quiet", ref]) != nil, let n = run(["rev-list", "--count", "HEAD.." + ref]).flatMap({ Int($0) }) else { return nil }
+ return (ref, n)
+ }
+ let fetchHead = run(["rev-parse", "--git-path", "FETCH_HEAD"]).map { $0.hasPrefix("/") ? $0 : repo + "/" + $0 } // a worktree keeps it elsewhere
+ let fetched = fetchHead.flatMap { (try? FileManager.default.attributesOfItem(atPath: $0))?[.modificationDate] as? Date }
+ return (commit, branch, behind, fetched)
+ }
+
+ /// What a tool prints for its version, nil when it does not run.
+ static func version(_ tool: String, _ args: [String], env: [String: String]) -> String? {
+ guard FileManager.default.isExecutableFile(atPath: tool) else { return nil }
+ let r = BuildModel.runQuiet([tool] + args, env: env)
+ let s = r.out.trimmingCharacters(in: .whitespacesAndNewlines)
+ return r.ok && !s.isEmpty ? String(s.split(separator: "\n").last ?? "") : nil
+ }
+}
+
+extension BuildModel {
+ /// The report, read in the background and handed back on the main thread.
+ func diagnostics(_ done: @escaping (String) -> Void) {
+ let repo = repoOK ? repoPath : "", python = pythonPath.isEmpty ? Self.findPython().path : pythonPath, dotnet = dotnetPath
+ let rows = depsChecked ? deps.map(Diagnostics.dependency) : [], checked = depsChecked
+ let command = lastBuildCommand, log = logTail
+ DispatchQueue.global(qos: .userInitiated).async {
+ let git = Diagnostics.git(repo)
+ let env = ["HOME": NSHomeDirectory(), "PATH": "/usr/bin:/bin", "TMPDIR": NSTemporaryDirectory()]
+ var dotnetEnv = env
+ if !dotnet.isEmpty { dotnetEnv["DOTNET_ROOT"] = (dotnet as NSString).deletingLastPathComponent }
+ let inputs = Diagnostics.Inputs(
+ appVersion: Self.appVersion,
+ macOS: ProcessInfo.processInfo.operatingSystemVersionString,
+ chip: Diagnostics.chip(),
+ repoPath: repo, commit: git.commit, branch: git.branch, behind: git.behind, lastFetch: git.lastFetch,
+ python: python,
+ pythonVersion: Diagnostics.version(python, ["-c", "import sys; print(sys.version.split()[0])"], env: env),
+ pythonIsVenv: python == Self.venvPython(),
+ dotnet: dotnet,
+ dotnetVersion: dotnet.isEmpty ? nil : Diagnostics.version(dotnet, ["--version"], env: dotnetEnv),
+ depsChecked: checked, deps: rows, lastCommand: command, log: log)
+ let report = Diagnostics.report(inputs)
+ DispatchQueue.main.async { done(report) }
+ }
+ }
+}
+
+/// Settings' Copy diagnostics: the report goes to the clipboard and the button says Copied for a moment.
+struct DiagnosticsButton: View {
+ @ObservedObject var m: BuildModel
+ let width: CGFloat
+ var showCopied = false // the visual QA's confirmation
+ @State private var busy = false
+ @State private var copied = false
+
+ var body: some View {
+ Button(action: copy) {
+ if copied || showCopied { Label(m.t("diag.copied"), systemImage: "checkmark") } else { Text(m.t("diag.copy")) }
+ }
+ .buttonStyle(LauncherSecondaryButtonStyle(accent: copied || showCopied ? LauncherPalette.ready : nil, minWidth: width))
+ .disabled(busy)
+ .padTarget("set.diagnostics", scope: "main") { if !busy { copy() } }
+ }
+
+ private func copy() {
+ busy = true
+ m.diagnostics { report in
+ NSPasteboard.general.clearContents()
+ NSPasteboard.general.setString(report, forType: .string)
+ busy = false
+ withAnimation(.easeOut(duration: 0.15)) { copied = true }
+ DispatchQueue.main.asyncAfter(deadline: .now() + 2.5) { withAnimation(.easeOut(duration: 0.2)) { copied = false } }
+ }
+ }
+}
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index 4454dd15..c1a09f4d 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -314,6 +314,11 @@ enum L10n {
"dep.installTimeout": ("安装超时(30 分钟)——网络太慢或卡住了",
"Install timed out (30 minutes) — the network is slow or stuck"),
"dep.installAll": ("一键安装全部缺失项", "Install all missing"),
+ // ---- Copy diagnostics (Diagnostics.swift); the report itself is in English, for the issue ----
+ "diag.title": ("诊断信息", "Diagnostics"),
+ "diag.note": ("用于问题报告:版本、工具和上次构建的日志,不含密钥。", "For a bug report: versions, tools, the last build’s log. No keys."),
+ "diag.copy": ("复制诊断信息", "Copy diagnostics"),
+ "diag.copied": ("已复制", "Copied"),
"dep.recheck": ("重新检测", "Check again"),
"dep.install": ("安装", "Install"),
"dep.installing": ("安装中…", "Installing…"),
diff --git a/frontend/Tests/NSPortBuilderTests/DiagnosticsTests.swift b/frontend/Tests/NSPortBuilderTests/DiagnosticsTests.swift
new file mode 100644
index 00000000..e749e51a
--- /dev/null
+++ b/frontend/Tests/NSPortBuilderTests/DiagnosticsTests.swift
@@ -0,0 +1,106 @@
+import XCTest
+@testable import NSPortBuilder
+
+/// Issue #69: Copy diagnostics. Every input is a stand-in; nothing reads this Mac's checkout, tools or keys.
+final class DiagnosticsTests: XCTestCase {
+ private let home = "/Users/jo"
+
+ private func inputs() -> Diagnostics.Inputs {
+ var log = (1...80).map { "line \($0)" }
+ log[70] = "header_key = 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
+ log[71] = "[keys] key_area_key_application_00 =ABCDEF0123456789ABCDEF0123456789"
+ log[72] = "main build ID: 3CA12DFB0123456789ABCDEF0123456789ABCDEF"
+ return Diagnostics.Inputs(
+ appVersion: "0.4.8", macOS: "Version 26.1 (Build 25B78)", chip: "Apple M3 Pro",
+ repoPath: "/Users/jo/repos/NX2Apple", commit: "d66e4ddd CI: the legacy zip names are hyphenated", branch: "main",
+ behind: [(ref: "upstream/main", count: 3), (ref: "origin/main", count: 0)],
+ lastFetch: DateComponents(calendar: Calendar(identifier: .gregorian), year: 2026, month: 10, day: 27, hour: 9, minute: 5).date,
+ python: "/Users/jo/Library/Application Support/NS Port Builder/venv/bin/python3", pythonVersion: "3.13.1", pythonIsVenv: true,
+ dotnet: "/Users/jo/.dotnet/dotnet", dotnetVersion: "10.0.100",
+ deps: [.init(name: "Xcode and the iOS SDK", present: true, detail: ""),
+ .init(name: "spirv-cross", present: false, detail: "")],
+ lastCommand: ["/Users/jo/Library/Application Support/NS Port Builder/venv/bin/python3", "scripts/build_ipa_from_nsp.py",
+ "--keys", "/Users/jo/Switch/prod.keys", "/Volumes/Games/Hades [0100535012974000].nsp"],
+ log: log.joined(separator: "\n") + "\n\n", home: home)
+ }
+
+ func testTheReportHoldsTheAppTheMacTheCheckoutAndTheTools() {
+ let report = Diagnostics.report(inputs())
+ XCTAssertTrue(report.hasPrefix("### NX2Apple diagnostics\n"))
+ for expected in [
+ "- App: NX2Apple 0.4.8",
+ "- macOS: Version 26.1 (Build 25B78)",
+ "- Chip: Apple M3 Pro",
+ "- Repository: ~/repos/NX2Apple",
+ "- Commit: d66e4ddd CI: the legacy zip names are hyphenated (branch main); 3 behind upstream/main, 0 behind origin/main as of the last fetch, 2026-10-27 09:05",
+ "- Python: ~/Library/Application Support/NS Port Builder/venv/bin/python3 (3.13.1, the launcher's venv)",
+ "- .NET: ~/.dotnet/dotnet (10.0.100)",
+ "- Dependencies: 1 missing",
+ " - ok Xcode and the iOS SDK",
+ " - MISSING spirv-cross",
+ "'~/Library/Application Support/NS Port Builder/venv/bin/python3' scripts/build_ipa_from_nsp.py --keys ~/Switch/prod.keys '/Volumes/Games/Hades [0100535012974000].nsp'",
+ ] {
+ XCTAssertTrue(report.contains(expected + "\n"), expected)
+ }
+ XCTAssertFalse(report.contains(home + "/"), "no home path")
+ }
+
+ func testTheLogIsItsLast50LinesWithKeysRedacted() {
+ let report = Diagnostics.report(inputs())
+ XCTAssertTrue(report.contains("Last 50 log lines:"))
+ XCTAssertFalse(report.contains("line 30\n"))
+ XCTAssertTrue(report.contains("````text\nline 31\n"))
+ XCTAssertTrue(report.contains("line 80\n````\n"))
+ XCTAssertTrue(report.contains("header_key = [redacted]\n"))
+ XCTAssertTrue(report.contains("key_area_key_application_00 =[redacted]\n"))
+ XCTAssertFalse(report.contains("0123456789abcdef0123456789abcdef"))
+ XCTAssertTrue(report.contains("main build ID: 3CA12DFB0123456789ABCDEF0123456789ABCDEF"), "a build ID is not a key")
+ }
+
+ func testTheTailKeepsTheLastLinesWithoutTrailingBlanks() {
+ XCTAssertEqual(Diagnostics.tail("a\nb\nc\n\n \n", lines: 2), ["b", "c"])
+ XCTAssertEqual(Diagnostics.tail("a\nb", lines: 50), ["a", "b"])
+ XCTAssertEqual(Diagnostics.tail(""), [])
+ XCTAssertEqual(Diagnostics.tail((1...120).map(String.init).joined(separator: "\n")).count, 50)
+ }
+
+ func testRedactionTakesKeyLinesOnly() {
+ XCTAssertEqual(Diagnostics.redact("titlekek_00 = 0x0123456789ABCDEF0123456789ABCDEF"), "titlekek_00 = [redacted]")
+ XCTAssertEqual(Diagnostics.redact(" master_key_0a=00112233445566778899aabbccddeeff "), " master_key_0a=[redacted] ")
+ XCTAssertEqual(Diagnostics.redact("01007EF00011E000 = 0123456789abcdef0123456789abcdef"), "01007EF00011E000 = [redacted]", "a title key")
+ XCTAssertEqual(Diagnostics.redact("DM_FPS_TARGET=60"), "DM_FPS_TARGET=60")
+ XCTAssertEqual(Diagnostics.redact("[2/7] extract v720896: 30,000 files"), "[2/7] extract v720896: 30,000 files")
+ XCTAssertEqual(Diagnostics.redact("commit 0123456789abcdef0123"), "commit 0123456789abcdef0123")
+ }
+
+ func testHomeBecomesATildeOnlyWhereItStartsAPath() {
+ XCTAssertEqual(Diagnostics.shortenHome("/Users/jo/a and /Users/jo", home: home), "~/a and ~")
+ XCTAssertEqual(Diagnostics.shortenHome("/Users/joanna/a", home: home), "/Users/joanna/a")
+ XCTAssertEqual(Diagnostics.shortenHome("'/Users/jo/My Games/x'", home: home + "/"), "'~/My Games/x'")
+ XCTAssertEqual(Diagnostics.shortenHome("/Users/jo.backup/x", home: home), "/Users/jo.backup/x")
+ }
+
+ func testAReportWithoutABuildOrACheckout() {
+ var i = inputs()
+ i.lastCommand = []; i.log = ""; i.commit = nil; i.repoPath = ""; i.depsChecked = false; i.dotnet = ""; i.dotnetVersion = nil
+ let report = Diagnostics.report(i)
+ XCTAssertTrue(report.contains("- Repository: not found\n"))
+ XCTAssertFalse(report.contains("- Commit:"))
+ XCTAssertTrue(report.contains("- .NET: not found\n"))
+ XCTAssertTrue(report.contains("- Dependencies: not checked yet\n"))
+ XCTAssertTrue(report.contains("No build in this session.\n"))
+ XCTAssertFalse(report.contains("log lines"))
+ i.repoPath = "/Users/jo/NX2Apple-main"
+ XCTAssertTrue(Diagnostics.report(i).contains("- Commit: not a git checkout\n"), "a ZIP download")
+ }
+
+ func testADependencyIsDescribedInEnglish() {
+ let python = BuildModel.Dep(id: "python", name: "dep.python", hint: "dep.python.hint", present: false,
+ detail: "dep.python.old:3.9:3.12", installCmd: [])
+ let row = Diagnostics.dependency(python)
+ XCTAssertEqual(row.name, L10n.string("dep.python", .en))
+ XCTAssertEqual(row.detail, String(format: L10n.string("dep.python.old", .en), "3.9:3.12"))
+ let zstd = BuildModel.Dep(id: "brew:zstd", name: "dep.zstd", hint: "dep.zstd.hint", present: true, detail: "/opt/homebrew/bin/zstd", installCmd: [])
+ XCTAssertEqual(Diagnostics.dependency(zstd).detail, "/opt/homebrew/bin/zstd")
+ }
+}
diff --git a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift
index 20b9fddf..2b0ea862 100644
--- a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift
@@ -761,6 +761,24 @@ final class LibraryTests: XCTestCase {
model.stages = [Stage(id: 1, name: "Extract game files", state: .running, percent: 40)]
try capture("building", activeID: library.games[1].id)
model.running = false
+
+ // ---- Copy diagnostics (#69): Settings with its row, and the button's Copied confirmation (nothing is copied) ----
+ do {
+ try capture("settings-diagnostics", height: 1500, page: .settings)
+ let buttons = NSHostingView(rootView: HStack(spacing: 14) {
+ DiagnosticsButton(m: model, width: BuilderView.settingsButtonWidth)
+ DiagnosticsButton(m: model, width: BuilderView.settingsButtonWidth, showCopied: true)
+ }.padding(24).background(LauncherPalette.background).environmentObject(PadFocus()))
+ buttons.frame = NSRect(x: 0, y: 0, width: 420, height: 90)
+ let window = NSWindow(contentRect: buttons.frame, styleMask: [.titled], backing: .buffered, defer: false)
+ window.contentView = buttons
+ window.orderFront(nil)
+ RunLoop.main.run(until: Date().addingTimeInterval(0.3))
+ let rep = try XCTUnwrap(buttons.bitmapImageRepForCachingDisplay(in: buttons.bounds))
+ buttons.cacheDisplay(in: buttons.bounds, to: rep)
+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent("diagnostics-copied.png"))
+ window.orderOut(nil)
+ }
}
/// Issue #52: the failure note names the last real line, not just the exit code.