chahinebrini 2cb1f8ad6e feat(binder-mac): SwiftUI Wizard für Self-Bind End-to-End-Flow
apps/rebreak-binder-mac/ — neue macOS-App die User durch den kompletten
Self-Bind-Prozess führt: Welcome → Preflight → Supervise → Enroll →
Configure (MDM-Push + Pre/Post-Check) → Sideload Lock-Profile (AirDrop).

3-Layer Smart-Resume: supervised? + Enrollment-Profil installed (cfgutil
Ground-Truth)? + MDM-Ack fresh (NanoMDM-DB via ssh+psql)?

Services: DeviceDetector (ideviceinfo + cfgutil), SuperviseRunner
(spawnt supervise-magic CLI), MDMClient (PUT /v1/enqueue?push=1, Apple
XML-Plist, identisch zum server-watcher-Format), MDMStatus (DB-Real-
Check + ManagedApplicationList-Result-Read).

Plus:
- fix(supervise-magic): EOF nach ProcessMessage Response (ErrorCode=0)
  ist Success, nicht Error — vermeidet false-fail bei iPhone-Restore-
  Reboot
- feat(mdm-profiles): rebreak-content-filter-mdm.mobileconfig als
  MDM-Push-Variante (ohne ConsentText, ohne globales allowAppRemoval=
  false — per-app via managed-state)

End-to-End validiert: App-Push via Ad-Hoc-Manifest (silent), Managed-
State via ManagedApplicationList-Query, NEFilter-Mode nach App-Force-
Quit, Lock-Profile non-removable nach Sideload.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 08:37:14 +02:00

132 lines
4.3 KiB
Swift

import SwiftUI
struct SuperviseView: View {
@Environment(WizardModel.self) private var model
@State private var task: Task<Void, Never>?
var body: some View {
VStack(alignment: .leading, spacing: 16) {
header
Text("Wir schreiben jetzt die Supervision-Plist auf dein iPhone und starten es neu. Das dauert ~60 Sekunden. **Trenne das USB-Kabel nicht.**")
.foregroundStyle(.secondary)
statusBox
logViewer
Spacer()
navigationBar
}
.padding(40)
.onAppear { startIfNeeded() }
.onDisappear { task?.cancel() }
}
private var header: some View {
HStack {
Image(systemName: "lock.shield")
.font(.system(size: 30))
.foregroundStyle(.tint)
Text("Supervisieren")
.font(.title).bold()
}
}
@ViewBuilder
private var statusBox: some View {
if model.supervisionRunning {
HStack(spacing: 8) {
ProgressView().controlSize(.small)
Text("supervise-magic läuft …")
}
.padding(10)
.background(Color.blue.opacity(0.08))
.cornerRadius(6)
} else if let err = model.supervisionError {
HStack(alignment: .top, spacing: 8) {
Image(systemName: "xmark.octagon")
.foregroundStyle(.red)
Text(err).font(.callout)
}
.padding(10)
.background(Color.red.opacity(0.08))
.cornerRadius(6)
} else if !model.supervisionLog.isEmpty {
HStack {
Image(systemName: "checkmark.circle.fill").foregroundStyle(.green)
Text("Supervisieren abgeschlossen.")
}
.padding(10)
.background(Color.green.opacity(0.08))
.cornerRadius(6)
}
}
private var logViewer: some View {
ScrollViewReader { proxy in
ScrollView {
LazyVStack(alignment: .leading, spacing: 2) {
ForEach(Array(model.supervisionLog.enumerated()), id: \.offset) { idx, line in
Text(line)
.font(.system(.caption, design: .monospaced))
.foregroundStyle(line.contains("[stderr]") ? .orange : .secondary)
.id(idx)
}
}
.padding(8)
.frame(maxWidth: .infinity, alignment: .leading)
}
.background(Color.black.opacity(0.04))
.cornerRadius(6)
.frame(maxHeight: 220)
.onChange(of: model.supervisionLog.count) { _, newCount in
if newCount > 0 { proxy.scrollTo(newCount - 1, anchor: .bottom) }
}
}
}
private var navigationBar: some View {
HStack {
Button("Zurück") { model.goTo(.preflight) }
.buttonStyle(.bordered)
.disabled(model.supervisionRunning)
Spacer()
if model.supervisionError != nil {
Button("Neu versuchen") { startSupervise() }
.buttonStyle(.bordered)
}
Button("Weiter →") { model.advance() }
.buttonStyle(.borderedProminent)
.disabled(model.supervisionRunning || model.supervisionLog.isEmpty || model.supervisionError != nil)
}
}
private func startIfNeeded() {
if model.supervisionLog.isEmpty && !model.supervisionRunning && model.supervisionError == nil {
startSupervise()
}
}
private func startSupervise() {
model.supervisionLog = []
model.supervisionError = nil
model.supervisionRunning = true
task?.cancel()
task = Task { @MainActor in
do {
_ = try await SuperviseRunner.supervise(organizationName: "ReBreak", force: true) { line in
model.supervisionLog.append(line)
}
model.supervisionRunning = false
model.device?.isSupervised = true
} catch {
model.supervisionError = error.localizedDescription
model.supervisionRunning = false
}
}
}
}