feat(launch): flip to the gateless launch (#151)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Wayfinder map #148's terminal slice (decisions #150 architecture, #149 UX variant A): every launch now opens straight into the workspace. The engine check (hermes acp --check) runs async from ContentView.task via AppGateState.startLaunchCheck — provisioning (x3 profiles) and the daily backup auto-fire the moment it passes (the gate era's exact onEnginePass chain, moved verbatim; once per app-launch, first window only, no-op under hosted tests). Nothing blocks: the blocking gate sheet, the placeholder logo screen, gateRaised/gateDismissed, EngineGateView, and the ProvisioningFailureCard sheet are deleted (net -350 lines with the additions). Engine state stays visible instead of interrupting: a 44x44 rail pill above Archive (8pt pulsing accent dot while checking, warning glyph on an accent-12% wash when failed, nothing at all once healthy — the slot collapses and the rail spacing closes) and mono-10 mentor-pane header states (checking... / engine missing / setup failed / hermes <base> once ready — the BASE version, never the gate's derived string; session chip renders only once ready). Failure auto-expands an anchored floating card (340pt, accent border — floats, never blocks): engine-missing carries #40's install steps with the gateless correction plus Copy, guide link, Re-check (disabled-while-checking), stderr + probed path; provisioning failure rides the same card (failing profile named, Retry inline). Focus mode recesses the card with the rail. Panes spawn the engine the moment the check lands (.task(id: binaryPath) on the nil->value arrival; a nil binary never calls openSession — that path lands the crash card). state.json semantics unchanged (About still reads it); #38's no-silent-degradation AC survives, carried by the pill. New GatelessLaunchTests pin the seam (hosted-test no-op, chain armed, pill + mentor-header visibility mappings — flip-verified); EngineGateTests byte-untouched and green; the dead deferFailure (#48's Not-Now) deleted with its test. PRD G1 amended; gateless DOX pass (Museion/AGENTS.md engine section rewritten); CHANGELOG; devlog. The #149 prototype ships lint-clean. Verified: full-scheme test 582 passed / 0 failed / 0 skipped (xcresult executed count, unit + UI), swiftformat lint clean, swiftlint 0 errors on touched files, finish-audit fanout clean (ponytail/security/general; 5 fixes applied, header-mapping pins flip-discriminated and restored). Closes #151 Closes #139
This commit is contained in:
1 parent
4065c31ec8
commit
55eff3a754
19 files changed
+1721
-384
No files matched your search
@@ -0,0 +1,393 @@
|
||||
//
|
||||
// EngineStatusView.swift
|
||||
// Museion
|
||||
//
|
||||
// #151 (map #148): the gateless engine-status surfaces — the rail pill
|
||||
// and the anchored fail card (#149's variant-A verdict, prototype
|
||||
// prototypes/GatelessStatusPrototype.swift). Quiet when healthy: once the
|
||||
// engine answered and provisioning finished, nothing renders anywhere.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// The pill/card state derivation — pure, test-pinned (#151). The gate's
|
||||
/// phase machine is the source; a provisioning failure rides the same
|
||||
/// failed surface under a passed gate.
|
||||
enum EngineStatusSurface {
|
||||
enum Visibility: Equatable {
|
||||
case hidden
|
||||
case pulsing
|
||||
case failed
|
||||
}
|
||||
|
||||
static func visibility(phase: EngineGateModel.Phase, provisioningFailed: Bool) -> Visibility {
|
||||
switch phase {
|
||||
case .idle: .hidden
|
||||
case .checking: .pulsing
|
||||
case .pass: provisioningFailed ? .failed : .hidden
|
||||
case .fail: .failed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// #149 variant A: the 44×44 rail slot above Archive — an 8pt pulsing
|
||||
/// accent dot while checking (no text), the warning glyph on an accent-12%
|
||||
/// wash when failed, nothing at all once healthy (the slot collapses and
|
||||
/// the rail spacing closes). Slot click re-opens a collapsed fail card.
|
||||
struct EngineStatusPill: View {
|
||||
let visibility: EngineStatusSurface.Visibility
|
||||
/// Opens the anchored card (only meaningful in the failed state).
|
||||
var onOpen: () -> Void
|
||||
|
||||
var body: some View {
|
||||
Button(action: onOpen) {
|
||||
ZStack {
|
||||
if visibility == .failed {
|
||||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||||
.fill(DesignTokens.accent.opacity(0.12))
|
||||
}
|
||||
switch visibility {
|
||||
case .pulsing:
|
||||
Circle()
|
||||
.fill(DesignTokens.accent)
|
||||
.frame(width: 8, height: 8)
|
||||
.pulsing()
|
||||
case .failed:
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.font(.system(size: 15))
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
case .hidden:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
.frame(width: 44, height: 44)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help(helpText)
|
||||
.accessibilityLabel(helpText)
|
||||
}
|
||||
|
||||
private var helpText: String {
|
||||
switch visibility {
|
||||
case .pulsing: "Checking the engine"
|
||||
case .failed: "Engine problem — click for details"
|
||||
case .hidden: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The anchored fail card (#149): 340pt wide, bottom-leading at
|
||||
/// railWidth + 12 / bottom 14 — surface bg, accent-0.5 border, radius 12,
|
||||
/// shadow. Floats over content; never blocks, never pushes layout. Engine
|
||||
/// failure and provisioning failure ride the same shell (#40 copy with the
|
||||
/// gateless subtitle — nothing pauses).
|
||||
struct EngineStatusCard: View {
|
||||
let gate: AppGateState
|
||||
let onCollapse: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
Text(title)
|
||||
.font(.system(size: 15, weight: .semibold, design: DesignTokens.serif))
|
||||
Spacer()
|
||||
Button(action: onCollapse) {
|
||||
Image(systemName: "chevron.down")
|
||||
.font(.system(size: 10, weight: .semibold))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.help("Collapse to the pill")
|
||||
.accessibilityLabel("Collapse to the pill")
|
||||
}
|
||||
if case .fail = gate.gateModel.phase {
|
||||
engineContent
|
||||
} else {
|
||||
setupContent
|
||||
}
|
||||
}
|
||||
.padding(16)
|
||||
.frame(width: 340, alignment: .leading)
|
||||
.background(DesignTokens.surface, in: RoundedRectangle(cornerRadius: 12))
|
||||
.overlay(RoundedRectangle(cornerRadius: 12).strokeBorder(DesignTokens.accent.opacity(0.5)))
|
||||
.shadow(radius: 16, y: 4)
|
||||
}
|
||||
|
||||
private var title: String {
|
||||
if case .fail = gate.gateModel.phase {
|
||||
return "Museion needs its engine"
|
||||
}
|
||||
return "Setup failed"
|
||||
}
|
||||
|
||||
// MARK: Engine missing (#40 copy, gateless correction)
|
||||
|
||||
@ViewBuilder
|
||||
private var engineContent: some View {
|
||||
if case let .fail(firstProbePath, stderrExcerpt) = gate.gateModel.phase {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text(
|
||||
"The Hermes engine wasn't found or didn't answer. Passes and Sessions need it — the editor keeps working.",
|
||||
)
|
||||
.font(.system(size: 12.5))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
||||
installSteps
|
||||
|
||||
recheckRow
|
||||
|
||||
technicalDetails(stderrExcerpt: stderrExcerpt, firstProbePath: firstProbePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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(DesignTokens.muted)
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(installCommand)
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.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(DesignTokens.muted)
|
||||
Text("Come back here and click Re-check.")
|
||||
.font(.system(size: 12))
|
||||
}
|
||||
Link("Installation guide", destination: URL(string: "https://hermes-agent.nousresearch.com/docs")!)
|
||||
.font(.system(size: 11))
|
||||
}
|
||||
.padding(12)
|
||||
.background(DesignTokens.background, in: RoundedRectangle(cornerRadius: 8))
|
||||
.overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(DesignTokens.border))
|
||||
}
|
||||
|
||||
private let installCommand = "curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash"
|
||||
|
||||
/// Re-check (#149): accent, disabled while checking, label "Checking…".
|
||||
private var recheckRow: some View {
|
||||
HStack {
|
||||
Button {
|
||||
Task { await gate.gateModel.runCheck() }
|
||||
} label: {
|
||||
HStack(spacing: 6) {
|
||||
if gate.gateModel.phase == .checking {
|
||||
ProgressView().controlSize(.small)
|
||||
}
|
||||
Text(gate.gateModel.phase == .checking ? "Checking…" : "Re-check")
|
||||
}
|
||||
.frame(minWidth: 120)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(DesignTokens.accent)
|
||||
.disabled(gate.gateModel.phase == .checking)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
/// stderr excerpt + the probed path. Empty stderr keeps the bare
|
||||
/// Probed line (the not-found case answers nothing).
|
||||
@ViewBuilder
|
||||
private func technicalDetails(stderrExcerpt: String, firstProbePath: String) -> some View {
|
||||
if !stderrExcerpt.isEmpty {
|
||||
DisclosureGroup("Technical details") {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(stderrExcerpt)
|
||||
.font(.system(size: 10, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.textSelection(.enabled)
|
||||
probedLine(firstProbePath)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.font(.system(size: 11))
|
||||
} else {
|
||||
probedLine(firstProbePath)
|
||||
}
|
||||
}
|
||||
|
||||
private func probedLine(_ firstProbePath: String) -> some View {
|
||||
Text("Probed: \(firstProbePath)")
|
||||
.font(.system(size: 10, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted.opacity(0.7))
|
||||
}
|
||||
|
||||
// MARK: Provisioning failure (#48 reborn, non-modal)
|
||||
|
||||
/// Live-reads the model: a successful Retry nils `lastFailure` and the
|
||||
/// whole surface disappears — no dismiss-animation snapshot needed.
|
||||
@ViewBuilder
|
||||
private var setupContent: some View {
|
||||
if case let .failed(profile, phase, excerpt) = gate.provisioning.lastFailure {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text(phase.rawValue)
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
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: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted.opacity(0.7))
|
||||
}
|
||||
Text(
|
||||
"Museion couldn't finish setting up the writing profiles. Nothing is lost — the setup is safe to run again.",
|
||||
)
|
||||
.font(.system(size: 12.5))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
||||
HStack {
|
||||
Button("Retry") {
|
||||
Task {
|
||||
await gate.provisioning.runPass(hermesBinary: gate.gateModel.currentBinaryPath)
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(DesignTokens.accent)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !excerpt.isEmpty {
|
||||
DisclosureGroup("Technical details") {
|
||||
Text(excerpt)
|
||||
.font(.system(size: 10, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.font(.system(size: 11))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Mentor header states (#151, #149's contract)
|
||||
|
||||
/// The mentor pane header's mono-10 engine states, one per gate verdict:
|
||||
/// "checking the engine…" muted + mini spinner / "engine missing" accent
|
||||
/// with help / "setup failed" accent / `hermes <base>` once ready. The
|
||||
/// gate's phase machine is the source; nil gate (previews) derives from
|
||||
/// the mentor model alone.
|
||||
struct MentorEngineStatus: View {
|
||||
let gate: AppGateState?
|
||||
let model: MentorSessionModel
|
||||
|
||||
/// #151: one state per gate verdict (internal — the pure mapping's
|
||||
/// pins name the cases).
|
||||
enum EngineState {
|
||||
case checking
|
||||
case engineMissing
|
||||
case setupFailed
|
||||
case ready
|
||||
}
|
||||
|
||||
/// The gate-driven mapping, pure and test-pinned (#151) — engine
|
||||
/// failure outranks a lingering provisioning failure (no engine →
|
||||
/// Retry can't run anyway).
|
||||
static func state(phase: EngineGateModel.Phase, provisioningFailed: Bool) -> EngineState {
|
||||
switch phase {
|
||||
case .idle, .checking: .checking
|
||||
case .fail: .engineMissing
|
||||
case .pass: provisioningFailed ? .setupFailed : .ready
|
||||
}
|
||||
}
|
||||
|
||||
/// No gate (previews): derive from the mentor model alone.
|
||||
private var state: EngineState {
|
||||
if let gate {
|
||||
Self.state(phase: gate.gateModel.phase, provisioningFailed: gate.provisioning.hasFailure)
|
||||
} else {
|
||||
model.phase == .idle ? .checking : .ready
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
switch state {
|
||||
case .checking:
|
||||
HStack(spacing: 5) {
|
||||
ProgressView().controlSize(.mini)
|
||||
Text("checking the engine…")
|
||||
}
|
||||
.font(.system(size: 10, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.layoutPriority(1)
|
||||
case .engineMissing:
|
||||
Text("engine missing")
|
||||
.font(.system(size: 10, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
.help("Passes and Sessions need the Hermes engine")
|
||||
case .setupFailed:
|
||||
Text("setup failed")
|
||||
.font(.system(size: 10, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
.help("Profile setup didn't finish — retry from the rail's status card")
|
||||
case .ready:
|
||||
// The BASE version (handshake answer first, the gate's derived
|
||||
// string `+`-stripped meanwhile — the drift-note contract),
|
||||
// plus the advisory drift note when they diverge.
|
||||
if !readyVersion.isEmpty {
|
||||
HStack(spacing: 8) {
|
||||
Text("hermes \(readyVersion)")
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
if let note = model.versionNote {
|
||||
Text(note)
|
||||
.help(note)
|
||||
.foregroundStyle(.orange)
|
||||
}
|
||||
}
|
||||
.font(.system(size: 10, design: DesignTokens.mono))
|
||||
.foregroundStyle(.tertiary)
|
||||
.layoutPriority(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var readyVersion: String {
|
||||
if let engineVersion = model.engineVersion {
|
||||
return engineVersion
|
||||
}
|
||||
if case let .pass(version, _)? = gate?.gateModel.phase {
|
||||
return String(version.prefix(while: { $0 != "+" }))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
/// The checking dot's pulse (#149: 8pt accent dot, pulsing). The
|
||||
/// repeatForever animation rides the onAppear state flip — a constant
|
||||
/// animation value never starts.
|
||||
private struct PulsingModifier: ViewModifier {
|
||||
@State private var dim = false
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.opacity(dim ? 0.35 : 1)
|
||||
.animation(.easeInOut(duration: 0.55).repeatForever(autoreverses: true), value: dim)
|
||||
.onAppear { dim = true }
|
||||
}
|
||||
}
|
||||
|
||||
private extension View {
|
||||
func pulsing() -> some View {
|
||||
modifier(PulsingModifier())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user