fix(editor): quit rides the departure gate
shutdown() flushed both sessions best-effort and ignored the results — quitting with an unanswered #67 conflict wrote local text over the foreign disk body (flush() holds for conflicts only in the debounce), and a failed quit-time flush silently dropped the only copy of the edits. Quit now routes through the same departure gate as navigation: documentsMayDepart runs both sessions through sessionMayDepart, and the failed-flush-at-quit posture is BLOCK QUIT — applicationShouldTerminate (quitReply(posts:), before the Cold Turkey ask) refuses termination with one spoken reason via a hosted-guarded alert. PostsModel.active (weak, registered by AppGateState.init — the WritingLockState.active precedent) is the delegate's reachability. Finish-audit fixes folded in: sessionMayDepart refuses a never-loaded session's retyped words (its flush is a vacuous success — the same gap closed for navigation); shutdown stays void (no production reader of a Bool). +5 pins (conflict hold, clean flush, guest flush, never-loaded refusal, delegate refusal incl. chmod-injected flush failure), all flip-verified. Rail 708/708; format+lint clean. Closes #200
This commit is contained in:
1 parent
55be3d1a2f
commit
2334afc392
6 files changed
+198
-2
No files matched your search
@@ -148,6 +148,14 @@ extension PostsModel {
|
||||
lastError = "This piece changed on disk underneath you — answer the reload question first."
|
||||
return false
|
||||
}
|
||||
// #200 finish-audit (LOW): a never-loaded session's flush reports
|
||||
// a vacuous success — its retyped words would die with the
|
||||
// departure (quit AND navigation). Block instead: never silently
|
||||
// drop the only copy.
|
||||
if outgoing.loadFailed, outgoing.saveState == .changed {
|
||||
lastError = "This piece's file never loaded — the retyped text in the editor can't be saved. Copy it out first."
|
||||
return false
|
||||
}
|
||||
if !outgoing.flush() {
|
||||
// Append, don't replace — the flush already routed the write's
|
||||
// localizedDescription into lastError; only say what was skipped.
|
||||
@@ -173,6 +181,25 @@ extension PostsModel {
|
||||
return true
|
||||
}
|
||||
|
||||
/// #200 (gate quit-time flushes through the departure gate): the quit
|
||||
/// run of the same gate — `shutdown`'s flush half, shared with
|
||||
/// WritingLockAppDelegate's `applicationShouldTerminate` (willTerminate
|
||||
/// can no longer refuse a quit). Both open documents route through
|
||||
/// `sessionMayDepart`; false = the quit must not proceed, lastError
|
||||
/// says why. The failed-flush-at-quit posture is BLOCK QUIT (the
|
||||
/// WritingLock refusal precedent) — never silently drop the only copy
|
||||
/// of the edits, never write over an unanswered #67 foreign body.
|
||||
func documentsMayDepart() -> Bool {
|
||||
var departed = true
|
||||
if let guest = externalSession, !sessionMayDepart(guest) {
|
||||
departed = false
|
||||
}
|
||||
if let open = session, !sessionMayDepart(open) {
|
||||
departed = false
|
||||
}
|
||||
return departed
|
||||
}
|
||||
|
||||
/// #108: Move to Project — flush first (move reads disk), then the
|
||||
/// folder moves under projects/. Id stays the same; the session is
|
||||
/// reopened anyway so folderURL re-resolves to the new parent.
|
||||
|
||||
Reference in new issue
Block a user