oficina / docs Public

native: a ••• action runs at once when the Format sheet never appeared

Fable's delta review on #180, F8. Each ••• action waits for the Format
sheet's dismissal when `formatting` is set; if the sheet was asked for
but never presented (another presentation in the way), there is no
dismissal and the action was dropped. The sheet now records when it is on
screen, and an action runs at once (closing the request) when it is not.

No test: the sheet failing to present is not something the tests can
arrange.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 134c492bbacd926f9c37a13993faa0eb05b17110 parent 30b6aee
1 file changed, +10 −2
  • native/apple/Sources/DocsKit/DocsWorkspace.swift +10 −2
diff --git a/native/apple/Sources/DocsKit/DocsWorkspace.swift b/native/apple/Sources/DocsKit/DocsWorkspace.swift
index 5d9fa0b..8f0ae94 100644
--- a/native/apple/Sources/DocsKit/DocsWorkspace.swift
+++ b/native/apple/Sources/DocsKit/DocsWorkspace.swift
@@ -39,6 +39,8 @@ import SwiftUI
/// A ••• action waiting for the Format sheet to go (two sheets cannot be
/// up at once: the second would be dropped).
@State private var afterFormatting: (() -> Void)?
+ /// The Format sheet is on screen (presented, not only asked for).
+ @State private var formatShown = false
@State private var renamingAlert = false
/// Why the last rename was refused, shown in the alert brought back.
@State private var renameRefusal: String?
@@ -716,7 +718,8 @@ extension DocsWorkspace {
.onGeometryChange(for: CGFloat.self) { $0.size.height } action: { height in
model.surface.sheetCovers(height)
}
- .onDisappear { model.surface.sheetCovers(0) }
+ .onAppear { formatShown = true }
+ .onDisappear { formatShown = false; model.surface.sheetCovers(0) }
}
.onChange(of: formatting) { _, open in
// The keyboard goes and the selection stays: the text view keeps
@@ -786,7 +789,12 @@ extension DocsWorkspace {
var actions = DocsPhoneActions()
// Each closes the Format sheet first, then runs.
func run(_ action: @escaping () -> Void) -> () -> Void {
- { if formatting { afterFormatting = action; formatting = false } else { action() } }
+ {
+ // Asked for but never on screen, there is no dismissal to
+ // wait for (Fable's delta review, F8).
+ if formatting && formatShown { afterFormatting = action; formatting = false }
+ else { formatting = false; action() }
+ }
}
actions.share = run { share() }
actions.rename = run {