Run a virtual iPhone on an Apple Silicon Mac.
Swift
Launchpad: stop opening the maintenance sheet and drop its progress banner
Lakr233ced5a17245e4
diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swiftindex 390c456a..516620f0 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Control/VPhoneLaunchpadControlCommands.swift@@ -893,7 +893,7 @@ struct VPhoneLaunchpadControlCommands {}/// A maintenance command for a client: it shows in the app as a run of- /// Launchpad's own would, without opening its sheet, and its output+ /// Launchpad's own would, and its output/// streams to the client too.private func maintenance(_ kind: VPhoneLaunchpadMaintenanceRun.Kind,@@ -903,7 +903,6 @@ struct VPhoneLaunchpadControlCommands {) async throws -> Int32 {try await library.runMaintenance(VPhoneLaunchpadMaintenanceRun(kind: kind, machine: machine),- presents: false,forward: emit,command,)diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swiftindex 65ac49a9..589fa734 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachineLibrary.swift@@ -49,12 +49,6 @@ final class VPhoneLaunchpadMachineLibrary {/// The last `cfw install` or update run on each machine this session,/// kept once it ends so its sheet and the inspector can say how it went.private(set) var maintenance: [Path: VPhoneLaunchpadMaintenanceRun] = [:]- /// Machines whose maintenance sheet is open: their failures show there,- /// not as an alert.- var showsMaintenance: Set<Path> = []- /// A run that has just started from Launchpad itself, for the machines- /// view to open its sheet. It clears this once it has.- var maintenanceSheetRequest: Path?private var isRefreshing = falseprivate var timer: Timer?@@ -644,13 +638,11 @@ final class VPhoneLaunchpadMachineLibrary {/// Runs one of the helper's maintenance commands with the machine shown/// busy. Each line goes to the machine's console log, as it always has,/// to the run's own log, which its sheet follows, and to `forward`; the- /// few that mark a step or a warning reach the run itself. `presents`- /// asks the machines view to open the sheet. A failure is recorded on the+ /// few that mark a step or a warning reach the run itself. A failure is recorded on the/// run in the words its sheet and an alert use; what the helper throws is/// thrown on.func runMaintenance(_ run: VPhoneLaunchpadMaintenanceRun,- presents: Bool,forward: (@Sendable (String) -> Void)? = nil,_ command: (@escaping @Sendable (String) -> Void) async throws -> Int32,) async throws -> Int32 {@@ -658,9 +650,6 @@ final class VPhoneLaunchpadMachineLibrary {maintenance[machine] = runactivities[machine] = run.kind.activitydefer { activities[machine] = nil }- if presents {- maintenanceSheetRequest = machine- }let banner = "$ vphone-cli \(run.kind.command) \(machine.name)"appendConsoleLog(machine, banner)run.log.write(banner)@@ -691,9 +680,8 @@ final class VPhoneLaunchpadMachineLibrary {}}- /// `runMaintenance` for a button or a menu item: its sheet opens, and a- /// failure, reworded by `explain`, becomes `actionError` unless that- /// sheet is open to show it. True once the command has succeeded.+ /// `runMaintenance` for a button or a menu item: a failure,+ /// reworded by `explain`, becomes `actionError`. True once the command has succeeded.@discardableResultprivate func performMaintenance(_ kind: VPhoneLaunchpadMaintenanceRun.Kind,@@ -702,14 +690,12 @@ final class VPhoneLaunchpadMachineLibrary {_ command: (@escaping @Sendable (String) -> Void) async throws -> Int32,) async -> Bool {let run = VPhoneLaunchpadMaintenanceRun(kind: kind, machine: machine)- if (try? await runMaintenance(run, presents: true, command)) == 0 {+ if (try? await runMaintenance(run, command)) == 0 {return true}if let failure = run.failure {run.failure = explain(failure)- if !showsMaintenance.contains(machine) {- actionError = run.failure- }+ actionError = run.failure}return false}diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swiftindex ce64527a..b17e1cda 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift@@ -123,19 +123,6 @@ struct VPhoneLaunchpadMachinesView: View {}// So New Machine opens on the catalog rather than loading it..task(id: model.bundles.defaultVersion) { await VPhoneLaunchpadNewMachineView.prefetchCatalog(model) }- // A CFW install or update started here shows its progress at once.- // Another sheet open keeps its place; the inspector offers the- // progress then. A run already over by the time the list is back- // on screen does not open.- .onChange(of: library.maintenanceSheetRequest, initial: true) {- guard let machine = library.maintenanceSheetRequest else {- return- }- library.maintenanceSheetRequest = nil- if sheet == nil, library.maintenance[machine]?.isRunning == true {- sheet = .maintenance(machine)- }- }.onChange(of: model.deletionRequest, initial: true) {if !model.deletionRequest.isEmpty {deletion = model.deletionRequestdiff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMaintenanceView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMaintenanceView.swiftindex a8412da9..ec4024ad 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMaintenanceView.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMaintenanceView.swift@@ -109,9 +109,8 @@ final class VPhoneLaunchpadMaintenanceRun {// MARK: - Sheet-/// A maintenance run's progress: the step under way, how long it has taken,-/// the steps that warned, and its output as it arrives. It follows the-/// machine's latest run, so it stays useful when another one starts.+/// A maintenance run's output as it arrives. It follows the machine's latest+/// run, so it stays useful when another one starts.struct VPhoneLaunchpadMaintenanceView: View {let machine: VPhoneLaunchpadMachinePath@Environment(VPhoneLaunchpadModel.self) private var model@@ -128,12 +127,6 @@ struct VPhoneLaunchpadMaintenanceView: View {width: VPhoneLaunchpadSheetSize.wide,) {VStack(alignment: .leading, spacing: 12) {- if let run {- summary(run)- if !run.progress.warnings.isEmpty {- warnings(run.progress)- }- }VPhoneLaunchpadLogTerminal(url: VPhoneLaunchpadMachineLibrary.consoleLog(machine, suffix: "-maintenance")).frame(maxWidth: .infinity, minHeight: 420, maxHeight: .infinity)}@@ -151,64 +144,6 @@ struct VPhoneLaunchpadMaintenanceView: View {Button("Close") { dismiss() }.keyboardShortcut(.cancelAction)}- // A failure shown here is not raised as an alert as well.- .onAppear { library.showsMaintenance.insert(machine) }- .onDisappear { library.showsMaintenance.remove(machine) }- }-- private func summary(_ run: VPhoneLaunchpadMaintenanceRun) -> some View {- HStack(alignment: .firstTextBaseline, spacing: 8) {- VPhoneLaunchpadStatusIcon(status: run.status)- VStack(alignment: .leading, spacing: 2) {- Text(verbatim: headline(run))- if let stage = run.progress.stage, run.isRunning || !run.succeeded {- Text(verbatim: stage)- .font(.caption.monospaced())- .foregroundStyle(.secondary)- .lineLimit(1)- .truncationMode(.middle)- .help(stage)- }- if let detail = run.failure?.detail {- Text(verbatim: detail)- .font(.caption)- .foregroundStyle(.secondary)- .textSelection(.enabled)- .lineLimit(6)- }- }- Spacer(minLength: 16)- VPhoneLaunchpadMaintenanceElapsed(run: run)- }- }-- private func headline(_ run: VPhoneLaunchpadMaintenanceRun) -> String {- if run.isRunning {- return run.kind.activity- }- if run.succeeded {- return run.kind.finished- }- return run.failure?.message ?? String(localized: "Unable to Complete Action")- }-- private func warnings(_ progress: VPhoneLaunchpadMaintenanceProgress) -> some View {- DisclosureGroup {- ScrollView {- Text(verbatim: progress.warnings.joined(separator: "\n"))- .font(.caption.monospaced())- .textSelection(.enabled)- .frame(maxWidth: .infinity, alignment: .leading)- }- .frame(maxHeight: 120)- } label: {- Label {- Text("^[\(progress.warningCount) warning](inflect: true)")- } icon: {- Image(systemName: "exclamationmark.triangle.fill")- .foregroundStyle(.yellow)- }- }}}