Files
museion/Museion/ContentView.swift
T
AlexKuceraandClaude f21d3a6844
CI / ci (push) Canceled after 0s
feat(acp): add M0 ACP bridge — engine child + mentor pane (fixes #14)
Spawn hermes acp -p museion over NDJSON JSON-RPC stdio via a
hand-rolled thin client (no Swift SDK exists). The mentor debug
pane streams replies, renders fix-card tool calls as structured
cards (ADR-0006), cancels via session/cancel, tears down on quit
(willTerminate), and surfaces a restart prompt on engine crash —
never data loss. Version verify against state.json is advisory.

Fake ACP server test double (zsh speaking real NDJSON) covers
handshake, streaming + fix-card, drift, crash latch, cancel,
teardown. 36/36 tests green; finish-audit fixes included (wired
binaryPath, focus-loss teardown bug, double onCrash latch).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-16 18:57:41 +02:00

79 lines
2.2 KiB
Swift

//
// 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<Bool> {
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.
Task { await gate.provisioning.runPass(hermesBinary: gate.gateModel.currentBinaryPath) }
},
onDismiss: {
gate.gateRaised = false
gate.gateDismissed = true
},
)
}
.sheet(isPresented: failurePresented) {
ProvisioningFailureCard(model: gate.provisioning) {
Task { await gate.provisioning.runPass(hermesBinary: gate.gateModel.currentBinaryPath) }
}
.interactiveDismissDisabled()
}
}
}