CI / ci (push) Canceled after 0s
Headless --serve-mcp role in the app binary: NDJSON JSON-RPC on stdio exposing query_learnings and submit_fix_cards (ADR-0006 cards, anchor-validated; stale lands flagged, never rejected), registered into the museion profile at provisioning. Cards persist per piece under <piece>/cards/ and surface in a floating Fix Cards palette with pass-stamped provenance. Live dogfood drove the shape: session/prompt waits pass length (the 15 s request default abandoned working turns), a liveness row and a persisted Debug checkbox (off) split writing sessions from debug chatter, the verdict references findings by title only while the cards carry the detail (persona v1.3 — tools work in silence), and the #24 pass rails (pass bar, TurnOutcome seam, snapshots) ride in. Three-reviewer audit round: piece-path shape guard closes the JSON-drop and substring-oracle holes, nested submit rawInput parsing (the flat parser never matched the live rail), missing stopReason never advances a pass, 1 MB stdin cap, card scan off MainActor. 296 tests green; every behavioral fix flip-verified. Closes #23
110 lines
3.7 KiB
Swift
110 lines
3.7 KiB
Swift
//
|
|
// FixCardsWindow.swift
|
|
// Museion
|
|
//
|
|
// #23 follow-up (dogfood): the Fix Cards palette — the durable card
|
|
// store's own surface, a floating window (scene id "fix-cards") opened
|
|
// from the mentor pass bar. The transcript renders card tool calls as
|
|
// one-line events; the card DETAIL lives here while the verdict gets
|
|
// worked through. Show-only, never acts (Apply is #25).
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// Palette body: the open piece's stored fix cards (`<piece>/cards/`, any
|
|
/// MCP client's submissions — PostsModel re-derives on open/rescan, so this
|
|
/// stays current via @Observable). Re-contextualizes as the piece changes.
|
|
struct FixCardsPalette: View {
|
|
@Environment(AppGateState.self) private var gate
|
|
|
|
var body: some View {
|
|
let posts = gate.posts
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
if let title = openPieceTitle {
|
|
Text(title)
|
|
.font(.headline)
|
|
.padding(.horizontal, 12)
|
|
.padding(.top, 12)
|
|
.padding(.bottom, 4)
|
|
}
|
|
if posts.openPieceCards.isEmpty {
|
|
emptyState(hasPiece: posts.session?.postID != nil)
|
|
} else {
|
|
cardList(posts.openPieceCards)
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
// The window reads as app chrome, not a document — the same warm
|
|
// cream the workspace root/rail paints (DesignTokens.background).
|
|
.background(DesignTokens.background)
|
|
}
|
|
|
|
/// The pass label's title source — PostsModel's shared lookup.
|
|
private var openPieceTitle: String? {
|
|
guard let id = gate.posts.session?.postID else { return nil }
|
|
return gate.posts.title(of: id)
|
|
}
|
|
|
|
private func emptyState(hasPiece: Bool) -> some View {
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
Text(hasPiece ? "No fix cards yet." : "No piece open.")
|
|
.font(.headline)
|
|
Text(hasPiece
|
|
? "Run a pass — cards land here as the mentor files them."
|
|
: "Open a post — its fix cards collect here.")
|
|
.font(.callout)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
.padding(12)
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
}
|
|
|
|
/// The open piece's STORED fix cards (moved from MentorPaneView #23 S2.4
|
|
/// — uncapped here, the window owns its scroll).
|
|
private func cardList(_ cards: [FixCardStore.StoredFixCard]) -> some View {
|
|
ScrollView {
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text("FIX CARDS · \(cards.count)")
|
|
.font(.system(size: 11, design: DesignTokens.mono))
|
|
.foregroundStyle(DesignTokens.muted)
|
|
ForEach(cards, id: \.id) { card in
|
|
row(card)
|
|
}
|
|
}
|
|
.padding(12)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
}
|
|
|
|
/// One card: pattern title, problem + fix body, lane · emitter mono meta
|
|
/// (ADR-0006). A stale anchor reads distinct — orange + caption — and is
|
|
/// never appliable: v1 shows, never acts.
|
|
private func row(_ card: FixCardStore.StoredFixCard) -> some View {
|
|
let stale = card.anchorStatus == .stale
|
|
var meta = "\(card.lane.rawValue) · \(card.emitter.rawValue)"
|
|
if let pass = card.provenance?.pass {
|
|
meta = "pass \(pass) · " + meta
|
|
}
|
|
if stale {
|
|
meta += " · stale anchor"
|
|
}
|
|
return VStack(alignment: .leading, spacing: 6) {
|
|
Label(card.pattern, systemImage: "rectangle.and.pencil.and.ellipsis")
|
|
.font(.callout.weight(.semibold))
|
|
.foregroundStyle(stale ? .orange : DesignTokens.foreground)
|
|
if !card.problem.isEmpty {
|
|
Text(card.problem).font(.callout)
|
|
}
|
|
if !card.fix.isEmpty {
|
|
Text("Fix: \(card.fix)").font(.callout)
|
|
}
|
|
Text(meta)
|
|
.font(.system(size: 11, design: DesignTokens.mono))
|
|
.foregroundStyle(stale ? .orange : DesignTokens.muted)
|
|
}
|
|
.padding(10)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.background(.quaternary.opacity(0.3), in: RoundedRectangle(cornerRadius: 8))
|
|
}
|
|
}
|