feat(workspace): add M1 Home & Posts list — nav rail, posts mirror, Home repoint (fixes #17)

The post-gate main surface is the workspace shell from the design
contract: nav rail (Posts/Sessions/Learnings/Settings), Posts pane
mirroring <home>/posts/ on disk (Pass State groups, origin meta,
empty state; lazy folders skipped), Settings pane with repoint-only
Home picking (NSOpenPanel + UserDefaults, default ~/Documents/Museion
per b3daac9), placeholder panes until #28/#26. Column collapse
mirrors the export's media queries so narrow windows never clip.
Mentor pane becomes the fourth column (#14 surface preserved).

[Generated by AI]
This commit is contained in:
AlexKucera committed 2026-10-01 13:14:55 +02:00
1 parent b3daac9486
commit 804b5889f6
15 files changed
+762 -5

No files matched your search

+1
View File
@@ -177,6 +177,7 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
<!-- write-log: window-start -->
| Date | Log |
|------|-----|
| 2026-10-01 | [20261001-issue17-home-posts-list_log.md](docs/devlog/20261001-issue17-home-posts-list_log.md) |
| 2026-09-25 | [20260925-issue50-profile-backup-s2-6_log.md](docs/devlog/20260925-issue50-profile-backup-s2-6_log.md) |
| 2026-09-16 | [20260916-issue14-acp-bridge-s2-2_log.md](docs/devlog/20260916-issue14-acp-bridge-s2-2_log.md) |
| 2026-09-05 | [20260905-issue48-provisioning-failure-alert-retry-ux_log.md](docs/devlog/20260905-issue48-provisioning-failure-alert-retry-ux_log.md) |
+2
View File
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. The format
### Added
- **workspace:** M1 Home & Posts list (PRD S1.1) — the post-gate main surface is now the workspace shell from the design contract: nav rail (Posts, Sessions, Learnings, Settings), a Posts pane that mirrors the Museion Home's `posts/` folder on disk (Pass State groups, origin meta, empty state, lazy folders skipped), a Settings pane where the Home can be repointed (repoint-only — Museion never moves content; NSOpenPanel picker, UserDefaults persistence, default `~/Documents/Museion`), and placeholder panes for Sessions/Learnings until their milestones; the M0 mentor pane becomes the workspace's fourth column (issue #17)
- **backup:** S2.6 daily profile backup — on launch, once per 24 h and only while the engine is idle (gateway.pid liveness + `ps` scan), Museion snapshots `~/.hermes/profiles/museion/` into a timestamped folder under `~/Library/Application Support/Museion/Backups/` (credentials included, logs/caches/locks excluded, last 7 kept); restore is manual Finder copy-back — Help → Open Backup Folder, `RESTORE.md` beside the snapshots (issue #50)
- **acp:** M0 ACP bridge (PRD S2.2) — the app spawns the Hermes engine (`hermes acp -p museion`) as a child process via a hand-rolled NDJSON JSON-RPC stdio client, opens a Session, streams mentor replies live in a debug pane, renders fix-card tool calls as structured cards, cancels turns via Stop, tears the child down on quit, and surfaces an in-pane restart prompt on engine crash — never data loss (issue #14)
- **provisioning:** S2.1 profile provisioning — idempotent per-gate pass creates the `museion` Hermes profile (`hermes profile create --no-alias --no-skills`) and additively seeds the bundled writing skills via `seed-manifest.txt`; existing skills are never overwritten (issue #47)
+10
View File
@@ -17,6 +17,16 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro
- No persistence layer yet — the SwiftData template was stripped; vault-vs-database gets an ADR when the need is real. Exception: the engine gate's `state.json` (see below).
- Tabs for indentation; SwiftFormat + SwiftLint must both stay clean.
## Workspace shell (M1, #17 / S1.1)
- `DesignTokens.swift` — palette/geometry from the design contract (`ref/Web-Prototype/museion-workspace.html` `:root` + grid): background/surface/foreground/muted/border/accent colors, radius 10/14, column widths (rail 56, library 232, editor min 420, mentor 356), serif/mono font designs. Light-only — the export defines one palette.
- `WorkspaceView.swift` — post-gate main surface (replaces the M0 mentor pane as root): nav rail (Posts/Sessions/Learnings + Settings at bottom) + active pane. `RailButton` per the export (44×44, muted icon, hover wash, surface card + 2px edge bar when current). Sessions/Learnings are honest placeholders until #28/#26. Posts renders the full grid; **column collapse mirrors the export's media queries** (library hides < 1100 px, mentor hides < 920 px budget) as macOS pane collapse — never a fixed four-column minWidth that clips. `PaneHeader` = 52pt serif-15 title row + border.
- `PostsPaneView.swift` — Posts destination: library column (Pass State groups in mono-11 uppercase labels, post rows with title + passState/origin meta), empty state, editor placeholder until #19–#21, mentor column (`MentorPaneView`, fixed 356). Selecting a post sets `selectedPostID` (editor shows its title; no editing yet).
- `PostLibrary.swift` — `Post` (nonisolated: id/title/passState/origin) + `PostLibrary.scan(home:)`: reads `posts/<id>/post.md`, skips dirs without post.md (lazy folders), loose files, hidden dirs; Title = first non-empty line after frontmatter, `#` stripped, `untitled` when blank; `pass_state`/`origin` frontmatter keys read leniently (First Draft/writer defaults — corpus posts ship bare; key format pinned by #18). Read-only — lifecycle is #18.
- `SettingsPaneView.swift` — Home control (NSOpenPanel folder pick; files/canCreate on). Repoint-only semantics stated in-UI.
- `AppGateState.museionHome` — app-scoped Home (UserDefaults `museionHome`, default `~/Documents/Museion` = `defaultMuseionHome`). Explicit init: `Self` in a stored-property initializer breaks `@ObservationTracked` (covariant-Self error).
- `MentorPaneView` no longer carries a root min-frame — it lives in the 356pt mentor column.
## Engine gate (launch gate, tickets #35–#41)
- `EngineGate.swift` — `EngineProbe` (nonisolated): six-path probe order, `acp --check` health (stdin closed, 5 s timeout, exit-status branching), `acp --version` version, `state.json` writer/reader. `EngineGateModel` (@MainActor @Observable): phases for the UI, `onPass` seam (fires provisioning, #47), `currentBinaryPath` handed to provisioning. `execute(_:timeout:)`/`ProcessOutput` are internal — shared child-process machinery.
+4 -4
View File
@@ -35,11 +35,11 @@ struct ContentView: 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.
// #17: post-gate main surface is the workspace shell (nav rail +
// Posts/Sessions/Learnings/Settings). 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)
WorkspaceView()
} else {
VStack(spacing: 8) {
Image(systemName: "books.vertical")
+34
View File
@@ -0,0 +1,34 @@
//
// DesignTokens.swift
// Museion
//
// Visual tokens from the design contract (ref/Web-Prototype/museion-workspace.html, #17).
//
import SwiftUI
/// Colors, radii, and column geometry extracted from the export's `:root`
/// and workspace grid. Light-only on purpose — the export defines one palette.
enum DesignTokens {
static let background = Color(red: 0xFA / 255, green: 0xFA / 255, blue: 0xF7 / 255)
static let surface = Color(red: 1, green: 1, blue: 1)
static let foreground = Color(red: 0x1A / 255, green: 0x19 / 255, blue: 0x16 / 255)
static let muted = Color(red: 0x6B / 255, green: 0x69 / 255, blue: 0x64 / 255)
static let border = Color(red: 0xE8 / 255, green: 0xE5 / 255, blue: 0xDF / 255)
static let accent = Color(red: 0xC9 / 255, green: 0x64 / 255, blue: 0x42 / 255)
static let radius: CGFloat = 10
static let radiusLarge: CGFloat = 14
/// The workspace grid: rail | posts library | editor | mentor (grid-template-columns
/// `56px 232px minmax(420px, 1fr) 356px`).
static let railWidth: CGFloat = 56
static let libraryWidth: CGFloat = 232
static let editorMinWidth: CGFloat = 420
static let mentorWidth: CGFloat = 356
/// The serif display face maps to the system serif design (export stack:
/// Iowan Old Style / Charter / Georgia); mono to the system monospaced.
static let serif: Font.Design = .serif
static let mono: Font.Design = .monospaced
}
+2 -1
View File
@@ -37,7 +37,8 @@ struct MentorPaneView: View {
crashCard(lastPrompt: lastPrompt)
}
}
.frame(minWidth: 560, minHeight: 420)
// #17: the pane lives in the workspace's fixed 356pt mentor column —
// no root min frame (it was the full-window M0 surface).
.task {
model.binaryPath = binaryPath ?? model.binaryPath
// Hosted unit tests run this app as their runner — never spawn a
+20
View File
@@ -22,6 +22,26 @@ final class AppGateState {
let backup = BackupModel()
/// #14: the app-scoped mentor bridge — the pane renders it; quit tears it down.
let mentor = MentorSessionModel()
/// #17: the Museion Home — repoint-only (ADR-0004). Defaults to
/// `~/Documents/Museion`; UserDefaults is the persistence floor: a Home is
/// a plain folder, nothing app-owned to put in a database.
var museionHome: URL {
didSet { UserDefaults.standard.set(museionHome.absoluteString, forKey: "museionHome") }
}
init() {
// Explicit init: `Self` in a stored-property initializer trips
// @ObservationTracked's macro expansion (covariant Self).
museionHome = UserDefaults.standard.string(forKey: "museionHome").flatMap(URL.init(string:))
?? Self.defaultMuseionHome
}
/// The default Home, absent a stored override — `~/Documents/Museion`
/// (b3daac9: Documents, not the account root; TCC note in ADR-0004).
nonisolated static let defaultMuseionHome = FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent("Documents/Museion", isDirectory: true)
private static let homeKey = "museionHome"
}
@main
+114
View File
@@ -0,0 +1,114 @@
//
// PostLibrary.swift
// Museion
//
// #17 (S1.1): the Posts list mirrors what is on disk under the Museion Home.
//
import Foundation
/// One Post on disk: `<home>/posts/<id>/post.md` (ADR-0004 shape).
/// A Post directory with no post.md yet is skipped — folders are created lazily
/// on first write, so an empty folder is not a Post.
nonisolated struct Post: Identifiable, Equatable {
/// The post folder's name — the Post's durable identity (CONTEXT.md).
let id: String
/// The Post's Title: first non-empty line, heading markers stripped.
var title: String
/// Pass State from frontmatter; First Draft when absent (explicit, never inferred).
var passState: PassState
/// Origin from frontmatter; writer when absent. Immutable once set (CONTEXT.md).
var origin: Origin
nonisolated enum PassState: String, Equatable, CaseIterable {
case firstDraft = "First Draft"
case pass1Done = "Pass-1 Done"
case pass2Done = "Pass-2 Done"
}
nonisolated enum Origin: String, Equatable {
case writer
/// PRD S5.1 pins the frontmatter vocabulary: `origin: writer|ai`.
// swiftlint:disable:next identifier_name
case ai
}
}
/// Scans `<home>/posts/` and parses each Post's frontmatter leniently.
/// Read-only for #17 — create/rename/delete round-trips are #18.
/// Nonisolated: a pure synchronous disk scan, safe from any executor.
nonisolated struct PostLibrary: Equatable {
private(set) var posts: [Post] = []
/// Reads every `posts/<id>/post.md`. Frontmatter keys (`pass_state:`, `origin:`)
/// are read leniently — corpus posts ship bare, so absent or unknown values fall
/// back to First Draft / writer. Keys outside a frontmatter block are ignored;
/// a malformed folder can't crash the list.
static func scan(home: URL) -> PostLibrary {
let postsURL = home.appendingPathComponent("posts", isDirectory: true)
guard let entries = try? FileManager.default.contentsOfDirectory(
at: postsURL,
includingPropertiesForKeys: [.isDirectoryKey],
) else { return PostLibrary() }
var posts: [Post] = []
for dir in entries where (try? dir.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == true {
let fileURL = dir.appendingPathComponent("post.md")
guard let text = try? String(contentsOf: fileURL, encoding: .utf8) else { continue }
let frontmatter = Self.frontmatter(of: text)
posts.append(
Post(
id: dir.lastPathComponent,
title: Self.title(of: text),
passState: Post.PassState(rawValue: frontmatter["pass_state"] ?? "") ?? .firstDraft,
origin: Post.Origin(rawValue: frontmatter["origin"] ?? "") ?? .writer,
),
)
}
return PostLibrary(posts: posts.sorted { $0.title.localizedStandardCompare($1.title) == .orderedAscending })
}
/// The `---`-delimited frontmatter block if present; empty otherwise.
static func frontmatter(of text: String) -> [String: String] {
let lines = text.split(separator: "\n", omittingEmptySubsequences: false)
guard lines.first?.trimmed() == "---" else { return [:] }
var map: [String: String] = [:]
for line in lines.dropFirst() {
let trimmed = line.trimmed()
guard trimmed != "---" else { break }
guard let colon = trimmed.firstIndex(of: ":") else { continue }
let key = trimmed[..<colon].trimmingCharacters(in: .whitespaces)
let value = trimmed[trimmed.index(after: colon)...].trimmingCharacters(in: .whitespaces)
map[key] = value
}
return map
}
/// The Post's Title: first non-empty line after any frontmatter block,
/// `#` heading markers stripped. A body with no text at all reads as
/// `untitled` (the blank-draft id).
static func title(of text: String) -> String {
var lines = text.split(separator: "\n", omittingEmptySubsequences: false)[...]
if lines.first?.trimmed() == "---" {
if let close = lines.dropFirst().firstIndex(where: { $0.trimmed() == "---" }) {
lines = lines[(close + 1)...]
} else {
lines = lines.dropFirst() // unterminated block: no title inside it
}
}
for line in lines {
let trimmed = line.trimmed()
if trimmed.isEmpty {
continue
}
return trimmed.trimmingCharacters(in: CharacterSet(charactersIn: "#").union(.whitespaces))
}
return "untitled"
}
}
private nonisolated extension Substring {
func trimmed() -> String {
trimmingCharacters(in: .whitespacesAndNewlines)
}
}
+168
View File
@@ -0,0 +1,168 @@
//
// PostsPaneView.swift
// Museion
//
// #17 (S1.1): the Posts pane — library column mirroring the Home's posts/
// on disk, editor placeholder until #19–#21, mentor column (#14).
//
import SwiftUI
/// The Posts destination: the workspace's full four-column layout
/// library 232 | editor ≥420 | mentor 356 (design contract grid).
struct PostsPaneView: View {
let home: URL
/// #14: the app-scoped mentor model + the gate's winning binary (no re-probe).
var mentor: MentorSessionModel
var mentorBinaryPath: String?
/// Width budget after the rail — drives column collapse (export media queries:
/// library hides ≤1100, mentor hides ≤920).
var availableWidth: CGFloat = .infinity
@State private var library = PostLibrary()
@State private var selectedPostID: String?
private var showsLibrary: Bool {
availableWidth >= 1100 - DesignTokens.railWidth
}
private var showsMentor: Bool {
availableWidth >= 920 - DesignTokens.railWidth
}
var body: some View {
HStack(spacing: 0) {
if showsLibrary {
libraryColumn
paneBorder
}
editorPlaceholder
if showsMentor {
paneBorder
mentorColumn
}
}
.task(id: home) { library = PostLibrary.scan(home: home) }
}
private var paneBorder: some View {
Rectangle()
.fill(DesignTokens.border)
.frame(width: 1)
}
// MARK: Library column
private var libraryColumn: some View {
VStack(spacing: 0) {
PaneHeader(title: "Posts") {
// New Post arrives with #18 (Post lifecycle: lazy folder + slug).
EmptyView()
}
if library.posts.isEmpty {
emptyState
} else {
ScrollView {
LazyVStack(alignment: .leading, spacing: 4) {
ForEach(Post.PassState.allCases, id: \.self) { state in
let posts = library.posts.filter { $0.passState == state }
if !posts.isEmpty {
Text(state.rawValue.uppercased())
.font(.system(size: 11, design: DesignTokens.mono))
.kerning(0.6)
.foregroundStyle(DesignTokens.muted)
.padding(.horizontal, 14)
.padding(.top, 18)
.padding(.bottom, 7)
ForEach(posts) { post in
PostRow(post: post, selected: post.id == selectedPostID) {
selectedPostID = post.id
}
}
}
}
}
.padding(.bottom, 12)
}
}
}
.frame(width: DesignTokens.libraryWidth)
}
private var emptyState: some View {
VStack(spacing: 8) {
Text("No posts yet")
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
Text("Posts in this Home's posts/ folder appear here.")
.font(.callout)
.foregroundStyle(DesignTokens.muted)
.multilineTextAlignment(.center)
}
.padding(38)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
// MARK: Editor + mentor columns
private var editorPlaceholder: some View {
VStack(spacing: 10) {
if let post = library.posts.first(where: { $0.id == selectedPostID }) {
Text(post.title)
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
}
Text("The editor arrives with S1.2 (#19–#21).")
.font(.callout)
.foregroundStyle(DesignTokens.muted)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(DesignTokens.surface)
}
private var mentorColumn: some View {
MentorPaneView(model: mentor, binaryPath: mentorBinaryPath)
.frame(width: DesignTokens.mentorWidth)
}
}
/// One post row per the export: title, Pass State + Origin in mono 11.
private struct PostRow: View {
let post: Post
let selected: Bool
let select: () -> Void
@State private var hover = false
var body: some View {
Button(action: select) {
VStack(alignment: .leading, spacing: 5) {
Text(post.title)
.font(.callout.weight(.semibold))
.lineLimit(1)
.truncationMode(.tail)
.frame(maxWidth: .infinity, alignment: .leading)
HStack {
Text(post.passState.rawValue)
Text(post.origin.rawValue)
}
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
.frame(maxWidth: .infinity, alignment: .leading)
}
.padding(10)
}
.buttonStyle(.plain)
.foregroundStyle(DesignTokens.foreground)
.background {
let fill: Color? = selected ? DesignTokens.surface : (hover ? DesignTokens.foreground.opacity(0.06) : nil)
if let fill {
RoundedRectangle(cornerRadius: DesignTokens.radius)
.fill(fill)
.overlay(
RoundedRectangle(cornerRadius: DesignTokens.radius)
.strokeBorder(selected ? DesignTokens.border : .clear),
)
}
}
.padding(.horizontal, 8)
.onHover { hover = $0 }
.accessibilityLabel("\(post.title), \(post.passState.rawValue), origin \(post.origin.rawValue)")
}
}
+53
View File
@@ -0,0 +1,53 @@
//
// SettingsPaneView.swift
// Museion
//
// #17 (S1.1): Settings — the Museion Home path, repoint-only (ADR-0004).
//
import AppKit
import SwiftUI
/// Settings pane. #17 scope: the Home control only — further settings arrive
/// with their tickets. Choosing a folder repoints Museion at that root;
/// content is never moved.
struct SettingsPaneView: View {
@Binding var home: URL
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 12) {
Text("Content")
.font(.system(size: 13, weight: .semibold))
HStack(spacing: 8) {
Text(home.path(percentEncoded: false))
.font(.system(size: 12, design: DesignTokens.mono))
.lineLimit(1)
.truncationMode(.middle)
.textSelection(.enabled)
Spacer(minLength: 12)
Button("Choose…") { chooseHome() }
}
Text(
"Repoint-only: Museion never moves content. The Posts list reads this folder's posts/ directory.",
)
.font(.callout)
.foregroundStyle(DesignTokens.muted)
}
.padding(24)
.frame(maxWidth: .infinity, alignment: .leading)
}
.background(DesignTokens.background)
}
private func chooseHome() {
let panel = NSOpenPanel()
panel.canChooseDirectories = true
panel.canChooseFiles = false
panel.canCreateDirectories = true
panel.message = "Choose the folder holding your posts. Museion never moves content."
if panel.runModal() == .OK, let url = panel.url {
home = url
}
}
}
+168
View File
@@ -0,0 +1,168 @@
//
// WorkspaceView.swift
// Museion
//
// #17 (S1.1): the workspace shell — nav rail + panes, built from the design
// contract's grid geometry (ref/Web-Prototype/museion-workspace.html):
// rail 56 | library 232 | editor min 420 | mentor 356.
//
import SwiftUI
/// The post-gate main surface. Posts shows the full four-column workspace;
/// Sessions/Learnings/Settings fill the space after the rail until their
/// tickets land (#28/#26; Settings is real here).
struct WorkspaceView: View {
@Environment(AppGateState.self) private var gate
@State private var selection: Pane = .posts
enum Pane: Hashable {
case posts
case sessions
case learnings
case settings
}
var body: some View {
@Bindable var gate = gate
return GeometryReader { geo in
HStack(spacing: 0) {
navRail
paneBorder
switch selection {
case .posts:
// #14: mentor column hands in the app-scoped model + gate's winner.
// Column collapse mirrors the export's media queries (library ≤1100,
// mentor ≤920) as macOS pane collapse per the PRD.
PostsPaneView(
home: gate.museionHome,
mentor: gate.mentor,
mentorBinaryPath: gate.gateModel.currentBinaryPath,
availableWidth: geo.size.width - DesignTokens.railWidth,
)
case .sessions:
PlaceholderPane(title: "Sessions", detail: "Session lifecycle arrives with S2.3 (#28).")
case .learnings:
PlaceholderPane(title: "Learnings", detail: "Promote, consult, and decay arrive with S4 (#26, #27).")
case .settings:
SettingsPaneView(home: $gate.museionHome)
}
}
.background(DesignTokens.background)
}
// Collapsed floor: rail 56 + editor 420 (export ≤920 layout).
.frame(minWidth: 480, minHeight: 320)
}
/// 1px contract border between rail and pane (`.rail { border-right }`).
private var paneBorder: some View {
Rectangle()
.fill(DesignTokens.border)
.frame(width: 1)
}
// MARK: Nav rail
private var navRail: some View {
VStack(spacing: 8) {
RailButton(pane: .posts, selection: $selection, label: "Posts", systemImage: "doc.text")
RailButton(pane: .sessions, selection: $selection, label: "Sessions", systemImage: "bubble.left")
RailButton(pane: .learnings, selection: $selection, label: "Learnings", systemImage: "cube")
Spacer()
RailButton(pane: .settings, selection: $selection, label: "Settings", systemImage: "gearshape")
}
.padding(.horizontal, 4)
.padding(.vertical, 8)
.frame(width: DesignTokens.railWidth)
.frame(maxHeight: .infinity)
}
}
/// Rail button per the export: 44×44 muted icon, hover wash, and the current
/// pane raised as a surface card with a 2px selection bar on the rail's edge.
private struct RailButton: View {
let pane: WorkspaceView.Pane
@Binding var selection: WorkspaceView.Pane
let label: String
let systemImage: String
@State private var hover = false
var body: some View {
let selected = selection == pane
Button {
selection = pane
} label: {
Image(systemName: systemImage)
.frame(width: 44, height: 44)
}
.buttonStyle(.plain)
.foregroundStyle(selected ? DesignTokens.foreground : DesignTokens.muted)
.background {
if selected || hover {
RoundedRectangle(cornerRadius: DesignTokens.radius)
.fill(selected ? DesignTokens.surface : DesignTokens.foreground.opacity(0.06))
.overlay(
RoundedRectangle(cornerRadius: DesignTokens.radius)
.strokeBorder(selected ? DesignTokens.border : .clear),
)
}
}
.overlay(alignment: .leading) {
// Selection bar (`.rail-btn[aria-current]::before`); offset to sit
// on the rail's leading edge like the export's negative inset.
if selected {
Rectangle()
.fill(DesignTokens.foreground)
.frame(width: 2, height: 22)
.offset(x: -6)
}
}
.onHover { hover = $0 }
.help(label)
.accessibilityLabel(label)
}
}
/// Pane-head row per the export (52pt, serif 15 semibold title, bottom border).
struct PaneHeader<Trailing: View>: View {
let title: String
@ViewBuilder var trailing: () -> Trailing
var body: some View {
VStack(spacing: 0) {
HStack {
Text(title)
.font(.system(size: 15, weight: .semibold, design: DesignTokens.serif))
Spacer()
trailing()
}
.padding(.horizontal, 14)
.frame(minHeight: 52)
Rectangle()
.fill(DesignTokens.border)
.frame(height: 1)
}
}
}
/// Navigation-target placeholder (#17 AC: panes exist as targets; real content
/// arrives with their tickets — honest copy, no fake controls).
struct PlaceholderPane: View {
let title: String
let detail: String
var body: some View {
VStack(spacing: 10) {
Image(systemName: "hourglass")
.font(.largeTitle)
.foregroundStyle(DesignTokens.muted)
Text(title)
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
Text(detail)
.font(.callout)
.foregroundStyle(DesignTokens.muted)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
+1
View File
@@ -20,6 +20,7 @@ Owned by the root AGENTS.md contract.
- `EngineGateTests.swift` builds fake `hermes` shell scripts in temp dirs and runs them through the real `Process` path — copy that pattern for any future child-process testing.
- `ACPClientTests.swift` extends it into a full fake ACP *server*: a zsh script speaking real NDJSON JSON-RPC over stdio (`makeFakeACP`), with a per-binary mode file (`crashAfterHandshake`, `hangOnPrompt`, default full) and a base64-encoded fix-card payload — shell quoting can never break the wire JSON. Only `acpTempDir` remains as a helper; crash assertions use Swift Testing's `confirmation` (hook the callback BEFORE triggering the crash).
- `ProfileProvisionerTests.swift` extends it: the fake creates the profile at `<binaryDir>/profiles/<name>` (self-locating, race-free under parallel tests); payload dirs are built at runtime; the bundled-payload test asserts manifest ↔ payload correspondence. #48 failure-path tests live in `ProfileProvisionerFailureTests.swift` (own file — Not-Now defer + re-fail, config.yaml byte-identity + fresh-profile no-config (mcp_servers negative invariant), state.json engine-gate-only, copy-phase catch branch, path-traversal rejection, orphaned-temp sweep). Shared helpers (`makeFakeHermes`, `makePayload`, `defaultSkills`, `provTempDir`) are internal in `ProfileProvisionerTests.swift`. `ProfileBackupTests.swift` (own helpers `backupTempDir`/`makeProfileFixture`) injects profile/backups roots, a fixed clock, and a `psScan` stub — a dev machine may run the real engine, so the ps scan is never trusted in tests.
- `PostLibraryTests.swift` (#17) — throwaway Homes via `makeHome`/`writePost` in temp dirs: bare corpus posts (First Draft/writer defaults), lenient frontmatter (`pass_state`/`origin`), lazy folders + noise not surfacing, localizedStandardCompare title sort, blank-draft `untitled`, default Home = `~/Documents/Museion`.
## Verification
+111
View File
@@ -0,0 +1,111 @@
//
// PostLibraryTests.swift
// MuseionTests
//
// #17: the Posts list mirrors <home>/posts/ on disk.
//
import Foundation
@testable import Museion
import Testing
/// Builds throwaway Homes in a temp dir: posts written bare (corpus shape,
/// no frontmatter) or with frontmatter; noise entries that must not crash or
/// surface as Posts.
private func makeHome(_ write: (URL) throws -> Void) throws -> URL {
let home = FileManager.default.temporaryDirectory
.appendingPathComponent("postlib-\(UUID().uuidString)", isDirectory: true)
try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)
try write(home)
return home
}
private func writePost(_ home: URL, _ id: String, _ body: String) throws {
let dir = home.appendingPathComponent("posts/\(id)", isDirectory: true)
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
try body.write(to: dir.appendingPathComponent("post.md"), atomically: true, encoding: .utf8)
}
@Test func `bare post is first draft writer with heading title`() throws {
let home = try makeHome { home in
try writePost(home, "the-new-reeder", "## The New Reeder\n\nBody text.")
}
let library = PostLibrary.scan(home: home)
#expect(library.posts.count == 1)
let post = try #require(library.posts.first)
#expect(post.id == "the-new-reeder")
#expect(post.title == "The New Reeder")
#expect(post.passState == .firstDraft)
#expect(post.origin == .writer)
}
@Test func `frontmatter keys are read leniently`() throws {
let home = try makeHome { home in
try writePost(
home,
"a-short-defence-of-footnotes",
"---\npass_state: Pass-1 Done\norigin: ai\ntitle: ignored — body wins\n---\n\n# A Short Defence of Footnotes\n\nBody.",
)
}
let post = try #require(PostLibrary.scan(home: home).posts.first)
#expect(post.passState == .pass1Done)
#expect(post.origin == .ai)
#expect(post.title == "A Short Defence of Footnotes")
}
@Test func `empty home is empty and missing home is empty`() throws {
let empty = try makeHome { _ in }
#expect(PostLibrary.scan(home: empty).posts.isEmpty)
let missing = FileManager.default.temporaryDirectory
.appendingPathComponent("postlib-missing-\(UUID().uuidString)")
#expect(PostLibrary.scan(home: missing).posts.isEmpty)
}
@Test func `lazy folders and noise are not posts`() throws {
let home = try makeHome { home in
try writePost(home, "one", "One")
// Lazy folder: no post.md yet (created lazily on first write, #18).
try FileManager.default.createDirectory(
at: home.appendingPathComponent("posts/not-yet", isDirectory: true),
withIntermediateDirectories: true,
)
// Noise: loose file at posts/ root, hidden dir.
try "loose".write(
to: home.appendingPathComponent("posts/loose.md"),
atomically: true,
encoding: .utf8,
)
try FileManager.default.createDirectory(
at: home.appendingPathComponent("posts/.DS_Store-dir", isDirectory: true),
withIntermediateDirectories: true,
)
}
#expect(PostLibrary.scan(home: home).posts.map(\.id) == ["one"])
}
@Test func `posts sort by title locally`() throws {
let home = try makeHome { home in
try writePost(home, "z-id", "## Alpha\n")
try writePost(home, "a-id", "## Beta 2\n")
try writePost(home, "m-id", "## beta 10\n")
}
// localizedStandardCompare: case-insensitive, numeric-aware (Finder order).
#expect(PostLibrary.scan(home: home).posts.map(\.title) == ["Alpha", "Beta 2", "beta 10"])
}
@Test func `blank draft title is untitled`() {
#expect(PostLibrary.title(of: "\n\n \n") == "untitled")
#expect(PostLibrary.title(of: "---\npass_state: Pass-2 Done\n---\n") == "untitled")
#expect(PostLibrary.title(of: "") == "untitled")
// Frontmatter-first title: first non-empty line after the block.
#expect(PostLibrary.title(of: "---\norigin: writer\n---\n\n## Named\n\nBody") == "Named")
}
@Test func `home default is documents museion`() {
#expect(
AppGateState.defaultMuseionHome
== FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent("Documents/Museion", isDirectory: true),
)
}
@@ -0,0 +1,73 @@
# M1: Home & Posts list (#17)
> **Date:** 2026-10-01
> **Type:** issue
> **Reference:** https://git.babylondreams.de/AlexKucera/museion/issues/17
## Goal
Ship #17 (S1.1): the workspace shell from the design contract — nav rail (Posts, Sessions, Learnings, Settings), Posts pane mirroring the Home's `posts/` on disk with empty state, Home editable in Settings with repoint-only semantics, placeholder panes for Sessions/Learnings.
## What Was Done
- `DesignTokens.swift` — palette + geometry extracted from `museion-workspace.html` (`:root` vars, grid columns 56/232/min-420/356, radii 10/14, serif/mono designs).
- `WorkspaceView.swift` — post-gate root surface: nav rail + pane switch; `RailButton` with the export's selected-card + edge-bar treatment; honest placeholders for Sessions (#28) / Learnings (#26, #27).
- `PostsPaneView.swift` — Posts destination with Pass State group labels, post rows (title + mono meta), empty state, editor placeholder (#19–#21), mentor column (`MentorPaneView` at 356).
- `PostLibrary.swift` — `PostLibrary.scan(home:)`: mirrors `posts/` (dirs with `post.md` only — lazy folders and noise skipped), lenient frontmatter (`pass_state`/`origin`, First Draft/writer defaults), Title = first non-empty line after frontmatter with `#` stripped, `untitled` fallback.
- `SettingsPaneView.swift` — Home row + NSOpenPanel repoint; repoint-only copy in-UI.
- `AppGateState.museionHome` — UserDefaults-backed, default `~/Documents/Museion` (main's b3daac9 default, not the old `~/Museion` from the issue text).
- `MentorPaneView` root min-frame dropped (it's a column now).
- Tests (+7): PostLibraryTests — bare post defaults, lenient frontmatter, empty/missing home, lazy-folder + noise exclusion, title sort, untitled edges, default Home.
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| Column collapse instead of a fat minWidth | First build forced rail+library+editor+mentor minWidth (1064); the restored 900pt window clipped the rail and mentor off-screen (user hit it live). The export collapses at media-query thresholds (≤1100 library, ≤920 mentor); PRD says map that to macOS pane collapse. `GeometryReader` budget drives `showsLibrary`/`showsMentor`. |
| Lenient frontmatter read (`pass_state`/`origin` keys, defaults) | Corpus posts ship bare; the write-side key format is #18's to pin. CONTEXT.md: Pass State explicit, never inferred — First Draft default is the honest read of a bare post. |
| UserDefaults for the Home | A Home is a plain folder the user points at — nothing app-owned worth a database. Same floor as state.json reasoning. |
| NSOpenPanel over fileImporter | fileImporter's folder mode still shows files on macOS; one proven AppKit call beats bridging workarounds. |
| Explicit `AppGateState.init()` | `Self` in a stored-property initializer trips `@ObservationTracked` (covariant-Self compile error). |
| Scan on `.task(id: home)` only | #17 is read-only; no FS events yet — #18 adds lifecycle (create/rename/delete round-trips) and re-scan triggers. |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| Empty posts list despite defaults write | `defaults write` from the agent's shell lives in a different cfprefsd context than the `open`-launched app; plist on disk never got the key | Verified scan logic standalone (swift REPL finds both posts); user-path verification (Settings → Choose…) is the honest route — CLI defaults injection is unreliable for GUI apps |
| Rail icons "invisible" in early screenshots | 900pt restored window < 1064 minWidth → HStack laid out at min size, clipping both edges | Column collapse (above) |
| `localizedStandardCompare` order surprise | It's Finder-like (case-insensitive, numeric-aware): "Beta 2" < "beta 10" | Test expectation corrected — the code is right |
| SwiftFormat reformatting drive-by (944-line prototype diff) | Ran `swiftformat .` repo-wide | Reverted untouched files; formatted only changed files after |
| AppleScript `by` reserved word | `set {bx, by} to position` — `by` is an AppleScript term | Renamed to `btnPos`/`btnSize` |
## Verification
- Build: `xcodebuild … build` → **BUILD SUCCEEDED**
- Tests: full suite → **TEST SUCCEEDED**, 52/52 passed (45 pre-existing + 7 new)
- Lint: `swiftlint Museion/ MuseionTests/` → 0 violations; SwiftFormat clean on changed files
- Live: app launched, gate sheet passed and dismissed via AX, workspace rendered (rail/Posts/editor/mentor verified by screenshot); window-resize collapse fix built but final visual pass blocked by a fullscreen break timer — needs one manual look
## Files Changed
| File | Change Summary |
|------|---------------|
| `Museion/DesignTokens.swift` | New — design-contract tokens |
| `Museion/WorkspaceView.swift` | New — nav rail + pane shell, collapse logic |
| `Museion/PostsPaneView.swift` | New — library column, groups, empty state, editor placeholder |
| `Museion/PostLibrary.swift` | New — disk scan + lenient frontmatter |
| `Museion/SettingsPaneView.swift` | New — Home repoint via NSOpenPanel |
| `Museion/MuseionApp.swift` | `AppGateState.museionHome` + default |
| `Museion/ContentView.swift` | Post-gate root → `WorkspaceView` |
| `Museion/MentorPaneView.swift` | Root min-frame dropped |
| `MuseionTests/PostLibraryTests.swift` | New — 7 tests |
| `Museion/AGENTS.md`, `MuseionTests/AGENTS.md` | Contracts updated |
## Open Items & Next Steps
- [ ] Manual look at the collapse behavior at narrow widths (break timer blocked the final screenshot pass)
- [ ] #18 Post lifecycle — New Post button, lazy folder creation, slug naming, rename/delete round-trips; pins the frontmatter key format written on save
- [ ] Mentor engine crash on workspace entry — pre-existing #14 behavior (drift note also visible); not #17 scope but worth a #28 look when Sessions land
---
*Log written by write-log skill*
+1
View File
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
<!-- write-log: full-index -->
| Date | Type | File | Summary |
|------|------|------|---------|
| 2026-10-01 | issue | [20261001-issue17-home-posts-list_log.md](20261001-issue17-home-posts-list_log.md) | #17 shipped: workspace shell, Posts mirror, Home repoint — 52 tests green |
| 2026-09-25 | issue | [20260925-issue50-profile-backup-s2-6_log.md](20260925-issue50-profile-backup-s2-6_log.md) | #50 S2.6 daily profile backup: liveness gate, curated copy, retention 7, RESTORE.md — 8 tests green |
| 2026-09-16 | issue | [20260916-issue14-acp-bridge-s2-2_log.md](20260916-issue14-acp-bridge-s2-2_log.md) | #14 M0 ACP bridge: NDJSON JSON-RPC client, mentor pane, fix-card round-trip, crash restart — 37 tests green |
| 2026-09-05 | issue | [20260905-issue48-provisioning-failure-alert-retry-ux_log.md](20260905-issue48-provisioning-failure-alert-retry-ux_log.md) | #48 shipped: failure card with retry/Not-Now, traversal guard, temp sweep — 30 tests green |