CI / ci (push) Canceled after 0s
Profiles S1 (#134, ADR-0014): one gate pass provisions all three surface profiles — museion adopted in place (never reconfigured; its glm-5.3-max stays the user's), museion-pass1/-pass2 created fresh with the #132 sonnet defaults + 24k budget via the hermes 'config set' CLI rail, marker-gated so a re-pass is a no-op and Settings changes survive; a failed provision names the profile on the #48 card. Skills move to ONE master copy under Application Support, symlinked per profile per the #133 allocation (P1 9 · P2 8 · Chat 10); copy-era dirs migrate on byte-match (.DS_Store-tolerant, symlink-refusing), diverged dirs stay copies, user skills untouched (G3a). Backup widens to one three-subdir stamp, any-live-skip-all; RESTORE.md names the three folders. Two review rounds (standards+spec, then finish-audit ponytail/ security/general) caught and fixed: the dead .DS_Store leniency in treesByteMatch, exit-code-only config-set trust, the swallowed marker write (defaults-stomp re-arm), symlink-following in the untrusted tree, and a fixture-skewed count pin. Suite: 412 passed / 414 (fork flake green in isolation 16/16; UI launch = pre-existing testmanagerd flake, failed identically pre-change). DOX: Museion/AGENTS.md, MuseionTests/AGENTS.md, ref/writing skills/AGENTS.md rewritten. Closes #134
246 lines
7.5 KiB
Swift
246 lines
7.5 KiB
Swift
//
|
||
// EngineGateView.swift
|
||
// Museion
|
||
//
|
||
// Ceiling note: a pathological all-hang machine holds the checking card up to
|
||
// ~N×5 s (per-candidate timeout, ticket #36) — not 5 s total.
|
||
//
|
||
|
||
import SwiftUI
|
||
|
||
/// The launch Engine gate: one blocking card, three states (tickets #38/#40/#41).
|
||
/// Shown once per app-launch over the first window; the sheet never closes itself.
|
||
struct EngineGateView: View {
|
||
/// Shared app-scoped model — one check per app-launch even if ⌘N opens more windows (#41).
|
||
let model: EngineGateModel
|
||
/// Fires the moment a check passes — provisioning (#13) starts here, in parallel (ticket #41).
|
||
var onEnginePass: (@MainActor @Sendable () -> Void)?
|
||
/// Unlock point: pass-card dismissal (ticket #41). The sheet's only exit.
|
||
var onDismiss: (@MainActor @Sendable () -> Void)?
|
||
|
||
var body: some View {
|
||
VStack(spacing: 14) {
|
||
switch model.phase {
|
||
case .idle, .checking:
|
||
checkingCard
|
||
case let .pass(engineVersion, binaryPath):
|
||
passCard(engineVersion: engineVersion, binaryPath: binaryPath)
|
||
case let .fail(firstProbePath, stderrExcerpt):
|
||
failCard(firstProbePath: firstProbePath, stderrExcerpt: stderrExcerpt)
|
||
}
|
||
}
|
||
.padding(24)
|
||
.frame(width: 460)
|
||
.onAppear {
|
||
model.onPass = onEnginePass
|
||
Task { await model.beginAutomaticCheck() }
|
||
}
|
||
.interactiveDismissDisabled()
|
||
}
|
||
|
||
// MARK: Checking (ticket #41) — spinner, no buttons; per-candidate timeout flips the card to fail
|
||
|
||
private var checkingCard: some View {
|
||
VStack(spacing: 14) {
|
||
ProgressView()
|
||
.controlSize(.regular)
|
||
.padding(.bottom, 2)
|
||
Text("Checking the Engine…")
|
||
.font(.title3)
|
||
Text("Running hermes acp --check")
|
||
.font(.callout)
|
||
.foregroundStyle(.secondary)
|
||
}
|
||
}
|
||
|
||
// MARK: Pass (ticket #40) — check icon, version, explicit dismiss; no re-check
|
||
|
||
private func passCard(engineVersion: String, binaryPath: String) -> some View {
|
||
VStack(spacing: 14) {
|
||
Image(systemName: "checkmark.circle.fill")
|
||
.font(.system(size: 30))
|
||
.foregroundStyle(.secondary)
|
||
Text("Engine ready")
|
||
.font(.title3)
|
||
Text("Hermes \(engineVersion) answered the health check. The mentor is available.")
|
||
.font(.callout)
|
||
.foregroundStyle(.secondary)
|
||
.multilineTextAlignment(.center)
|
||
Text(binaryPath)
|
||
.font(.system(size: 10, design: .monospaced))
|
||
.foregroundStyle(.tertiary)
|
||
.lineLimit(1)
|
||
.truncationMode(.middle)
|
||
Button("Start Writing") {
|
||
onDismiss?()
|
||
}
|
||
.keyboardShortcut(.defaultAction)
|
||
.buttonStyle(.borderedProminent)
|
||
}
|
||
}
|
||
|
||
// MARK: Fail (ticket #40) — two install steps, re-check, collapsed stderr
|
||
|
||
private func failCard(firstProbePath: String, stderrExcerpt: String) -> some View {
|
||
VStack(spacing: 14) {
|
||
Image(systemName: "exclamationmark.triangle.fill")
|
||
.font(.system(size: 30))
|
||
.foregroundStyle(.orange)
|
||
Text("Museion needs its engine")
|
||
.font(.title3)
|
||
Text("The Hermes engine wasn't found or didn't answer. Museion is paused until it's installed — Passes and Sessions need it.")
|
||
.font(.callout)
|
||
.foregroundStyle(.secondary)
|
||
.multilineTextAlignment(.center)
|
||
|
||
installSteps
|
||
|
||
Button("Re-check") {
|
||
Task { await model.runCheck() }
|
||
}
|
||
.buttonStyle(.borderedProminent)
|
||
|
||
if !stderrExcerpt.isEmpty {
|
||
DisclosureGroup("Technical details") {
|
||
VStack(alignment: .leading, spacing: 6) {
|
||
Text(stderrExcerpt)
|
||
.font(.system(size: 10, design: .monospaced))
|
||
.foregroundStyle(.secondary)
|
||
.textSelection(.enabled)
|
||
Text("Probed: \(firstProbePath)")
|
||
.font(.system(size: 10, design: .monospaced))
|
||
.foregroundStyle(.tertiary)
|
||
}
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
}
|
||
.font(.system(size: 11))
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
} else {
|
||
Text("Probed: \(firstProbePath)")
|
||
.font(.system(size: 10, design: .monospaced))
|
||
.foregroundStyle(.tertiary)
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Ticket #40: exactly two steps + the docs link. Nothing else.
|
||
private var installSteps: some View {
|
||
VStack(alignment: .leading, spacing: 10) {
|
||
HStack(alignment: .top, spacing: 8) {
|
||
Text("1.").monospacedDigit().foregroundStyle(.secondary)
|
||
VStack(alignment: .leading, spacing: 4) {
|
||
Text(installCommand)
|
||
.font(.system(size: 11, design: .monospaced))
|
||
.textSelection(.enabled)
|
||
.fixedSize(horizontal: false, vertical: true)
|
||
Button {
|
||
NSPasteboard.general.clearContents()
|
||
NSPasteboard.general.setString(installCommand, forType: .string)
|
||
} label: {
|
||
Label("Copy", systemImage: "doc.on.doc")
|
||
}
|
||
.controlSize(.small)
|
||
.buttonStyle(.link)
|
||
.font(.system(size: 11))
|
||
}
|
||
}
|
||
HStack(alignment: .top, spacing: 8) {
|
||
Text("2.").monospacedDigit().foregroundStyle(.secondary)
|
||
Text("Come back here and click Re-check.")
|
||
}
|
||
Link("Installation guide", destination: URL(string: "https://hermes-agent.nousresearch.com/docs")!)
|
||
.font(.system(size: 11))
|
||
.frame(maxWidth: .infinity)
|
||
}
|
||
.padding(12)
|
||
.background(.quaternary.opacity(0.3), in: RoundedRectangle(cornerRadius: 8))
|
||
}
|
||
|
||
private let installCommand = "curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash"
|
||
}
|
||
|
||
/// #48: provisioning failure card — separate from the gate, which never re-raises.
|
||
/// Presented only after the gate sheet has been dismissed.
|
||
struct ProvisioningFailureCard: View {
|
||
let model: ProvisioningModel
|
||
/// Retry re-runs the whole idempotent pass with the gate's binary (#45).
|
||
let onRetry: () -> Void
|
||
|
||
/// Snapshot taken when the card appears; a successful Retry nils
|
||
/// `model.lastFailure` mid-presentation, and reading it live would blank
|
||
/// the card during its dismiss animation.
|
||
@State private var failure: ProfileProvisioner.Outcome?
|
||
|
||
var body: some View {
|
||
if let failure, case let .failed(profile, phase, excerpt) = failure {
|
||
VStack(spacing: 14) {
|
||
Image(systemName: "exclamationmark.triangle.fill")
|
||
.font(.system(size: 30))
|
||
.foregroundStyle(.orange)
|
||
Text(phase.rawValue)
|
||
.font(.title3)
|
||
if let profile {
|
||
// #134: the card names the failing profile — with three
|
||
// surface profiles, "which one?" is the first question.
|
||
Text(profile)
|
||
.font(.system(size: 10, design: .monospaced))
|
||
.foregroundStyle(.tertiary)
|
||
}
|
||
Text("Museion couldn't finish setting up the writing profiles. Nothing is lost — the setup is safe to run again.")
|
||
.font(.callout)
|
||
.foregroundStyle(.secondary)
|
||
.multilineTextAlignment(.center)
|
||
|
||
if !excerpt.isEmpty {
|
||
DisclosureGroup("Technical details") {
|
||
Text(excerpt)
|
||
.font(.system(size: 10, design: .monospaced))
|
||
.foregroundStyle(.secondary)
|
||
.textSelection(.enabled)
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
}
|
||
.font(.system(size: 11))
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
}
|
||
|
||
HStack {
|
||
Button("Not Now") {
|
||
model.deferFailure()
|
||
}
|
||
.keyboardShortcut(.cancelAction)
|
||
Button("Retry") {
|
||
onRetry()
|
||
}
|
||
.keyboardShortcut(.defaultAction)
|
||
.buttonStyle(.borderedProminent)
|
||
}
|
||
}
|
||
.padding(24)
|
||
.frame(width: 460)
|
||
.onAppear(perform: refreshIfNewFailure)
|
||
.onChange(of: model.lastFailure) {
|
||
refreshIfNewFailure()
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Refresh only on a new failure — never on clearing, so the card stays
|
||
/// rendered until the sheet dismisses it.
|
||
private func refreshIfNewFailure() {
|
||
if case .failed = model.lastFailure {
|
||
failure = model.lastFailure
|
||
}
|
||
}
|
||
}
|
||
|
||
#Preview {
|
||
EngineGateView(model: EngineGateModel())
|
||
}
|
||
|
||
#Preview("provisioning failure") {
|
||
ProvisioningFailureCard(
|
||
model: ProvisioningModel(),
|
||
onRetry: {},
|
||
)
|
||
}
|