refactor(posts): route every library write through one rail
CI / ci (push) Canceled after 0s

#179: every library-reflecting store write (draft save, session-born
post, rename, move to project, archive/restore, trash, convert,
project creation, import batch, pass advance) now rides one internal
seam — performWrite pairs the write with exactly one rescan and owns
the error strip (cleared BEFORE the write so importFiles' per-file
failure messages survive the success tail; a nil-Home refusal writes
nothing). The model owns the Home: watchedHome is private(set), set
only by bind (construction + the Settings repoint); no public method
takes a Home parameter — 14 view call sites and ~115 test call sites
swept, dead home plumbing cut. The editor's debounced flush, the card
closes, the pass substrate and the micropub publish stay off the rail
by design (own error semantics, no library regroup).

A converged review finding is closed with a guard: the pass advance
re-resolves watchedHome after the engine's minutes-long turn, so a
mid-pass Settings repoint now refuses the advance with an honest strip
message instead of silently stamping pass state into the repointed
library (wrong-piece write on a slug collision). createProject
failures now surface in the sheet AND the strip — the rail-owns-the-
strip posture supersedes the #108 sheet-only rule.

Five rail pins (PostsModelWriteRailTests, suite members): write → one
library refresh + strip cleared, failed write owns the strip, nil-Home
refusal, import batch keeps per-file messages, mid-pass repoint
refuses the advance — the last two flip-verified against their guards.
ScriptedEngine gains endHeldPrompt (release a held turn as ended).

Verification: suite 657/657 the evening this landed; the next-morning
re-run could not start — both test runners hung before establishing
connection (#134 testmanagerd wedge; an untouched control suite hangs
identically — machine state, not this diff; reboot pending). Rail pins
5/5 isolated after the last test-only edit; swiftlint at baseline
parity; swiftformat clean.

Closes #179

[Generated by AI]
This commit is contained in:
AlexKucera committed 2026-11-10 08:45:04 +01:00
1 parent 627ecf515e
commit 5bf09552f6
27 files changed
+572 -345

No files matched your search

+11 -12
View File
@@ -117,14 +117,14 @@ struct WorkspaceView: View {
// answer (Esc/Cancel) drops the batch.
.sheet(isPresented: originAskBinding) {
OriginAskSheet(count: gate.posts.pendingImportURLs?.count ?? 0) { origin in
gate.posts.importFiles(origin: origin, home: gate.museionHome)
gate.posts.importFiles(origin: origin)
}
}
// #108: File ▸ New Project… ask — commands can't present sheets, so
// the model stages and this window presents (OriginAsk pattern).
.sheet(isPresented: newProjectAskBinding) {
NewProjectSheet { name in
if let reason = gate.posts.createProject(named: name, home: gate.museionHome) {
if let reason = gate.posts.createProject(named: name) {
return reason
}
gate.posts.newProjectPending(named: name)
@@ -137,9 +137,9 @@ struct WorkspaceView: View {
// drop; Esc/Cancel backs out with nothing opened.
.sheet(isPresented: outlineGuardBinding) {
OutlineGuardSheet {
gate.posts.openGuardedOutlineInProse(home: gate.museionHome)
gate.posts.openGuardedOutlineInProse()
} openAsOutline: {
gate.posts.openGuardedOutlineAsOutline(home: gate.museionHome)
gate.posts.openGuardedOutlineAsOutline()
}
}
// #114 (S4): the Convert to Post ask — which body the outline
@@ -147,7 +147,7 @@ struct WorkspaceView: View {
// is the default: lossless. Esc/Cancel converts nothing.
.sheet(isPresented: convertAskBinding) {
ConvertSheet(lossy: gate.posts.pendingConversion?.lossy ?? false) { headingsLadder in
gate.posts.convertToPost(headingsLadder: headingsLadder, home: gate.museionHome)
gate.posts.convertToPost(headingsLadder: headingsLadder)
}
}
}
@@ -286,7 +286,7 @@ struct WorkspaceView: View {
case .archive:
// #108: list-only pane — clicking a row selects the piece and
// hops to Posts where its editor lives.
ArchivePaneView(home: gate.museionHome, model: gate.posts) {
ArchivePaneView(model: gate.posts) {
selection = .posts
}
case .settings:
@@ -352,7 +352,6 @@ struct WorkspaceView: View {
/// verdict: a destination, not a library disclosure). List-only: clicking a
/// piece selects it and hops to Posts, where the editor column lives.
private struct ArchivePaneView: View {
let home: URL
var model: PostsModel
/// Fired after a row select — the pane can't reach WorkspaceView's
/// selection itself.
@@ -437,7 +436,7 @@ private struct ArchivePaneView: View {
// 'Unarchive Group' — it moves the whole
// project, not one piece.
Button("Unarchive Group") {
model.unarchiveProject(project, home: home)
model.unarchiveProject(project)
}
.buttonStyle(BorderedSecondaryButtonStyle(minHeight: 24))
.help("Move the whole project back to projects/")
@@ -453,7 +452,7 @@ private struct ArchivePaneView: View {
// at x28 (the one indent). The hairline is
// BOUNDED to the fixed frame: x14 → 706.
LibraryPostRow(post: post, selected: post.id == model.selectedPostID) {
model.select(post.id, home: home)
model.select(post.id)
onOpenPiece()
}
.overlay(alignment: .bottom) {
@@ -464,14 +463,14 @@ private struct ArchivePaneView: View {
}
.contextMenu {
Button("Move Back to \(post.project)") {
model.restorePost(post, home: home)
model.restorePost(post)
}
Button("Rename…") { renamingPost = post }
// #114 (S4): works archived too — the piece
// stays where it is, only type + body flip.
if post.type == .outline {
Button("Convert to Post…") {
model.stageConversion(post, home: home)
model.stageConversion(post)
}
}
}
@@ -496,7 +495,7 @@ private struct ArchivePaneView: View {
.background(DesignTokens.background)
.sheet(item: $renamingPost) { post in
RenamePostSheet(post: post) { title in
model.rename(post, to: title, home: home)
model.rename(post, to: title)
}
}
}