Skip to content

Commit 586841b

Browse files
committed
Better pairing file errors
1 parent 2f4e434 commit 586841b

1 file changed

Lines changed: 12 additions & 65 deletions

File tree

StikJIT/Views/HomeView.swift

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,6 @@ struct HomeView: View {
403403
statusLightsRow
404404

405405
vpnControls
406-
407-
ddiControls
408406

409407
}
410408
}
@@ -417,6 +415,14 @@ struct HomeView: View {
417415
.font(.headline.weight(.semibold))
418416
.foregroundStyle(.primary)
419417

418+
if primaryActionTitle == "New Pairing File Needed" {
419+
statusBadge(
420+
icon: "xmark.octagon.fill",
421+
text: "Pairing file expired",
422+
color: .red
423+
)
424+
}
425+
420426
primaryActionControls
421427

422428
if let info = connectionInfoMessage, !info.isEmpty {
@@ -468,7 +474,6 @@ struct HomeView: View {
468474
}
469475

470476
private var allStatusIndicatorsGreen: Bool {
471-
pairingIndicatorStatus == .success &&
472477
ddiIndicatorStatus == .success &&
473478
wifiIndicatorStatus == .success &&
474479
heartbeatIndicatorStatus == .success
@@ -484,13 +489,6 @@ struct HomeView: View {
484489

485490
private var statusLights: [StatusLightData] {
486491
[
487-
StatusLightData(
488-
type: .pairing,
489-
title: "Pairing",
490-
icon: "doc.badge.plus",
491-
status: pairingIndicatorStatus,
492-
detail: pairingDetailText
493-
),
494492
StatusLightData(
495493
type: .ddi,
496494
title: "DDI",
@@ -515,16 +513,9 @@ struct HomeView: View {
515513
]
516514
}
517515

518-
private var pairingDetailText: String {
519-
if isValidatingPairingFile { return "Validating…" }
520-
if pairingFileExists { return "Ready" }
521-
if pairingFilePresentOnDisk { return "Unreadable" }
522-
return "Missing"
523-
}
524-
525516
private var ddiDetailText: String {
526517
if ddiMounted { return "Mounted" }
527-
if pairingFileLikelyInvalid { return "Needs pairing" }
518+
if pairingFileLikelyInvalid { return "Error" }
528519
return pairingFileExists ? "Mount required" : "Not ready"
529520
}
530521

@@ -540,7 +531,7 @@ struct HomeView: View {
540531
}
541532
return "Pair first"
542533
}
543-
534+
544535
private var ddiIndicatorStatus: StartupIndicatorStatus {
545536
if ddiMounted { return .success }
546537
if pairingFileLikelyInvalid { return .warning }
@@ -627,13 +618,6 @@ struct HomeView: View {
627618
return wifiConnected ? .success : .warning
628619
}
629620

630-
private var pairingIndicatorStatus: StartupIndicatorStatus {
631-
if isValidatingPairingFile { return .running }
632-
if pairingFileExists { return .success }
633-
if pairingFilePresentOnDisk || pairingFileLikelyInvalid { return .warning }
634-
return .error
635-
}
636-
637621
private var heartbeatSubtitle: String {
638622
if heartbeatOK {
639623
return "Heartbeat is responding."
@@ -733,27 +717,6 @@ struct HomeView: View {
733717
}
734718
}
735719

736-
private var ddiControls: some View {
737-
VStack(alignment: .leading, spacing: 10) {
738-
HStack {
739-
Text("Developer Disk Image")
740-
.font(.subheadline.weight(.semibold))
741-
.foregroundStyle(.primary)
742-
Spacer()
743-
statusBadge(
744-
icon: ddiMounted ? "externaldrive.fill.badge.checkmark" : "externaldrive.badge.exclamationmark",
745-
text: ddiMounted ? "Mounted" : "Not Mounted",
746-
color: ddiStatusColor
747-
)
748-
}
749-
750-
Text(ddiStatusDescription)
751-
.font(.footnote)
752-
.foregroundStyle(.secondary)
753-
754-
}
755-
}
756-
757720
private var vpnStatusColor: Color {
758721
switch tunnel.tunnelStatus {
759722
case .connected: return .green
@@ -781,22 +744,6 @@ struct HomeView: View {
781744
}
782745
}
783746

784-
private var ddiStatusDescription: String {
785-
if ddiMounted {
786-
return "Mounted successfully and ready for debugging."
787-
}
788-
if pairingFileLikelyInvalid {
789-
return "We can’t mount until a valid pairing file is imported."
790-
}
791-
return "Mount the Developer Disk Image before enabling JIT."
792-
}
793-
794-
private var ddiStatusColor: Color {
795-
if ddiMounted { return .green }
796-
if pairingFileLikelyInvalid { return .yellow }
797-
return .orange
798-
}
799-
800747
private func runConnectionDiagnostics(autoStart: Bool = false) {
801748
guard !isConnectionCheckRunning else { return }
802749
connectionTimeoutTask?.cancel()
@@ -834,7 +781,7 @@ struct HomeView: View {
834781
private var primaryActionTitle: String {
835782
if isValidatingPairingFile { return "Validating…" }
836783
if !pairingFileExists { return pairingFilePresentOnDisk ? "Import New Pairing File" : "Import Pairing File" }
837-
if pairingFileLikelyInvalid { return "Import New Pairing File" }
784+
if pairingFileLikelyInvalid { return "New Pairing File Needed" }
838785
if !ddiMounted { return "Mount Developer Disk Image" }
839786
return "Connect by App"
840787
}
@@ -1331,6 +1278,7 @@ struct HomeView: View {
13311278
return lastSignature != signature
13321279
}
13331280

1281+
13341282
private func pairingFileSignature(for url: URL) -> PairingFileSignature {
13351283
let attributes = (try? FileManager.default.attributesOfItem(atPath: url.path)) ?? [:]
13361284
let modificationDate = attributes[.modificationDate] as? Date
@@ -1700,7 +1648,6 @@ private struct StatusLightData: Identifiable {
17001648
}
17011649

17021650
private enum StatusLightType {
1703-
case pairing
17041651
case ddi
17051652
case wifi
17061653
case heartbeat

0 commit comments

Comments
 (0)