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
@@ -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),
)
}