Files
museion/prototypes/GatelessStatusPrototype.swift
T
AlexKucera 55eff3a754
CI / ci (push) Canceled after 0s
feat(launch): flip to the gateless launch (#151)
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
2026-11-03 16:50:55 +01:00

948 lines
26 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// PROTOTYPE — wayfinder #149 "Engine status surfaces" (map #148, origin #139).
// THROWAWAY; not part of the app target.
// Run: swiftc -parse-as-library prototypes/GatelessStatusPrototype.swift -o /tmp/gateless_proto && /tmp/gateless_proto
// (←/→ arrows cycle variants; the bottom bar flips the scenario and re-fires the check)
//
// The gateless engine-status surfaces on a mock of TODAY's workspace (post-#89
// tokens, real rail/library/mentor geometry). The map settled the surface — a
// rail-bottom pill + mentor-pane header states, quiet when healthy — so the three
// variants differ on EXPANSION BEHAVIOR, the fact this ticket pins:
// A — Rail slot + anchored card: 44×44 slot above Archive; fail AUTO-expands a
// floating card at the rail's bottom-left. Coverage-first.
// B — Overflow capsule: capsule pinned at the window's bottom-left corner,
// beside the Settings rail button; fail stays collapsed, click expands in
// place above it. Calm-first.
// C — Beacon + mentor inline: the rail slot is a pure status beacon; the fail
// detail renders INSIDE the mentor column (where the engine matters).
// Fail content = #40's copy (install steps, Re-check, technical details) with the
// gateless correction — nothing "pauses"; the editor keeps working. Provisioning
// failure rides the same shape: profile named, Retry inline (the
// ProvisioningFailureCard sheet dies). Mentor-pane header check/fail states react
// in every variant.
import SwiftUI
// MARK: - Tokens (Museion/DesignTokens.swift verbatim, post-#89 calibration)
enum Tok {
static let background = Color(hex: 0xFAF9F3)
static let surface = Color(hex: 0xFFFEFB)
static let foreground = Color(hex: 0x1A1916)
static let muted = Color(hex: 0x6B6964)
static let border = Color(hex: 0xE8E5DF)
static let accent = Color(hex: 0xC96442)
static let foregroundSoft = Color(hex: 0x1A1916).opacity(0.06)
static let railWidth: CGFloat = 56
static let libraryWidth: CGFloat = 232
static let mentorWidth: CGFloat = 356
static let radius: CGFloat = 10
static func display(_ size: CGFloat, _ weight: Font.Weight = .regular) -> Font {
.system(size: size, design: .serif).weight(weight)
}
static func mono(_ size: CGFloat) -> Font {
.system(size: size, design: .monospaced)
}
}
extension Color {
init(hex: UInt32) {
self.init(.sRGB,
red: Double((hex >> 16) & 0xFF) / 255,
green: Double((hex >> 8) & 0xFF) / 255,
blue: Double(hex & 0xFF) / 255)
}
}
// MARK: - Mock state (EngineGateModel's phase machine, repurposed)
enum Variant: String, CaseIterable {
case slot = "A"
case capsule = "B"
case inline = "C"
var label: String {
switch self {
case .slot: "Rail slot + card"
case .capsule: "Overflow capsule"
case .inline: "Beacon + mentor inline"
}
}
}
enum Scenario: String, CaseIterable, Identifiable {
case engineMissing = "Engine missing"
case setupFails = "Pass → setup fails"
case healthy = "Healthy"
var id: String {
rawValue
}
}
final class ProtoModel: ObservableObject {
enum Phase: Equatable {
case checking
case ready(version: String)
case engineFailed
case setupFailed(profile: String)
}
@Published var phase: Phase = .checking
@Published var scenario: Scenario = .engineMissing {
didSet { check() }
}
/// A/B card expansion. Fail auto-expands in A, starts collapsed in B.
@Published var expanded = true
/// The derived-version shape the gate really records.
let version = "0.21.5+2177.g735e426"
let probedPath = "~/.local/bin/hermes"
private var token = 0
func check() {
token += 1
let myToken = token
phase = .checking
expanded = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { [weak self] in
guard let self, token == myToken else { return }
switch scenario {
case .engineMissing:
phase = .engineFailed
case .healthy:
phase = .ready(version: version)
case .setupFails:
// Provisioning auto-fires on pass and runs quiet; only its
// failure raises the orange surface.
phase = .ready(version: version)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.9) { [weak self] in
guard let self, token == myToken else { return }
phase = .setupFailed(profile: "museion-pass2")
}
}
}
}
/// Quiet-when-healthy: ready AND setup done = nothing renders anywhere.
var isQuiet: Bool {
if case .ready = phase {
return true
}
return false
}
var isFailed: Bool {
switch phase {
case .engineFailed, .setupFailed: true
default: false
}
}
}
// MARK: - Shared status content (#40 copy, gateless correction)
/// The engine-missing card body: install steps, Re-check, technical details.
struct EngineFailContent: View {
@EnvironmentObject var model: ProtoModel
var body: some View {
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(Tok.muted)
.fixedSize(horizontal: false, vertical: true)
InstallSteps()
RecheckRow()
DisclosureGroup("Technical details") {
VStack(alignment: .leading, spacing: 6) {
Text("zsh:1: command not found: hermes")
.font(Tok.mono(10))
.foregroundStyle(Tok.muted)
.textSelection(.enabled)
Text("Probed: \(model.probedPath)")
.font(Tok.mono(10))
.foregroundStyle(Tok.muted.opacity(0.7))
}
.frame(maxWidth: .infinity, alignment: .leading)
}
.font(.system(size: 11))
}
}
}
/// Ticket #40: exactly two steps + the docs link. Nothing else.
struct InstallSteps: View {
private let installCommand = "curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash"
var body: some View {
VStack(alignment: .leading, spacing: 10) {
HStack(alignment: .top, spacing: 8) {
Text("1.").font(Tok.mono(11)).foregroundStyle(Tok.muted)
VStack(alignment: .leading, spacing: 4) {
Text(installCommand)
.font(Tok.mono(11))
.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.").font(Tok.mono(11)).foregroundStyle(Tok.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(Tok.background, in: RoundedRectangle(cornerRadius: 8))
.overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(Tok.border))
}
}
struct RecheckRow: View {
@EnvironmentObject var model: ProtoModel
var body: some View {
HStack {
Button {
model.check()
} label: {
HStack(spacing: 6) {
if model.phase == .checking {
ProgressView().controlSize(.small)
}
Text(model.phase == .checking ? "Checking…" : "Re-check")
}
.frame(minWidth: 120)
}
.buttonStyle(.borderedProminent)
.tint(Tok.accent)
.disabled(model.phase == .checking)
Spacer()
}
}
}
/// The provisioning-failure shape (ProvisioningFailureCard reborn, non-modal):
/// phase title, failing profile named, Retry inline.
struct SetupFailContent: View {
@EnvironmentObject var model: ProtoModel
let profile: String
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("configure")
.font(Tok.mono(11))
.foregroundStyle(Tok.muted)
Text(profile)
.font(Tok.mono(10))
.foregroundStyle(Tok.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(Tok.muted)
.fixedSize(horizontal: false, vertical: true)
HStack {
Button("Retry") {
model.check()
}
.buttonStyle(.borderedProminent)
.tint(Tok.accent)
Spacer()
}
DisclosureGroup("Technical details") {
Text("profile create \(profile): config set failed (exit 1)")
.font(Tok.mono(10))
.foregroundStyle(Tok.muted)
.textSelection(.enabled)
.frame(maxWidth: .infinity, alignment: .leading)
}
.font(.system(size: 11))
}
}
}
/// One card shell for both failure kinds: orange-edged title row + content.
struct StatusCard: View {
@EnvironmentObject var model: ProtoModel
/// A/B only: chevron collapses back to the pill. Nil in C (inline, no collapse).
var collapsible = true
var body: some View {
VStack(alignment: .leading, spacing: 12) {
HStack(spacing: 8) {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundStyle(Tok.accent)
Text(title)
.font(Tok.display(15, .semibold))
Spacer()
if collapsible {
Button {
model.expanded = false
} label: {
Image(systemName: "chevron.down")
.font(.system(size: 10, weight: .semibold))
}
.buttonStyle(.plain)
.foregroundStyle(Tok.muted)
.help("Collapse to the pill")
}
}
if case let .setupFailed(profile) = model.phase {
SetupFailContent(profile: profile)
} else {
EngineFailContent()
}
}
.padding(16)
.frame(width: 340, alignment: .leading)
.background(Tok.surface, in: RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).strokeBorder(Tok.accent.opacity(0.5)))
.shadow(radius: 16, y: 4)
}
private var title: String {
if case .setupFailed = model.phase {
return "Setup failed"
}
return "Museion needs its engine"
}
}
// MARK: - Mock workspace (today's real geometry: rail | library | editor | mentor)
struct MockWorkspace: View {
@EnvironmentObject var model: ProtoModel
let variant: Variant
var body: some View {
HStack(spacing: 0) {
rail
verticalBorder
library
verticalBorder
editor
verticalBorder
mentor
}
.background(Tok.background)
// The gateless contract: the workspace is the first frame; status
// floats over it and NEVER blocks. A only, on fail.
.overlay(alignment: .bottomLeading) {
if variant == .slot {
variantAOverlay.animation(.spring(duration: 0.3), value: model.phase)
}
}
.overlay(alignment: .bottomLeading) {
if variant == .capsule {
variantBOverlay.animation(.spring(duration: 0.3), value: model.phase)
}
}
}
}
// MARK: Rail (real order: Posts/Sessions/Learnings/Trends … Archive/Settings)
extension MockWorkspace {
private var rail: some View {
VStack(spacing: 8) {
MockRailButton(icon: "doc.text", label: "Posts", selected: true)
MockRailButton(icon: "bubble.left", label: "Sessions")
MockRailButton(icon: "cube", label: "Learnings")
MockRailButton(icon: "chart.xyaxis.line", label: "Trends")
Spacer(minLength: 12)
// The pill's slot sits above Archive, beside-bottom of the rail.
// B has no slot (its capsule lives at the window corner).
if variant != .capsule, !model.isQuiet {
statusSlot
}
MockRailButton(icon: "archivebox", label: "Archive")
MockRailButton(icon: "gearshape", label: "Settings")
}
.padding(.horizontal, 4)
.padding(.vertical, 8)
.frame(width: Tok.railWidth)
.frame(maxHeight: .infinity)
.animation(.easeInOut(duration: 0.2), value: model.isQuiet)
}
/// A: clickable beacon that reopens the auto-expanded card.
/// C: pure beacon — the detail lives in the mentor pane.
private var statusSlot: some View {
Button {
if variant == .slot {
model.expanded = true
}
} label: {
ZStack {
RoundedRectangle(cornerRadius: Tok.radius)
.fill(model.isFailed ? Tok.accent.opacity(0.12) : .clear)
switch model.phase {
case .checking:
Circle()
.fill(Tok.accent)
.frame(width: 8, height: 8)
.modifier(Pulse(active: true))
case .engineFailed, .setupFailed:
Image(systemName: "exclamationmark.triangle.fill")
.font(.system(size: 15))
.foregroundStyle(Tok.accent)
case .ready:
EmptyView()
}
}
.frame(width: 44, height: 44)
}
.buttonStyle(.plain)
.help(slotHelp)
}
private var slotHelp: String {
switch model.phase {
case .checking: "Checking the engine"
case .engineFailed: "Engine missing — click for install steps"
case .setupFailed: "Profile setup failed — click for details"
case .ready: ""
}
}
private var verticalBorder: some View {
Rectangle().fill(Tok.border).frame(width: 1)
}
}
// MARK: Variant A — fail AUTO-expands a card anchored at the rail's bottom-left
extension MockWorkspace {
@ViewBuilder
private var variantAOverlay: some View {
if model.isFailed, model.expanded {
StatusCard()
.padding(.leading, Tok.railWidth + 12)
.padding(.bottom, 14)
.transition(.opacity.combined(with: .move(edge: .bottom)))
}
}
}
// MARK: Variant B — capsule at the window's bottom-left; click expands in place
extension MockWorkspace {
@ViewBuilder
private var variantBOverlay: some View {
if !model.isQuiet {
VStack(alignment: .leading, spacing: 8) {
if model.isFailed, model.expanded {
StatusCard()
.transition(.opacity.combined(with: .move(edge: .bottom)))
}
capsule
}
.padding(.leading, 8)
.padding(.bottom, 12)
}
}
private var capsule: some View {
Button {
if model.isFailed {
model.expanded.toggle()
}
} label: {
HStack(spacing: 7) {
switch model.phase {
case .checking:
Circle()
.fill(Tok.accent)
.frame(width: 7, height: 7)
.modifier(Pulse(active: true))
Text("Checking engine")
.font(Tok.mono(11))
.foregroundStyle(Tok.foreground)
case .engineFailed:
Image(systemName: "exclamationmark.triangle.fill")
.font(.system(size: 11))
.foregroundStyle(Tok.accent)
Text("Engine missing")
.font(Tok.mono(11))
.foregroundStyle(Tok.foreground)
chevron
case .setupFailed:
Image(systemName: "exclamationmark.triangle.fill")
.font(.system(size: 11))
.foregroundStyle(Tok.accent)
Text("Setup failed")
.font(Tok.mono(11))
.foregroundStyle(Tok.foreground)
chevron
case .ready:
EmptyView()
}
}
.padding(.horizontal, 12)
.frame(minHeight: 30)
.background(Tok.surface, in: Capsule())
.overlay(Capsule().strokeBorder(model.isFailed ? Tok.accent : Tok.border))
.shadow(radius: 8, y: 2)
}
.buttonStyle(.plain)
}
private var chevron: some View {
Image(systemName: model.expanded ? "chevron.down" : "chevron.up")
.font(.system(size: 9, weight: .semibold))
.foregroundStyle(Tok.muted)
}
}
// MARK: Library column (#108 shape: project head → Pass State groups → rows)
extension MockWorkspace {
private var library: some View {
VStack(spacing: 0) {
PaneHeader(title: "Posts") {
Text("+ New")
.font(Tok.mono(11))
.foregroundStyle(Tok.muted)
}
ScrollView {
VStack(alignment: .leading, spacing: 4) {
HStack(alignment: .firstTextBaseline, spacing: 8) {
Image(systemName: "chevron.down")
.font(.system(size: 9, weight: .semibold))
.foregroundStyle(Tok.muted)
Text("essays")
.font(Tok.display(15, .semibold))
.textCase(.lowercase)
Text("· 4")
.font(Tok.mono(11))
.foregroundStyle(Tok.muted)
}
.padding(.top, 14)
.padding(.horizontal, 14)
.padding(.bottom, 6)
passStateLabel("first draft", indent: true)
libraryRow(title: "On rereading Orwell", meta: "First Draft · writer", selected: true)
passStateLabel("pass 1 done")
libraryRow(title: "The draft knows", meta: "Pass 1 · writer")
libraryRow(title: "Notes toward a style", meta: "Pass 1 · writer")
passStateLabel("second draft", indent: false)
libraryRow(title: "Slow sentences", meta: "Second Draft · writer")
}
.padding(.bottom, 12)
}
}
.frame(width: Tok.libraryWidth)
}
private func passStateLabel(_ label: String, indent: Bool = true) -> some View {
Text(label.uppercased())
.font(Tok.mono(10))
.foregroundStyle(Tok.muted.opacity(0.8))
.padding(.leading, indent ? 22 : 14)
.padding(.vertical, 2)
.frame(maxWidth: .infinity, alignment: .leading)
}
private func libraryRow(title: String, meta: String, selected: Bool = false) -> some View {
HStack(spacing: 8) {
RoundedRectangle(cornerRadius: 1)
.fill(selected ? Tok.accent : Tok.border)
.frame(width: 2)
VStack(alignment: .leading, spacing: 2) {
Text(title)
.font(Tok.display(13))
.lineLimit(1)
Text(meta)
.font(Tok.mono(11))
.foregroundStyle(Tok.muted)
}
Spacer(minLength: 0)
}
.padding(.horizontal, 10)
.padding(.vertical, 6)
.padding(.leading, 14)
.background {
if selected {
RoundedRectangle(cornerRadius: 8)
.fill(Tok.surface)
.overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(Tok.border))
.padding(.leading, 8)
}
}
.padding(.bottom, 2)
}
}
// MARK: Editor column (mock body; header keeps the 52px hairline alignment)
extension MockWorkspace {
private var editor: some View {
VStack(spacing: 0) {
PaneHeader(title: "On rereading Orwell") {
Text("Publish")
.font(Tok.mono(11))
.foregroundStyle(Tok.muted)
}
ScrollView {
VStack(alignment: .leading, spacing: 18) {
Text("On rereading Orwell")
.font(Tok.display(26, .semibold))
Text(previewText)
.font(.system(size: 14))
.foregroundStyle(Tok.foreground)
.lineSpacing(5)
}
.padding(36)
.frame(maxWidth: 720, alignment: .leading)
.frame(maxWidth: .infinity, alignment: .center)
}
}
.frame(minWidth: 420)
}
private var previewText: String {
String(
repeating: "The essay argues itself into a corner by the third paragraph, and the prose knows it. Sentences shorten. Claims retreat. ",
count: 6,
)
}
}
// MARK: Mentor column — header states are a surface under test in EVERY variant
extension MockWorkspace {
private var mentor: some View {
VStack(spacing: 0) {
mentorHeader
modePicker
// C: the fail detail lives here — inside the pane that needs
// the engine, never floating, never modal.
if variant == .inline, model.isFailed {
StatusCard(collapsible: false)
.padding(.horizontal, 12)
.padding(.top, 10)
.frame(width: Tok.mentorWidth)
}
passBar
ScrollView {
VStack(alignment: .leading, spacing: 12) {
mentorRow(label: "you", text: "Can you read the intro against the outline?", muted: false)
mentorRow(
label: "mentor",
text: "The intro promises three moves the essay never makes. By page two the reader is waiting for evidence that never lands — "
+ "cut the promise or keep it.",
muted: false,
)
}
.padding(12)
}
inputRail
Spacer(minLength: 0)
}
.frame(width: Tok.mentorWidth)
.animation(.spring(duration: 0.3), value: model.isFailed)
}
/// The mentor-pane header status surface: checking / failed / version.
private var mentorHeader: some View {
HStack(spacing: 8) {
Image(systemName: "bubble.left.and.text.bubble.right")
.foregroundStyle(Tok.muted)
Text("Mentor Session")
.font(.headline)
.fixedSize()
headerStatus
.layoutPriority(1)
Spacer()
// No live session id exists while the engine is missing or checking —
// the chip renders only once ready (and frees header width otherwise).
if case .ready = model.phase {
Text("session 3f9a2c")
.font(Tok.mono(10))
.foregroundStyle(Tok.muted.opacity(0.7))
.lineLimit(1)
.truncationMode(.tail)
}
Toggle("Debug", isOn: .constant(false))
.toggleStyle(.checkbox)
.controlSize(.mini)
.foregroundStyle(Tok.muted)
}
.padding(.horizontal, 12)
.frame(minHeight: 52)
.overlay(alignment: .bottom) { verticalBorder }
}
@ViewBuilder
private var headerStatus: some View {
switch model.phase {
case .checking:
HStack(spacing: 5) {
ProgressView().controlSize(.mini)
Text("checking the engine…")
}
.font(Tok.mono(10))
.foregroundStyle(Tok.muted)
.layoutPriority(1)
case .engineFailed:
Text("engine missing")
.font(Tok.mono(10))
.foregroundStyle(Tok.accent)
.help("Passes and Sessions need the Hermes engine")
case .setupFailed:
Text("setup failed")
.font(Tok.mono(10))
.foregroundStyle(Tok.accent)
case let .ready(version):
// The pane shows the handshake (base) version, not the gate's
// derived one — baseVersion(of:) per the drift-note contract.
Text("hermes \(version.prefix(while: { $0 != "+" }))")
.font(Tok.mono(10))
.foregroundStyle(Tok.muted.opacity(0.7))
.lineLimit(1)
.truncationMode(.middle)
}
}
private var modePicker: some View {
Picker("Mentor surface", selection: .constant(0)) {
Text("Pass 1").tag(0)
Text("Pass 2").tag(1)
Text("Chat").tag(2)
}
.pickerStyle(.segmented)
.padding(.horizontal, 12)
.padding(.top, 10)
.padding(.bottom, 8)
}
private var passBar: some View {
VStack(alignment: .leading, spacing: 4) {
Text("Critiques: the open piece · ~2.4k tokens")
HStack(spacing: 8) {
Text("First Draft")
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(Tok.foregroundSoft, in: Capsule())
Text("Run Pass 1").foregroundStyle(Tok.accent)
}
}
.font(Tok.mono(11))
.foregroundStyle(Tok.muted)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal, 12)
.padding(.bottom, 10)
}
private func mentorRow(label: String, text: String, muted: Bool) -> some View {
VStack(alignment: .leading, spacing: 3) {
Text(label)
.font(Tok.mono(10))
.foregroundStyle(Tok.muted)
Text(text)
.font(.system(size: 13))
.foregroundStyle(muted ? Tok.muted : Tok.foreground)
.lineSpacing(3)
}
}
private var inputRail: some View {
HStack(spacing: 8) {
TextField("Ask the mentor…", text: .constant(""))
Button {} label: {
Image(systemName: "arrow.up.circle.fill")
}
.buttonStyle(.plain)
}
.padding(.horizontal, 12)
.padding(.vertical, 8)
}
}
// MARK: - Shared mock pieces
/// RailButton per the app: 44×44 muted icon, hover wash, surface card + 2px edge
/// bar when current.
struct MockRailButton: View {
let icon: String
let label: String
var selected = false
@State private var hover = false
var body: some View {
Button {} label: {
Image(systemName: icon)
.font(.system(size: 15))
.frame(width: 44, height: 44)
}
.buttonStyle(.plain)
.foregroundStyle(selected ? Tok.foreground : Tok.muted)
.background {
if selected || hover {
RoundedRectangle(cornerRadius: Tok.radius)
.fill(selected ? Tok.surface : Tok.foregroundSoft)
.overlay(
RoundedRectangle(cornerRadius: Tok.radius)
.strokeBorder(selected ? Tok.border : .clear),
)
}
}
.overlay(alignment: .leading) {
if selected {
Rectangle()
.fill(Tok.foreground)
.frame(width: 2, height: 22)
.offset(x: -6)
}
}
.onHover { hover = $0 }
.help(label)
}
}
/// Pane-head per the app: 52pt, serif 15 semibold, bottom hairline.
struct PaneHeader<Trailing: View>: View {
let title: String
@ViewBuilder var trailing: () -> Trailing
init(title: String, @ViewBuilder trailing: @escaping () -> Trailing = { EmptyView() }) {
self.title = title
self.trailing = trailing
}
var body: some View {
VStack(spacing: 0) {
HStack {
Text(title)
.font(Tok.display(15, .semibold))
Spacer()
trailing()
}
.padding(.horizontal, 14)
.frame(minHeight: 52)
Rectangle().fill(Tok.border).frame(height: 1)
}
}
}
struct Pulse: ViewModifier {
let active: Bool
func body(content: Content) -> some View {
if active {
content.opacity(0.35).animation(
Animation.easeInOut(duration: 0.55).repeatForever(autoreverses: true),
value: active,
)
} else {
content
}
}
}
// MARK: - Root + switcher
struct ProtoRoot: View {
@StateObject private var model = ProtoModel()
@State private var variant: Variant = .slot
var body: some View {
// The switcher is PROTOTYPE CHROME: safeAreaInset keeps it outside the
// content area so no status surface can ever collide with it.
MockWorkspace(variant: variant)
.environmentObject(model)
.safeAreaInset(edge: .bottom, spacing: 0) {
SwitcherBar(variant: $variant, model: model)
.padding(.horizontal, 14)
.padding(.vertical, 8)
}
.frame(minWidth: 1180, minHeight: 700)
.background(Tok.background)
.onAppear { model.check() }
}
}
struct SwitcherBar: View {
@Binding var variant: Variant
@ObservedObject var model: ProtoModel
var body: some View {
HStack(spacing: 14) {
arrow("chevron.left") { cycle(-1) }
.keyboardShortcut(.leftArrow, modifiers: [])
Text("\(variant.rawValue) — \(variant.label)")
.font(Tok.mono(12))
arrow("chevron.right") { cycle(1) }
.keyboardShortcut(.rightArrow, modifiers: [])
Divider().frame(height: 16).overlay(Tok.border)
Picker("Scenario", selection: $model.scenario) {
ForEach(Scenario.allCases) { Text($0.rawValue).tag($0) }
}
.pickerStyle(.segmented)
.frame(width: 300)
Button("Re-run") { model.check() }
.buttonStyle(.link)
.font(Tok.mono(11))
Divider().frame(height: 16).overlay(Tok.border)
Text(phaseLabel)
.font(Tok.mono(11)).foregroundStyle(Tok.background.opacity(0.8))
}
.padding(.horizontal, 14)
.padding(.vertical, 9)
.background(Tok.foreground, in: RoundedRectangle(cornerRadius: 10))
.foregroundStyle(Tok.background)
.onAppear { NSApp.appearance = NSAppearance(named: .aqua) } // prototype: force light so tokens read as designed
}
private var phaseLabel: String {
switch model.phase {
case .checking: "checking"
case .ready: "ready · quiet (nothing renders)"
case .engineFailed: "failed · engine missing"
case let .setupFailed(profile): "failed · setup (\(profile))"
}
}
private func cycle(_ dir: Int) {
let all = Variant.allCases
let idx = all.firstIndex(of: variant) ?? 0
variant = all[(idx + dir + all.count) % all.count]
}
private func arrow(_ system: String, action: @escaping () -> Void) -> some View {
Button(action: action) {
Image(systemName: system).font(.system(size: 11, weight: .semibold))
}
.buttonStyle(.plain)
}
}
@main
struct GatelessStatusPrototypeApp: App {
var body: some Scene {
WindowGroup("Gateless status — #149 prototype") { ProtoRoot() }
}
}