oficina / docs Public

Docs native S1a: four flush triggers in code and tests (#170, 6)

Following the spec amendment: the comments at inputPaused and didRender
say they are not flush triggers and why (the calls stay; they cost
nothing), DocumentSurface lists (a)–(d), and the (e) test, which only
held by wrapping canRender, is removed: no test claims a trigger that
production cannot reach. FlushTriggerTests covers the four.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 7e19bbc56f486001079c28a97d617ec050586f24 parent 28bc8c6
3 files changed, +6 −24
  • native/apple/Sources/DocsKit/DocsModel.swift +3 −4
  • native/apple/Sources/DocsKit/DocumentSurface.swift +1 −2
  • native/apple/Tests/DocsKitTests/FlushTriggerTests.swift +2 −18
diff --git a/native/apple/Sources/DocsKit/DocsModel.swift b/native/apple/Sources/DocsKit/DocsModel.swift
index e2881f5..5edae79 100644
--- a/native/apple/Sources/DocsKit/DocsModel.swift
+++ b/native/apple/Sources/DocsKit/DocsModel.swift
@@ -479,10 +479,9 @@ import RastrilloNative
// A delayed acknowledgement cannot retire the currently displayed source.
guard generation > renderedGeneration else { return }
renderedGeneration = generation
- // Trigger (d), its didRender half. canRender reads
- // projectionGeneration, not renderedGeneration, so the half that
- // can unblock is projectionGeneration's didSet; this one is kept for
- // completeness (#170, finding 6).
+ // Not a flush trigger (spec §7 Design 6): canRender reads
+ // projectionGeneration, not renderedGeneration, so trigger (d) is
+ // projectionGeneration's didSet. The call costs nothing.
surface.flushIfDeferred()
refreshToolbarSelection()
}
diff --git a/native/apple/Sources/DocsKit/DocumentSurface.swift b/native/apple/Sources/DocsKit/DocumentSurface.swift
index 30b4766..1961a09 100644
--- a/native/apple/Sources/DocsKit/DocumentSurface.swift
+++ b/native/apple/Sources/DocsKit/DocumentSurface.swift
@@ -205,8 +205,7 @@ typealias DocsStorageEditActions = NSTextStorage.EditActions
/// pending, nothing composing, the newest generation current, and no
/// marked text (spec §7 Design 6). Called on every event that can make
/// that true: (a) a publication applied, (b) the edit queue draining,
- /// (c) composition ending, (d) the generation catching up, (e) input
- /// unpaused.
+ /// (c) composition ending, (d) the generation catching up.
func flushIfDeferred(notifyLater: Bool = false) {
guard !flushing, let newest, let text = textView, let storage = text.textStorage as NSTextStorage? else { return }
let waiting = newest.revision > appliedRevision || !pendingDirty.isEmpty || fullDiff
diff --git a/native/apple/Tests/DocsKitTests/FlushTriggerTests.swift b/native/apple/Tests/DocsKitTests/FlushTriggerTests.swift
index ae4900e..120dfb3 100644
--- a/native/apple/Tests/DocsKitTests/FlushTriggerTests.swift
+++ b/native/apple/Tests/DocsKitTests/FlushTriggerTests.swift
@@ -3,7 +3,8 @@ import RastrilloApple
import XCTest
@testable import DocsKit
-/// The deferred-flush triggers (spec 2026-11-22 §7 Design 6, finding 2):
+/// The four deferred-flush triggers (spec 2026-11-22 §7 Design 6, finding
+/// 2; inputPaused and didRender are not triggers, see the spec):
/// a publication arrives while something stops the text view taking it,
/// and *no later publication* follows. When that something clears, its
/// event alone must bring the storage to a whole render of the newest
@@ -110,23 +111,6 @@ import XCTest
SurfaceFixture.assertMatchesWholeRender(shown, publication.projection, "after the generation caught up")
}
- /// (e) is wired: with a canRender that held rendering while input is
- /// paused, unpausing alone would draw the waiting publication. A
- /// wiring test only: production's canRender (spec §7 Design 6) does not
- /// read inputPaused, and must not (a reader is paused for good and
- /// still sees peers' changes), so no production state waits on (e)
- /// alone (#170, finding 6; DocsModel.inputPaused).
- func testInputUnpausedDrawsTheWaitingPublication() throws {
- let canRender = model.surface.hooks.canRender
- model.surface.hooks.canRender = { [unowned self] generation in canRender(generation) && !model.inputPaused }
- model.inputPaused = true
- let publication = try fabricated(generation: model.projectionGeneration, changing: 4)
- model.surface.apply(publication)
- XCTAssertLessThan(model.surface.appliedRevision, publication.revision)
- model.inputPaused = false
- SurfaceFixture.assertMatchesWholeRender(shown, publication.projection, "after input was unpaused")
- }
-
static func mark(_ word: String, in text: DocsTextView) {
#if os(macOS)
text.setMarkedText(word, selectedRange: NSRange(location: word.utf16.count, length: 0), replacementRange: NSRange(location: NSNotFound, length: 0))