feat(gate): add Engine gate launch check (S2.1)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Block every app launch behind an Engine gate per wayfinder map #12: discover the user-installed hermes binary via the documented six-path probe (#36), health-check it with acp --check (stdin closed, 5 s per-candidate timeout, exit-status branching), version via acp --version, and record every completed check in Application Support state.json (#39). The gate is a blocking sheet with checking/pass/fail cards (#38/#40), app-scoped so only the first window per launch auto-checks (#41); an About window mirrors the state file read-only. Provisioning (#13) has a stub seam at onEnginePass. 12 unit tests drive the real Process path with fake hermes binaries; build, tests, swiftformat, swiftlint all green. Closes #42 [Generated by AI]
This commit is contained in:
1 parent
232ac9d722
commit
753da2135a
11 files changed
+832
-3
No files matched your search
@@ -7,11 +7,89 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// App-scoped gate state — raised once per app-launch, first window only (ticket #41).
|
||||
/// The model is shared so ⌘N during the gate can't start a second concurrent check.
|
||||
@MainActor
|
||||
@Observable
|
||||
final class AppGateState {
|
||||
var gateRaised = true
|
||||
let gateModel = EngineGateModel()
|
||||
}
|
||||
|
||||
@main
|
||||
struct MuseionApp: App {
|
||||
@State private var gate = AppGateState()
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environment(gate)
|
||||
}
|
||||
Window("About \(AppMetadata.name)", id: "about") {
|
||||
AboutEngineView()
|
||||
}
|
||||
.windowResizability(.contentSize)
|
||||
.commands {
|
||||
// SwiftUI has no About scene on macOS; replace the stock panel with our window.
|
||||
CommandGroup(replacing: .appInfo) {
|
||||
OpenAboutButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct OpenAboutButton: View {
|
||||
@Environment(\.openWindow) private var openWindow
|
||||
|
||||
var body: some View {
|
||||
Button("About \(AppMetadata.name)") { openWindow(id: "about") }
|
||||
}
|
||||
}
|
||||
|
||||
/// Read-only mirror of the last completed check's state.json record (ticket #39).
|
||||
/// Reads the file when opened; never triggers a check; no re-check button.
|
||||
struct AboutEngineView: View {
|
||||
@State private var record: EngineProbe.StateRecord?
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 12) {
|
||||
Image(systemName: "books.vertical")
|
||||
.font(.largeTitle)
|
||||
Text(AppMetadata.name)
|
||||
.font(.title)
|
||||
.bold()
|
||||
Text(AppMetadata.tagline)
|
||||
.foregroundStyle(.secondary)
|
||||
|
||||
Divider()
|
||||
|
||||
if let record {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
aboutRow("Engine", record.status == "pass" ? "Ready" : "Unavailable")
|
||||
aboutRow("Engine version", record.engineVersion ?? "—")
|
||||
aboutRow("Last checked", record.checkedAt)
|
||||
aboutRow("Binary path", record.binaryPath ?? "—")
|
||||
}
|
||||
} else {
|
||||
Text("No engine check recorded yet.")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
.frame(width: 380)
|
||||
.onAppear { record = EngineProbe.readStateRecord() }
|
||||
}
|
||||
|
||||
private func aboutRow(_ label: String, _ value: String) -> some View {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text(label)
|
||||
.foregroundStyle(.secondary)
|
||||
Spacer(minLength: 12)
|
||||
Text(value)
|
||||
.textSelection(.enabled)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
}
|
||||
.font(.callout)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user