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
@@ -38,6 +38,13 @@ struct PostDraft {
|
||||
@MainActor
|
||||
@Observable
|
||||
final class PostsModel {
|
||||
/// #200: the app's one model, for WritingLockAppDelegate's quit-time
|
||||
/// departure gate (the WritingLockState.active reachability
|
||||
/// precedent). Weak; registered by AppGateState's init — bare
|
||||
/// hosted-test rigs never register, so the delegate's pins inject
|
||||
/// their model through `quitReply(posts:)`.
|
||||
weak static var active: PostsModel?
|
||||
|
||||
/// The scanned, title-sorted list — mirrors `projects/` + `archive/` at
|
||||
/// all times (#107).
|
||||
/// #193: setter internal — PostsModelWatcher's rescan writes it.
|
||||
@@ -164,9 +171,15 @@ final class PostsModel {
|
||||
/// deinit of a @MainActor-held object may run elsewhere. #64: app quit
|
||||
/// flushes the open session first (sidecar rides along). #96: quit also
|
||||
/// flushes the external buffer — same posture, same moment.
|
||||
/// #200: quit is a document departure — the flush half routes through
|
||||
/// the departure gate (`documentsMayDepart`): an unanswered #67
|
||||
/// conflict never writes over the foreign body, a failed flush or a
|
||||
/// never-loaded retype lands its reason in lastError instead of
|
||||
/// silently dropping the edits. The verdict itself is quitReply's, at
|
||||
/// applicationShouldTerminate — this belt runs only at willTerminate.
|
||||
/// Watchers stop either way — the process is leaving.
|
||||
func shutdown() {
|
||||
session?.flush()
|
||||
externalSession?.flush()
|
||||
documentsMayDepart()
|
||||
watcher.stop()
|
||||
externalWatcher.stop()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user