S0 of the Docs native redesign: editor snapshots on main, drawn by today's renderer. Spec docs/superpowers/specs/2026-11-22-native-redesign-design.md §11 and plan S0 (spec/native-redesign @ 2fb4a76), plus Fable's re-review finding 13 on #157 (an iPad-width screen and an after-a-scripted-edit screen). Nothing in production changes; this branch adds the test, its fixtures and 46 baselines. Not merged, released or deployed.
Why the editor was excluded, and the fix
DocsSnapshots.swift:20 said a document's first layout could finish after the kit's settle window (and that web or Metal views draw blank). The page is TextKit 1 in NSTextView and UITextView, so it draws: the real problem is timing. The kit takes a picture once two captures 50 ms apart agree, and a document opens asynchronously, so a screen could be recorded before it opened, before its layout, or with the page laid out at the scroll view's provisional size.
native/apple/Tests/DocsSnapshots/EditorSnapshots.swift opens each fixture through the real path: a replica seeded by a paste on an in-memory server, DocsModel.open, NativeTextProjection, then NativeDocumentTextView wired as DocsWorkspace.editor wires it (page only, no toolbar or chrome). Until the screen is ready it shows a counter that changes every frame, so the kit can't settle on a half-drawn picture. Ready means: open, rendered, the stream connected and nothing left to send, the text view's text equal to a full render of the projection, then a layout once the kit has sized the window (needsLayout, then ensureLayout on the container), the fixed scroll offset, and a run-loop turn. If any step times out, the screen stays unsettled and the gate fails.
Determinism:
- Bundled faces are registered first.
- Nothing reads a clock or animates.
- The text view is never first responder, so no caret or selection is drawn.
- Mac scrollers are pinned to overlay. Legacy scrollers otherwise follow whether a mouse is connected.
- Scroll offsets are constants, never measured, so a moved line can't be hidden by scrolling with it.
Two timing bugs were found and fixed in the harness on the way. A layout that ran before the kit sized the window left the Mac paper at its 636 pt minimum width. A counter ticking in the same view as the editor re-evaluated its body on every tick.
Matrix (46 images)
Light and dark throughout. Mac at 1000 pt wide, iPhone 18 Pro 402 × 874, iPad Air width 820 × 1180 (drawn by the iOS renderer in the iPhone simulator).
| Screen | Mac | iPhone | |---|---|---| | editor-paged, editor-pageless (Millbrook: H1–H4, marks, link, bullet and ordered lists, quote, code block, inline code, centre and right alignment, indent, Caladea/Playfair/Garamond, image, rule) | ✓ | ✓, plus AX3 (docs-editor-ax3) | | editor-paged-150, editor-pageless-150 | ✓ | — (no zoom on iPhone) | | editor-paged-heading-break, editor-pageless-heading-break (38 one-line paragraphs, so an H1 is the first line of page 2 on every width) | ✓ | ✓ | | editor-paged-image-break, editor-pageless-image-break (an image is the first line of page 3) | ✓ | ✓ | | editor-paged-edited (typed through the text view at the end of line 30 with a Return, which moves the break; then a peer's insert into line 34, through the stream) | ✓ | ✓ | | editor-ar (Arabic, RTL layout direction, an embedded English name), editor-ru (long words) | ✓ | ✓ | | editor-ipad-paged | — | ✓ (iPad width) |
AX3 is drawn only for the two plain screens: the page's text doesn't scale (§9). Mac has no AX3, because the kit leaves it out.
The kit can't set a per-screen language (a bundle resolves strings in the process's language; SnapshotEnvironment says so). It doesn't need to for the page: ar and ru are document content, plus a .rightToLeft layout direction set inside the screen. The page-number label stays English. The S2a chrome screens will need the kit change the plan names; it is not done here.
Proof the gate bites
- Stable: after recording,
snapshots.sh compare all passed three times in a row, then once more on Mac. Every run passed on both platforms, with no flake. - One-point paper margin (
DocsPageGeometry.sideMargin 72→73 and 20→21): every one of the 46 editor images failed on both platforms, 2.4–14% of pixels changed each. One existing docs screen, other-ways, also failed on Mac in that run. It is green in every other run. - One attribute (code font scale 0.85→0.86): exactly the 8 Mac Millbrook screens failed, the only ones with code on screen, about 1.1–1.4% each. Every other screen passed.
- Both changes were reverted, and the gate is green again.
The tolerance is the kit's standard: a pixel counts if a channel moves more than 2 of 255, and at most 8 pixels may change. S1 must therefore be pixel-identical.
Findings in today's renderer (recorded as they are, not fixed)
- iOS editor update loop. This is the important one. Opening a document that holds a list (and, in this harness, an image or a rule) never finishes on iOS.
applyRender finds the content unequal to what it rendered (it holds an NSTextList or NSTextAttachment), so it assigns attributedText again. That moves the caret to the end and back. iOS textViewDidChangeSelection writes the selection binding even while it is applying ("Modifying state during view update"); the Mac guards this with !applying. The write calls updateUIView again, without end, at 100% CPU and growing memory (29 GB before I killed it). - Reproduced through the production DocsWorkspace with documentID: in the simulator (iOS 27.0): the Russian fixture with its lists hangs, and its first four blocks without the lists open fine. - The harness also looped after a peer's insert and after typing in the middle of a document. - Not checked on a device. - This harness therefore pins the iOS selection binding (EditorPage.selection; the Mac keeps the real one). The pictures are what the renderer draws. The loop needs its own fix branch, which is a production change and so out of S0's scope. It probably belongs before S1, which rewrites exactly this path. - Lists draw no markers on Mac or iOS.
NSTextList is set and indented, but no bullet or number is drawn. - Arabic paragraphs are left-aligned:
NativeTextProjection sets .left rather than .natural. - iOS paged: the first page's text starts at the paper's top with no 72 pt margin, and "Page 1" is drawn at the foot of page 1, where the Mac draws "Page 2" at the break.
Gates
native/scripts/check-native.sh (includes swift test), the snapshot run above, and hub CI: results in the reply below. WorkspaceInitTests and SignedInLaunchTests are untouched and run in swift test. The harness creates its model in .task, never in init or body.
Commits
cab8399 harness and fixtures, plus BUILDING.md and snapshots.sh notes9f4fcff 22 Mac baselines (1.8 MB)3e12285 24 iPhone and iPad-width baselines (1.8 MB)
Each was pushed on its own, with http.postBuffer.