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

+8 -8
View File
@@ -112,7 +112,7 @@ struct PostsPaneView: View {
draftText: draft.text,
draftEdited: { model.updateDraft($0) },
draftSave: {
model.saveDraft(home: home)
model.saveDraft()
},
outline: draft.type == .outline,
)
@@ -317,7 +317,7 @@ struct PostsLibraryColumn: View {
.background(LaunchFocusReset())
.sheet(item: $renamingPost) { post in
RenamePostSheet(post: post) { title in
model.rename(post, to: title, home: home)
model.rename(post, to: title)
}
}
.sheet(item: $movingPost) { post in
@@ -325,8 +325,8 @@ struct PostsLibraryColumn: View {
// the library renders (Unicode-scalar sort split them), and it
// includes empty projects (a fresh New Project has no pieces yet —
// it must already be a move target).
MoveToProjectSheet(post: post, projects: model.moveTargets(home: home)) { project in
model.moveToProject(post, project: project, home: home)
MoveToProjectSheet(post: post, projects: model.moveTargets()) { project in
model.moveToProject(post, project: project)
}
}
// #144: keystroke-debounced (250 ms), structured body scan —
@@ -355,7 +355,7 @@ struct PostsLibraryColumn: View {
/// render the same row (#144: results carry the full menu too).
private func postRow(_ post: Post) -> some View {
LibraryPostRow(post: post, selected: post.id == model.selectedPostID) {
model.select(post.id, home: home)
model.select(post.id)
}
.contextMenu {
Button("Rename…") { renamingPost = post }
@@ -363,15 +363,15 @@ struct PostsLibraryColumn: View {
// body transform, then the piece becomes a prose post.
if post.type == .outline {
Button("Convert to Post…") {
model.stageConversion(post, home: home)
model.stageConversion(post)
}
}
Button("Move to Project…") { movingPost = post }
Button("Move to Archive") {
model.archivePost(post, home: home)
model.archivePost(post)
}
Button("Move to Trash", role: .destructive) {
model.trash(post, home: home)
model.trash(post)
}
}
}