oficina / docs Public

native: a refused rename's alert stays with its document

Fable's delta review on #180, F7. A refused rename brings its alert back
half a second later; leaving the document in between left the refusal
and the alert's binding set for the next one. `closeFormatting()` (Back,
a swipe, Delete, Discard, losing the right to write) now clears both,
and the alert comes back only if the same document is still open.

The writer XCUITest refuses a rename and goes Back at once: no alert over
the library, and none on opening the document again. It does not fail
without this change: SwiftUI does not present an alert whose binding was
already true when its view appears, so the stale state did not show here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 30b6aeeee72f083a36064d40d20cd3e63e2cc3e8 parent 7df4608
2 files changed, +17 −1
  • native/apple/Sources/DocsKit/DocsWorkspace.swift +6 −1
  • native/ios/UITests/NativeUITests.swift +11 −0
diff --git a/native/apple/Sources/DocsKit/DocsWorkspace.swift b/native/apple/Sources/DocsKit/DocsWorkspace.swift
index 6aa0d6e..5d9fa0b 100644
--- a/native/apple/Sources/DocsKit/DocsWorkspace.swift
+++ b/native/apple/Sources/DocsKit/DocsWorkspace.swift
@@ -760,9 +760,10 @@ extension DocsWorkspace {
renameRefusal = typed.utf8.count > 1024 ? "native.rename.tooLong" : (model.errorKey ?? "docs.error.generic")
// Once the alert that was answered has gone: one presented during
// its dismissal is dropped.
+ let document = model.detail?.sqid
Task { @MainActor in
try? await Task.sleep(for: .milliseconds(500))
- if renameRefusal != nil { renamingAlert = true }
+ if renameRefusal != nil, model.detail?.sqid == document { renamingAlert = true }
}
}
@@ -775,6 +776,10 @@ extension DocsWorkspace {
model.surface.suppressKeyboard(false)
model.surface.sheetCovers(0)
phoneChrome.header.sheetOpen = false
+ // A refused rename's alert waiting to come back stays with this
+ // document (Fable's delta review, F7).
+ renameRefusal = nil
+ renamingAlert = false
}
var phoneActions: DocsPhoneActions {
diff --git a/native/ios/UITests/NativeUITests.swift b/native/ios/UITests/NativeUITests.swift
index 87647f7..57dd39b 100644
--- a/native/ios/UITests/NativeUITests.swift
+++ b/native/ios/UITests/NativeUITests.swift
@@ -369,6 +369,17 @@ final class NativeUITests: XCTestCase {
app.alerts.buttons["Cancel"].tap()
XCTAssertTrue(app.alerts.firstMatch.waitForNonExistence(timeout: 5))
XCTAssertTrue(app.staticTexts["docs.document.title"].exists || inline.exists, "the document is still there")
+ // Refused again, and Back before the alert comes back: it does not
+ // come back over the library.
+ app.buttons["docs.more"].tap()
+ app.buttons["Rename document"].tap()
+ XCTAssertTrue(field.waitForExistence(timeout: 5))
+ field.typeText(String(repeating: "📄", count: 257))
+ app.alerts.buttons["Rename document"].firstMatch.tap()
+ app.buttons["BackButton"].tap()
+ XCTAssertTrue(app.buttons["Native review document"].firstMatch.waitForExistence(timeout: 5), "the library")
+ XCTAssertFalse(app.alerts.firstMatch.waitForExistence(timeout: 2), "and no rename alert over it")
+ _ = try openPhoneDocument(app, "Native review document")
// Back with the Format sheet up: nothing of it is left behind.
app.buttons["docs.format.toggle"].tap()