// // ContentView.swift // Museion // // Created by Alexander Kucera on 26.08.26. // import SwiftUI enum AppMetadata { nonisolated static let name = "Museion" nonisolated static let tagline = "The Agentic Writing Environment" } struct ContentView: View { @Environment(AppGateState.self) private var gate /// #48: provisioning failure presents only once the gate sheet has fully /// dismissed — keying on `gateDismissed` (set in the sheet's onDismiss, /// which fires at dismissal completion) rather than `!gateRaised` (which /// flips at dismissal start); macOS can drop a sheet presented during /// another sheet's dismissal animation. private var failurePresented: Binding { Binding( get: { gate.provisioning.hasFailure && gate.gateDismissed }, set: { if !$0 { gate.provisioning.deferFailure() } }, ) } var body: some View { @Bindable var gate = gate Group { // #14: post-gate main surface is the mentor debug pane (M0 demo // surface, map decision: pane placement). Gate pass hands over the // probe's winning binary — no re-probe. if gate.gateModel.currentBinaryPath != nil { MentorPaneView(model: gate.mentor, binaryPath: gate.gateModel.currentBinaryPath) } else { VStack(spacing: 8) { Image(systemName: "books.vertical") .font(.largeTitle) Text(AppMetadata.name) .font(.title) .bold() Text(AppMetadata.tagline) .foregroundStyle(.secondary) } .padding(32) } } .frame(minWidth: 480, minHeight: 320) .sheet(isPresented: $gate.gateRaised) { EngineGateView( model: gate.gateModel, onEnginePass: { // #47: provisioning runs in parallel on pass; idempotent, so re-fires // are no-ops. Alert UX on failure is #48. // #50: backup runs after the provision pass finishes — success or // failure; a failed provision doesn't skip the backup. Task { await gate.provisioning.runPass(hermesBinary: gate.gateModel.currentBinaryPath) await gate.backup.runPass() } }, onDismiss: { gate.gateRaised = false gate.gateDismissed = true }, ) } .sheet(isPresented: failurePresented) { ProvisioningFailureCard(model: gate.provisioning) { Task { await gate.provisioning.runPass(hermesBinary: gate.gateModel.currentBinaryPath) } } .interactiveDismissDisabled() } } }