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

One internal seam (PostsModelRail.swift) now pairs every library
verb store write with exactly one library rescan and owns the error
strip: saveDraft, newPostFromSession, rename, trash, createProject,
moveToProject, archivePost, restorePost, unarchiveProject,
importFiles, convertToPost, and runPass pass-state advance (12 sites
on this base; the pass snapshot/stats writes, the publish stamp, and
the editor flush stay outside by design).

The model owns the Home: boundHome is set by bind() alone (app
construction + Settings repoint); every public verb lost its home:
parameter (create post/outline/session-born, rename, move, archive,
restore, trash, convert, project creation, import, select, cards,
passes, blind read, publish).

The three rail entries are railWrite/railWriteReturningReason/
railWriteKeepingStrip — deliberately NOT overloads: a shared base
name let unlabeled trailing-closure calls resolve into the labeled
non-generic entry (Swift binds trailing closures to labeled first
parameters), silently bypassing the strip and the pairing.

Views + 11 test files swept to the homeless signatures (160 sites).
RED suite green: 3/3. Full unit suite: 654/654. Fixes #179
This commit is contained in:
AlexKucera committed 2026-11-10 03:05:48 +01:00
1 parent 8c5ceffa3c
commit 06283b6287
23 files changed
+364 -363

No files matched your search

+10 -10
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)
}
}
}
@@ -437,7 +437,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 +453,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 +464,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 +496,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)
}
}
}