fix(editor): Home repoint rides the departure gate; document identity is (Home, ID)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Settings committed the new Home and bind flipped watchedHome without departing the open session: the session's immutable target kept the OLD Home, a same-slug piece in the new library made the ID-only reselect return it, and autosave/Save/quit wrote the old library while structural operations resolved against the new one. #198's departure gate never saw this seam; a no-collision piece was torn down by the vanish path with its dirty buffer dropped. The gate runs BEFORE anything commits. PostsModel.repoint(to:) is a document departure through the same sessionMayDepart (all three legs: unanswered #67, failed flush, never-loaded retype — no parallel gate); on refusal nothing changes (preference, watchedHome, the session's (A, id) target, its buffer), on acceptance the departed piece's state dies with it. AppGateState.repointMuseionHome(to:) commits the preference and its persistence only after the gate; WorkspaceView's Settings binding routes through it and the root .task(id:) binds the model after that commit — the dumb binder. A refusal speaks the #198 reason the way #200's quit refusal does (hosted-guarded alert: no Posts strip is in sight from Settings). Nothing auto-reopens after an accepted repoint — the writer picks from the new list; the in-memory draft survives (no Home until first save; dropping it would drop the only copy). Document identity is (Home, ID) everywhere — EditorSession.targets is the pair, PostsModel.openSessionTargets the model-side question; every ID-only session comparison is retired: select's reselect no-op, openUnguarded, the structural rail (rename/trash/move/archive/ restore/unarchive + flushOrAbort), conversion, the pass guard (its answer now carries the Home it validated), Micropub's launch, the lock's arm/body reads. Async continuations re-validate identity at COMPLETION: refreshCards (launch and hop-back — the old ID-only guard let a scan from the previous library land its cards on the new library's same-slug piece) and rescan (the stale-Home verdict is hoisted: a scan that outlived a repoint applies nothing, not just the vanish check; the #67 disk read runs only for a session targeting the scan's own Home). scanPieceCards is the per-model injectable scanner the deterministic stale-scan pin needs. Tests: PostsModelRepointTests (7) move to the gated entry and go green (17/17 with PostsModelDepartureTests — the #198 matrix stays green and composes); the stale-scan pin's RED is a mutation check (completion guard reverted to ID-only → only that pin fails, cards → ["Hedging"]; restored byte-exact). The #179 mid-pass repoint pin drives the real Settings path now (repoint + bind). swiftformat 0/152, swiftlint 0.
This commit is contained in:
1 parent
bce6abb38b
commit
8b0d43aed8
12 files changed
+298
-72
No files matched your search
@@ -12,6 +12,7 @@
|
||||
// WorkspaceChrome.swift; RailButton stays (the rail is its only caller).
|
||||
//
|
||||
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
/// The post-gate main surface. Posts shows the full four-column workspace;
|
||||
@@ -248,6 +249,37 @@ struct WorkspaceView: View {
|
||||
)
|
||||
}
|
||||
|
||||
/// brief-28 (home-repoint-retains-old-editor-target): a Home repoint is a
|
||||
/// document departure. The binding's setter IS the gate —
|
||||
/// `repointMuseionHome` runs the departure gate first and commits the
|
||||
/// preference (and its persistence) only when every open document
|
||||
/// landed; the root `.task(id: museionHome)` binds the model after that
|
||||
/// commit. A refusal keeps Home A and every buffer, and speaks the #198
|
||||
/// reason the way #200's quit refusal does — the Posts strip that shows
|
||||
/// `lastError` is not in sight from Settings.
|
||||
private var homeRepointBinding: Binding<URL> {
|
||||
Binding(
|
||||
get: { gate.museionHome },
|
||||
set: { newHome in
|
||||
guard gate.repointMuseionHome(to: newHome) else {
|
||||
presentRepointRefusal()
|
||||
return
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// Hosted tests never present (the quit refusal's guard convention).
|
||||
private func presentRepointRefusal() {
|
||||
guard !AppGateState.hostedTestRun else { return }
|
||||
let alert = NSAlert()
|
||||
alert.messageText = "Home not changed — a piece needs you first"
|
||||
alert.informativeText = gate.posts.lastError
|
||||
?? "An open piece could not be saved. Tend to it, then choose the folder again."
|
||||
alert.addButton(withTitle: "Back to Museion")
|
||||
alert.runModal()
|
||||
}
|
||||
|
||||
/// #151: the pill/card state — the gate's phase machine plus the
|
||||
/// provisioning failure verdict.
|
||||
private var statusVisibility: EngineStatusSurface.Visibility {
|
||||
@@ -259,7 +291,6 @@ struct WorkspaceView: View {
|
||||
|
||||
@ViewBuilder
|
||||
private func paneContent(_ geo: GeometryProxy) -> some View {
|
||||
@Bindable var gate = gate
|
||||
switch selection {
|
||||
case .posts:
|
||||
// #14: mentor column hands in the app-scoped model + gate's winner.
|
||||
@@ -303,8 +334,9 @@ struct WorkspaceView: View {
|
||||
// #137 (S4): a committed Chat model change restarts the resident
|
||||
// chat engine in place (slice A's engine-side API; deferred to
|
||||
// turn end while streaming).
|
||||
// brief-28: the Home control binds through the repoint gate.
|
||||
SettingsPaneView(
|
||||
home: $gate.museionHome,
|
||||
home: homeRepointBinding,
|
||||
binaryPath: gate.gateModel.currentBinaryPath,
|
||||
onChatSurfaceWrite: { gate.mentor.requestRestart() },
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user