oficina / docs Public
Docs native redesign: Mac, iPhone and iPad (SwiftUI)
Status: revision 3, 2026-11-22. Approved after fixes; these are the fixes.
- Revision 1 (8354b32) was reviewed by Claude Fable 5.2 on oficina/docs #157: CHANGES NEEDED. Revision 2 (2fb4a76) answered all 19 findings.
- Fable re-reviewed revision 2: APPROVE AFTER FIXES, with no third pass needed. Revision 3 applies those fixes 1–13 and the coordinator's ruling on 14 (S1 split into S1a and S1b).
- The two tables at the end map each review's findings to where they are answered.
- The S1 and S2a branch reviews check the fixes against the code.
Branch: spec/native-redesign. Implementation branches follow the plan's slices.
Mock-ups: design/native-levelup-mockups b700109 (native/apple/Tests/DocsMockups, native/scripts/mockups.sh, native/scripts/mockups-page/), shown at polish-audit/docs-native/index.html. They are real SwiftUI drawn to PNG and wired to nothing. They are the reference for look and measurements, matched by screenshot, not code to copy.
Web reference: Docs web I2 (2026-11-11-editor-i2-design.md, main faad78a): stacked header, undo/redo in the header, Format toggles a floating inspector, Share as a popover over a server-rendered panel, readers get no formatting chrome.
Performance reference: oficina/native-levelup/docs-realtime-audit.md (findings 3, 4 and 10), and the engine's per-block project_delta (main c715478).
Why
Paul, 2026-11-21: "Can we have the Desktop and mobile apps reflect the web apps a bit more now?" The mock-up agent drew A/B directions, and Paul ruled on 2026-11-22. The audit adds that the editor's main-thread rendering still costs O(document) per key, and that work rides with this redesign because it rebuilds the same views.
Rulings and defaults
Paul's rulings, 2026-11-22 (binding):
- Mac inspector floats, like the web's (option B).
- Mac home is the Finder/Notes idiom (option B). Title, search and + in the toolbar. Below them, a shelf of page previews, then the Earlier rows with excerpts. No web header inside the window.
- iPhone formatting is a half-height sheet, plus a quick format bar above the keyboard while it is open.
- No Share pill beside the iPhone title. Share lives in the ••• menu.
- iPhone library is option B: iOS bars, with search and New at the bottom.
Coordinator's rulings on the review (2026-11-22, binding):
- iPad keeps today's layout from S3 until S5, behind a size-class and idiom gate. iPad never shows the phone layout in between.
- S2 is split into S2a (the Mac document window, floating inspector and subtitle) and S2b (the Share popover, and Delete… with its server change).
- New English strings go through copy review (the
paulca/agent-skillscopy-review skill,serve.sh) before the slice that introduces them lands.
Defaults where Paul did not answer. Each is one constant or one branch, so it is easy to flip:
| # | Default | |---|---| | D1 | The inspector is open by default. Its state is remembered app-wide (@AppStorage("docs.inspector.open")), not per window. | | D2 | Pages/Infinite, Word count and Export live only in the View, Tools and File menus, where the web has them. There is no Document tab in the inspector. Zoom stays in View on the Mac as a native-only item: the web has none. | | D3 | A subtitle under the title ("<Team> · Saved", "<Team> · View only") replaces today's sync status row. Every state the row shows today is expressible in it or in a banner (§6). | | D4 | The Mac shows the account avatar in the home window only. Document windows reach the account through the app menu. | | D5 | The page stays white in dark mode. The desk and the chrome follow the theme. | | D6 | iPad uses the Mac layout at regular width and the iPhone layout at compact width, from S5. Until then iPad keeps today's layout. | | D7 | The subtitle's team is the account's team ("the team you're in"), even on a private document or one shared in from elsewhere. The detail answer carries no visibility. Paul may prefer to add visibility (§13 Q4). |
Corrections to the mock-ups. These are facts, not choices:
- The iPhone sheet drew a "Title" style. Docs has no Title style. The styles are the web's: Body text, Heading 1, Heading 2 and Heading 3 (
docs.editor.toolbar.block.*). - The ••• menu's "Jump To…" is the web's "Open a document…" (
docs.editor.menu.file.open, ⌘K). - Keyboard shortcuts… is in Help, as on the web (
menu.go), not in Tools.
1. Mac document window
Header contract
One contract, confirmed by a half-day spike at the start of S2a. The spike result is recorded in the S2a discussion before the header is built.
- The window title is always the document's title. It is set with
.navigationTitle(title), so the Window menu, Mission Control, the Dock menu and VoiceOver's window name are right. It is never drawn twice. - The visible title area is Docs' own view, placed at the toolbar's leading edge (
ToolbarItem(placement: .navigation)). The system-drawn title is hidden (.toolbar(removing: .title)) while.navigationTitlestays set.
The title area holds: - the title in 15pt semibold; - under it, the subtitle in 11pt, with §6's styles (muted, or negative semibold), the eye glyph for View only, and one accessibility element with .updatesFrequently.
.navigationSubtitle is not used: on macOS it is a plain string and cannot carry those styles.
- Spike checklist (each item passes, or the fallback is taken): - the window can be dragged by the title area; - double-clicking the title area renames, and double-clicking the empty toolbar still zooms or minimises per the system setting; - at narrow widths, the toolbar's overflow keeps the title area and moves the trailing controls into the » menu in the order Share…, Format, undo/redo; - full screen, including the toolbar revealed on hover; - window tabs (⌘T-style tab bar, when the user merges windows): the tab shows the document title; - VoiceOver reads the window as the document title, then the subtitle.
- Spike fallback. If the spike shows the system title cannot be hidden while still set, the header uses the system title with a plain
.navigationSubtitle. §6's styling requirements then drop to text alone: - negative states put their words in the subtitle and also raise the §6 banner; - View only is written in words; - the subtitle's announcements are posted from the banner's view instead; - Rename cannot be in place, so File ▸ Rename (⇧⌘R) and the title's context menu open a small sheet with the title field (Return commits, Esc cancels).
The S2a discussion records which of the two shipped.
- The
.principalToolbarItemis deleted (documentTitleinDocsWorkspace.editor). It is what draws the title a second time today. - Rename in place. Double-clicking the title area, File ▸ Rename (⇧⌘R) or the title's context menu turns the title text into a field in the same place. - It commits through
model.commitRename()on Return or focus loss. Esc reverts. - Only people who can write may rename. - Trailing controls, in this order, 8pt apart: 1. Undo/redo: one pill holding two icon buttons with a hairline between them (
docs.editor.toolbar.undo/.redo; group labeldocs.editor.toolbar.history). Each is enabled fromcanUndo/canRedo. 2. Format: a quiet pill with a pencil icon (docs.editor.inspector.toggle). - It is a toggle: a SwiftUITogglewith a button style, so VoiceOver says "Format, toggle button, on/off". - It is accent-soft with accent text while the inspector is open. - It carries no other selected or value semantics (Low 13). 3. Share…: the one filled accent pill (docs.share.action). S2b; in S2a it opens today's sharing sheet. - Who sees which control: - Undo/redo and Format need
can_write. - Share… needscan_share, which is owner and member, the web's rule. - A draft that is not yet created on the server has no Share…. - Kit dependency. The subtitle reuses the kit's sync wording (
NativeSyncStrings.text(for:)) and its announcement rule.NativeSyncStatusView.sameKindis internal today. - A rastrillo/native change exports the rule as a publicSyncStatusAnnouncer, withsameKind,isAnnouncedandannounce(old:new:). -NativeSyncStatusViewand Docs both use it. - Docs re-pins the kit in S2a. - Removed: the formatting strip (
EditorToolbar), the trailing inspector column (thesafeAreaInsetFormwith zoom, Pages and tools), and the sync status row.
Floating inspector (ruling 1)
- Panel: - 248pt wide. It floats 12pt below the toolbar and 12pt from the trailing edge, over the desk. - 12pt corner radius, 12pt padding, glass (
glassEffect; an opaque surface under Reduce Transparency). - A hairline accent rim: accent mixed 70% into the line colour, 30% in dark. - Sections sit 16pt apart (14pt in revision 3; S2a moved it to 16, the nearest step of the spacing scale,--rst-sp-4, by AGENTS.md's spacing rule of 2026-11-22). Section labels are 11pt, semibold and muted. - Sections (web keys as labels, each an accessibility group named by its label): - Style (
docs.editor.toolbar.group.style): - The paragraph style pop-up at full width: Body text and Heading 1–3, each in its own face. - Font and Size on one row, with a 64pt size column. Font lists families in their own faces (DocsFontPopUp). Size is the eleven values 8–72. - Text (…group.text): Bold, Italic and Code, as a joined segmented row of 28pt buttons. - Alignment (…group.align): left, centre and right. - Lists (…group.lists): - Bulleted list, Numbered list and Quote. - A second row: Decrease indent, Increase indent and Clear formatting. - The web's inspector has no second row. The mock-up's does, and native keeps it (§13 Q2). - Behaviour: - The controls act on the text view's selection and never take first responder: a click leaves the caret where it was. - Selected states (
.isSelected, accent) come fromDocumentToolbarSelection, the same source the menus use. - With Full Keyboard Access, the inspector comes after the header controls in the key-view loop. In the text view, Tab keeps indenting and ⌃Tab leaves (standard AppKit). - Visibility: - The Format toggle and View ▸ Show/Hide Format (⌥⌘I) flip the one app-wide state (D1). - A reader never sees it, whatever the stored state, and a reader's window does not write the state. - Show/Hide Format is disabled in a reader's window and in the home window.
- No
.inspector. It is an overlay in the editor'sZStack, not SwiftUI's.inspector. The code records that a closed.inspectorinvalidates hosting constraints on macOS 27 while the editor loads.
Page centring (the web's rule, in the window's points)
- Coordinate spaces: - The page lives in the scroll view's document space: paper 612pt wide, magnified by
m = 4/3 × zoom(NativeDocumentTextView). - The inspector and the desk are in window points. - All centring arithmetic is in window points, withP = 612 × m. - The rule is the web's
show.htmlrule exactly. Trailing desk padding:
E = clamp(16, 16 + P + 2R − W, R)
where: - R = 248 + 12 + 16 = 276; - W is the clip view's width in window points (not the window's: no title-bar or scroller arithmetic); - the leading padding is 16.
The page is centred in the band [16, W − E]. - With the inspector closed, E = 16 and the page is plainly centred. - At W ≥ P + 16 + R, the page clears the inspector. At zoom 100% that is 1,108pt. - Below that, E = R. The page's leading edge stays at 16, and the page runs under the inspector on its trailing side. The page never reflows or shrinks; that overlap is the cost Paul accepted with B, and ⌥⌘I hides the inspector.
- Moving the page never relayouts the text. - Today the centring lives in the text container (
DocsPageGeometry.paperX), so any change of width relayouts the document. - From S2a, the container's geometry is a fixed paper band (viewportWidth= the paper width). - The mechanism is a container document view. The scroll view's document view becomes a flippedDocsDeskView, which draws the desk. Its width tracks the clip view's bounds width (already in magnified document units), and its height is the text view's. - The text view is its only subview, atx = leading / m, whereleadingis the page's leading edge in window points from the rule above andmis the magnification. - Changing the inspector state or the width sets that one frame origin.NSClipViewis not asked to honour an arbitrary document-view origin. - So toggling the inspector and live-resizing are O(1): the page slides, the text never reflows, and the caret keeps its place in the text. - "The inspector appears without moving the text" is withdrawn. It may move the page sideways, per the rule; it never reflows it.
- Tests: - A pure unit test of
Eat W = 1800, 1440, 1280, 1108, 1000 and 920pt, at zoom 1.0 and 1.5, open and closed. - A hosted-window test that measures the page's and the inspector's frames in window coordinates at the same widths, including the exact boundary (finding 5).
Share popover (S2b)
- Opening: Share… opens a popover anchored under its button (arrow at top, 420pt wide). It replaces
DocsSharingView's sheet. - Contents, one for one with the web's panel and its
docs.share.panel.*words: - Head: "Share “<title>”" and Close. -{title}is replaced in the looked-up string at runtime, the waydocs.editor.page.number's{n}is. - Error callout under the head (docs.share.panel.failed, ornative.share.loadFailed/native.share.saveFailed). - Invite row: one rounded field holding the email field ("Add people by email"), a Can read / Can edit menu and Invite. - People with access: the owner first ("(you)", Owner), then each grant with an initial avatar, its access and an × labelleddocs.share.panel.remove("Stop sharing with {address}"). - General access: - Your team: a switch (team_switch, with theteam_on/team_offline). It posts/d/{sqid}/share/team, which already answers native JSON. - Anyone with the link: a switch (link_switch, with thelink_on/link_offline). - Just published: the once-only URL, Copy link anddocs.share.panel.once. - Later:docs.share.panel.shownand Make a new link. - Behaviour: - A switch holds its new position until its request settles. On failure it reverts and shows the callout. - A second submit while one is in flight is refused. - A control that waits more than 500ms shows a spinner on itself. Nothing else is busy. - Share… while the popover is open does nothing. - Esc and Close dismiss it and return focus to Share…. - On open, focus goes to the email field.
- The once-only URL (Low 14): - While it is showing, the popover is not transient. An outside click does not close it (
NSPopover.Behavior.applicationDefined); only Close and Esc do. On iPhone, the sheet sets.interactiveDismissDisabled(true). - The URL exists only in the panel's memory for that lifetime. It is never logged or persisted, and it reaches the pasteboard only through Copy link. - When it is available: - Share… flushes first (as today). - It is disabled while the origin is offline or the document is a draft. The help tag says why (
native.share.offline).
Reader mode (can_write == false)
- Header: the title and "<Team> · View only" with an eye glyph. No undo/redo, no Format, no Share….
- Text: the text view is selectable and not editable.
- Menus: the Format menu and Show/Hide Format are disabled. Rename and Delete… are absent.
- Losing access mid-session: see §6's "Write access ends" and "No longer available" rows.
Delete… (S2b)
- Who: owners only (
can_share). A draft has no Delete…; closing an empty draft discards it, as today. - Confirmation: the web's words (
docs.delete.heading/.body/.confirm/.cancel). - Refused with unsent changes (
native.delete.unsent). - Server:
deletePostgains the native JSON answer its own comment asks for (delete.go:89-92, "No native answer"). It returns{"ok":true}afterStore.Deletecommits, with no re-read. The HTML redirect is unchanged for browsers. - Client rule, which also covers version skew: - Older or lagged servers 303 to the list after the delete has committed. The client POSTs with
Accept: application/json. - On a 2xx JSONok, the document is deleted. - On any non-JSON or redirected answer, the client GETs/d/{sqid}as JSON: 404 means deleted, 200 means failed (callout, nothing removed), anything else means failed and retryable. - A 404 on the POST is ambiguous: non-owners also get 404, with nothing deleted. So after a POST 404 the client also GETs/d/{sqid}as JSON. 404 means deleted (a retry after a lost answer lands here); 200 means it failed (callout, nothing removed). - The lane and the replica are dropped only on a JSONok, or on a re-GET 404. - After a delete: - drop the document's outbox lane and replica cache; - close its Mac window, or pop to the library on iPhone and on iPad; - remove it from the home list, File ▸ Recent and the thumbnail cache; - reload the list.
- Deploy order: the server change deploys to every instance with native users (prod and lagged) before the client that uses it is released. Because of the client rule above, an undeployed server is still safe.
- Tests (Go): - the owner gets JSON
ok; - a writer grantee, a reader, a guest and a team non-owner get 404 with nothing deleted; - an already-deleted document gets 404; - a lookup failure gets JSON with the failure status shape (ownerLookupFailureOrStatuswith native accept); - the browser's 303 is unchanged; - the suite feed announces the deletion (softDelete). - Tests (Swift): the client rule against a stub answering JSON
ok, 303-to-HTML then 404, 303-to-HTML then 200, POST 404 then GET 404 (deleted), and POST 404 then GET 200 (failed; lane and replica kept).
Menus and shortcuts (Mac)
The menu bar maps the web's six menus onto the Mac's. Labels are the web's keys where one exists.
| Menu | Items | |---|---| | File | New document ⌘N · Open a document… ⌘K · Recent ▸ · Rename ⇧⌘R · Save ⌘S · Export ▸ PDF…, Markdown… · Share… · Print… ⌘P · Delete… (owner only) | | Edit | System items · Undo ⌘Z · Redo ⇧⌘Z (the responder's) | | View | Show/Hide Format ⌥⌘I · Paged / Infinite (a pair, the web's docs.editor.menu.view.paged / .infinite) · Zoom ▸ 50–200% and Actual size ⌘0 (native-only) | | Format | Bold ⌘B, Italic ⌘I, Code · Style ▸ Body text, Heading 1–3 · Bulleted list, Numbered list, Quote · Font ▸ · Size ▸ · Align left/center/right · Increase indent, Decrease indent · Clear formatting. The labels are the inspector's web keys (docs.editor.toolbar.*, docs.editor.menu.format.*), replacing "Normal", "Bullet list", "Block quote", "Inline code" and Headings 4–6. H4–6 content still renders and edits. | | Tools | Word count… | | Help | Keyboard shortcuts… · Colophon |
- Open a document… ⌘K opens the jump palette (
DocsJumpSheet) as a sheet over the focused window, or over the home window when no document is focused. Choosing a result opens or focuses that document's window. (Today ⌘K brings the home window forward.) - ⌥⌘I. The web has no Format shortcut. ⌥⌘I is the Mac's inspector convention (Pages, Keynote) and is free in Docs.
2. Mac home window (ruling 2)
- Toolbar: - Window title "Documents" (
docs.list.title). - A search field (.searchable, promptdocs.list.search.placeholder, labeldocs.list.search.label). - A filled accent + (New document,docs.list.create.label, ⌘N; shown whencan_create). - A divider, then the account avatar (D4). - Avatar: a 28pt circle with the identity label's initial on accent-soft (
docs.chrome.account, with "{address}" replaced). Its menu: - Teams, Use another Oficina ID, Other ways to sign in…, then Sign out of <label>. - Each keeps today's guards: disabled with the reason while documents are open or changes are unsent. - A server-address account shows Accounts… and Sign out, as now. - Content: on the desk colour, with a column at most 1,200pt wide, centred. - Shelf: the newest five documents (the web's
recentShelf) as page previews, 170×220pt. - Each shows the title (2 lines), the time or date, and the shared glyph. - One row. When it does not fit, it scrolls horizontally. - Labelled "Recent", visibly as drawn and to VoiceOver. - Rows: everything older, in a rounded card, grouped like the web's: Today, Yesterday, This week, Earlier. - The groups use the device's calendar and time zone. - Each row has a thumbnail, the title, a one-line excerpt and the date, trailing. - The excerpt is already in the list JSON (thumbnail.Excerpt).DocumentThumbnailDatadecodes it, so no server change is needed. - Searching: ranked rows only, no shelf and no groups. No results showsdocs.list.search.none.*. - Empty:docs.list.empty.*with New document. - List failure: a callout with Try again. - Removed: the sidebar holding one "Recent" row, and the "Recent documents" large title.
- Unchanged: opening a document opens or focuses its window. File ▸ Recent and Window ▸ Home stay.
3. iPhone document (rulings 3 and 4)
Header and scrolling
- Navigation bar: - Back (to the library). - Trailing: the undo/redo pill, Aa (Format) and ••• (
native.more). - Readers get back and ••• only. - Large title area: the title, bold, at most three lines, with the subtitle (§6) under it. There is no Share pill (ruling 4).
- How it scrolls with the text: - The large title is a SwiftUI header hosted inside the
UITextView's own scroll view: aUIHostingControllerview added as a subview above the text. The text view's toptextContainerInsetequals the header's measured height. - So the title scrolls with the text and there is no outer scroll view. - The header's content comes from a smallDocumentHeaderStateobject: title, subtitle, collapsed. It is separate from the text view's host, so updating it never re-evaluates that host. - The coordinator'sscrollViewDidScrollsetscollapsedwhen the offset passes the header's height. The header's height changes go back as an inset update on the coordinator, not through SwiftUI state on the host. - Collapse: the title folds into the bar as a two-line inline title (title truncated, subtitle under it): - when the text scrolls past the large title; - when the keyboard appears; - when the Format sheet opens. - It unfolds only when scrolled back to the top with the keyboard down. - Under Reduce Motion it fades, with no movement.
- Rename: from ••• ▸ Rename, an alert with a text field. It commits through
model.commitRename().
••• menu
The web's File, View, Tools and Help, in this order. Items a capability forbids are absent, not disabled.
- Share… (
can_share) · Rename (can_write) - Export ▸ PDF…, Markdown…, Print… · Word count… · Open a document… · Paged / Infinite (a checkmarked pair)
- Help ▸ Keyboard shortcuts…, Colophon · Delete… (owner, destructive, S2b's rules)
There is no zoom on iPhone. The page fits the width, as it does today.
Format sheet (ruling 3)
- Opening: Aa, or Aa in the keyboard bar, opens a sheet at the
.mediumdetent only, with.presentationBackgroundInteraction(.enabled(upThrough: .medium)), so the text stays interactive above it. - The selection stays visible. - Opening the sheet does not resign first responder. The text view's
inputViewis set to an empty, zero-height view andreloadInputViews()is called. The keyboard goes, and the selection highlight and caret stay. - Closing the sheet restoresinputView = niland reloads, so the keyboard returns only if it was up before. - The text view's bottom content inset follows the sheet's height, and the selection is scrolled into view above it. - Typing marks: a mark chosen with a collapsed caret (for example Bold) is kept as today's
typingMarksuntil the caret moves or text is typed, and the sheet's Bold shows it as selected. Closing the sheet does not clear it. - Contents (the web inspector's sections, in one screen at default Dynamic Type): - Head: "Format" (
docs.editor.inspector.label) and a close button (native.close). - Style: Body text and Heading 1–3 as chips, each in its own face. The current one has an accent outline and.isSelected. They scroll horizontally when they do not fit. - Font and size: the font picker (DocsFontPickerButton, families in their own faces), then a size stepper (− value +) over the eleven sizes. - Marks and alignment: Bold, Italic and Code, then left, centre and right (one row; two rows from AX1). - Lists and indent: bulleted, numbered and quote, then decrease indent, increase indent and clear formatting (one row; two rows from AX1). - Applying: every control applies to the current selection, and the sheet stays up.
Keyboard bar
- Mechanism: the
UITextView'sinputAccessoryView, aUIInputViewhosting a SwiftUI capsule. NotToolbarItemGroup(placement: .keyboard), which does not attach reliably to a wrappedUITextView. - When: writers only. A reader's text view has no accessory.
- Items: Aa (opens the sheet), Bold, Italic, Bulleted list, Numbered list, Quote, a divider, then Hide keyboard (
native.keyboard.hide). - Marks and lists show.isSelectedfromDocumentToolbarSelection. - Targets are at least 44pt. At AX sizes the capsule scrolls horizontally rather than shrinking. - Hardware keyboard: the system shows the accessory at the bottom of the screen; that is accepted. ⌘B and ⌘I work through the text view's key commands.
Share sheet (S2b)
The same panel as the Mac's popover, as a sheet with .medium and .large detents.
- Focus goes to the email field when VoiceOver is off; with VoiceOver on, it goes to the head.
- Not dismissible by swipe while the once-only URL shows.
Reader (iPhone)
Back and ••• only, and "<Team> · View only" with the eye glyph. No keyboard bar and no Format sheet.
Removed on iPhone
These go on the iPhone only. iPad keeps them until S5.
- The
NavigationSplitView(library | editor). The library is aNavigationStackroot and the document is pushed. - The horizontal formatting strip.
- The toolbar's Paged toggle, export control, Tools menu and Share button. They move to •••.
- The sync status row.
4. iPhone library (ruling 5)
- Bars: a large title, "Documents", and the account avatar trailing, with the Mac avatar's menu plus Colophon.
- Bottom toolbar: the search field (
DefaultToolbarItem(kind: .search, placement: .bottomBar), promptdocs.list.search.placeholder) and a filled compose button (New document,square.and.pencil; whencan_create). - Content: the same
LibraryModelas the Mac home. - A horizontally scrolling shelf of the newest five. - Then grouped rows: thumbnail, title, date, two-line excerpt, shared glyph. - Searching shows ranked rows. Empty, no-results and failure states are as on the Mac. - Pull to refresh reloads the list. - New document: the existing
beginDocument()path, pushed.
5. iPad (D6; S5)
- Gate: until S5,
UIDevice.current.userInterfaceIdiom == .padkeeps today's views (theNavigationSplitView, the strip, the toolbar items). S1's rendering changes apply to iPad too; the gate only chooses the chrome. S5 removes the gate. - Compact width (Slide Over, narrow split): exactly the iPhone layout.
- Regular width: - Library: the Mac home's content. "Documents", search, + and the avatar are in the navigation bar. A document is pushed full screen, with no sidebar. - Document: - The Mac's header contract in the navigation bar: back, the title area at the leading edge, then undo/redo, Format, Share… and ••• (the iPhone's menu, for touch). - The floating inspector and the page-centring rule are the Mac's, in the text view's points; the iPad text view has no magnification. - Share is a popover. - Menus: the iPadOS 26 menu bar carries the Mac's menus and shortcuts (
.commands). - Changing size class keeps the same text view, selection, scroll position and undo stack. - The inspector closes at compact width without changing the remembered state, and never turns into the sheet by itself. - An open Format sheet closes at regular width, and the inspector shows if the remembered state says open.
- Pagination (Low 16): iPad keeps iOS's geometric pagination, where lines may split across pages, not the Mac's whole-block plan.
PARITY.mdrecords it. - Multi-window and state restoration are unchanged from today. S5 records in
PARITY.mdwhat iPad does: which scenes it supports, and what a relaunch restores.
6. States
Subtitle
The subtitle is <Team> · <state>.
- Team: D7. For an Oficina ID, the team's name (
OficinaTeam.name). For a server-address account, the account name Settings shows. With no name, the state alone, with no separator. - Joining: a format key,
native.subtitle.joined("%1$@ · %2$@"), so right-to-left languages can order it. It is looked up as a String key and formatted withString(format:), never interpolated into a key. - Precedence: top to bottom, the first row that applies wins.
| # | Condition | Subtitle | Style | Announced | Extra | |---|---|---|---|---|---| | 1 | No longer available: refreshAccess got 403 or 404, or a stream or write was refused and the re-GET says 404 | "No longer available" (native.subtitle.unavailable) | negative | yes | The editor becomes read-only. Banner native.unavailable.body ("This document was deleted or is no longer shared with you.") with Close (Mac) or Back (iPhone), and Discard changes when unsent. Held entries stay held; nothing is sent. Covers a document deleted on another device. Not terminal: a later refreshAccess answering 200 (re-shared or restored) leaves this row for row 10 or 11 by can_write, and calls retry() to release the held entries. | | 2 | failed(held) | "Some changes could not be saved." (sync.failed.held) | negative, semibold | yes | Banner: today's errorKey text, Try again, and Discard changes when unsent | | 3 | failed(cannotSaveOnDevice) | "Can’t save on this device." | negative | yes | Input paused (unchanged) | | 4 | failed(tooManyUnsent) | "Too many unsent changes…" | negative | yes | Input paused (unchanged) | | 5 | needsSignIn(n), n > 0 | "Sign in to send n pending" | negative | yes | Banner with Sign in (the account flow, as Settings' Sign in… opens it) | | 6 | needsSignIn(0) | "Signed out" (native.subtitle.signedOut) | negative | yes | The same banner. Input behaves as today (typing still reaches the outbox); nothing new is paused. | | 7 | offline(n) | "Offline · n pending" | muted | yes | NativeOfflineBanner (durable wording) under the header, unchanged | | 8 | retrying(n) | "Trouble saving · Retrying…" | muted | no | none | | 9 | Not .saved continuously for ≥ 1 s (.saving, or a draft being created) | "Saving…" | muted | no | none | | 10 | Write access ends (can_write becomes false on a 200 re-GET), or was never there | "View only", with an eye glyph | muted | no (yes when it changes mid-session) | Reader chrome, applied in place. Caret, scroll and selection are kept. Pending entries follow today's outbox rules. | | 11 | saved | "Saved" (native.subtitle.saved) | muted | no | none | | 12 | saved, origin offline | "Saved" | muted | no | NativeOfflineBanner: the banner is driven by connectivity, not by status, so "Saved" plus the banner is a real, correct state | | 13 | Loading (no projection yet) | the team only | muted | no | A spinner on the page |
Notes on the table:
- 401 no longer touches
can_write. - TodayrefreshAccessmaps 401, 403 and 404 alike tocan_write = false. Then a re-minted session would leave the window at row 10 with reader chrome. - From S2a, a 401 setsinputPaused = true, as today, and leavescan_writeand the chrome alone. The session machinery re-mints, and when the outbox restarts after the replaced session (1433e2b),refreshAccessruns again: a 200 clearsinputPausedwithcan_writeunchanged. - The "401" unit test expectscan_writeunchanged and input paused. Its subtitle is fromSyncStatus: row 5 or 6 if the session ended, otherwise row 8 while the outbox retries. - 403 and 404 become row 1, each with its own test. - Opened from the device's copy while offline: the detail and capability are the cached ones and the status is the outbox's. So the rows above apply unchanged (typically 12, or 7 with pending changes). There is no extra text: the banner already says offline. When the connection returns,
refreshAccessmay move the window to row 1 or row 10. - A draft being created is row 9 while creation is in flight. If creation fails, it is row 2 with
native.pending, and row 7 while offline. - Debounce (row 9): the subtitle shows "Saving…" only after the status has been continuously not
.savedfor 1 s. The clock restarts on every return to.saved. It runs in a.task(id: statusKind)that sleeps 1 s and sets a@Stateflag, never inbody. Rows 1–8 show at once. - Announcements: the kit's rule through the exported
SyncStatusAnnouncer, plus rows 1 and 10's mid-session changes. Entering offline, needs-sign-in, failed or unavailable is announced. A count change inside the same kind is not. Saving is never announced. - Element structure: the subtitle is one accessibility element with
.updatesFrequently, present even when quiet. In the spike fallback, the banners carry the styling instead (§1).
Banners and dialogs
All unchanged in behaviour; only the placement moves.
errorKeybanner (native.pending,native.recovered,docs.error.generic,docs.editor.status.retrying): a callout under the header, not a row above the editor. It keeps Try again and Discard changes.- Lost changes (
sync.unsentLost): the existing alert. - Close or quit with unsent changes:
DocsCloseGuard, unchanged. - Discard: the existing confirmation.
Other states
- Signed out: the home window and the iPhone root show the Oficina ID door as today. Straight-in, and the account menu's items and guards, are unchanged.
- Offline: editing continues into the outbox, exactly as today. Share… and Delete… are disabled with reasons. Export, which needs the server, is disabled with
native.share.offline's siblingnative.export.offline. Open a document… searches only what is loaded. - Document failed to open:
ContentUnavailableViewwithdocs.error.genericand Try again.
7. Rendering architecture (rides with this work)
Problem
From the audit; S1 re-measures on main after phase 2 before any work starts:
- The Mac paged view copies and lays out the whole document twice per key (
DocsPagedTextView.updatePagination; finding 3). - SwiftUI evaluates the editor body 4–11× per key. Each evaluation runs a full
NativeTextProjection.render, as doDocsToolsControls,DocsEditorContext.actionsandEditorToolbar(finding 4). - iOS sets
attributedTextto the whole document per publication, and lays out everything inlayoutSubviews(finding 10, and finding 3's iOS half).
The engine knows which top-level blocks a transaction changed (project_delta). But the delta is relative to CRDTReplica.presented, and three things break any assumption that the surface sees every delta:
presentedadvances on every projection call, includingreplica.projection()at open and elsewhere (DocsModel.swift:301).publishCurrentdrops a computed presentation when typing, composition, selection or the epoch moved (DocsModel.swift:380).- The text view defers a render while
canRenderis false or text is marked.
So a delta cannot be forwarded as a patch.
Design
- Revisions and a dirty log in the replica (findings 1 and 7 of both reviews). -
CRDTReplicakeepspresentedRevision, a counter incremented every timepresentedchanges, for any caller. - Every delta it applies appends(revision, touchedBlockIDs)to a bounded log of the last 512 revisions.touchedBlockIDsare the ids the delta's ops insert or remove. The engine expresses an edit in place as remove plus insert of the same id, so edits are covered. - An unknown entry is recorded every timeauthorityProjectiontakes the fullprojectbranch instead ofproject_delta. That covers open, a fresh source, recovery, a generation reset, anddelta.applied(to:)returning nil. - (The revision 2structuralflag is dropped. It had no reader.) - The dirty set comes back atomically with the presentation. -
CRDTReplicais an actor and the surface is@MainActor, so the surface never asks the replica anything during an apply. -DocsModelreadssurface.appliedRevisionon the main actor and passes it assinceintopresentation(…, since:). - The replica returns(projection, resultRevision, dirty), wheredirtyis the union of touched ids over exactly(since, resultRevision], or nil if that span is older than the log or contains an unknown entry. -DocsModelforwards the triple to the surface only when it actually publishes. A publication dropped bypublishCurrent's guards loses nothing:appliedRevisionhas not moved, so the next presentation's span covers it. -DocsModelstops holding the projection as observed state (@ObservationIgnored). DocumentSurfaceis new,@MainActor, one per open document, and deliberately not@Observable. It holds: -appliedRevision, the revision its storage reflects; - the newest projection and itsresultRevision; - a per-block render cache keyed by block id; -pendingDirty, a set of block ids, and afullDiffflag; - the block index (item 4); - the pagination caches (Incremental pagination); - a weak reference to the text view.
Attaching a different text view (the host rebuilt without the model opening again: an iPad split collapsing, a restructured window) lets the old one go and draws the new one whole. reset(), when the replica changes (open, a new draft, a discard), clears what the surface remembers so the next publication is drawn whole, but keeps the attached text view: a new draft or a discard keeps the same host, which nothing rebuilds to attach it again (S1a review, #170 finding 2; coordinator's ruling).
It exposes the live text storage as the content that DocumentCommands, word counts and DocumentToolbarSelection read.
- The block index tracks storage, not publications (finding 1). - The authority for "which characters belong to which block" is the storage's
.docsTopBlockattribute (NativeTextProjection.swift:25), which optimistically typed text inherits. - The index is a list of runs(blockID, range)over that attribute. - The surface keeps it current in the storage'sdidProcessEditing: runs before the edited range are untouched; runs after it shift by the change in length; the runs overlapping the edit are re-read from the attribute. - This is O(blocks) integer work per edit, and correct before any publication arrives. - Per-block reconciliation and the break lookup both use this index. - A provisional block is one id run that spans more than one paragraph. It appears after an optimistic Return: the new paragraph inherits its block's id until the publication gives it its own. - A Backspace at a block's start gives the reverse: one paragraph holding two id runs. - Both are legal transient states. Reconciliation handles them as the blocks the publication names. Pagination treats a run as one unit, and allows a break only where a run starts a paragraph. - Applying a publication is synchronous on the main actor: - If
resultRevision ≤ appliedRevision, it is stale and dropped. - A setdirtyis merged intopendingDirty. A nildirtysetsfullDiff: every block of the new projection is compared with its cache by id and by structural equality (CRDTNodebecomesEquatable), and the differing, new and missing ones are marked. - The surface keeps the newest projection andresultRevision, then callsflushIfDeferred(). flushIfDeferred()runs only when the text view can render:canRender(newest generation)is true (no pending input, not composing, generation current) and there is no marked text. When it runs: - walk the new block order against the old with two pointers (unchanged ids stay; missing ids are removed; new ids are inserted); - render every block inpendingDirty, plus any new ones; - reconcile each changed range into storage; - setappliedRevision = resultRevision; - clearpendingDirtyandfullDiff.
It is called on every event that can turn canRender true (finding 2): - (a) a publication applied (item 5); - (b) the edit queue draining: drainEdits ends with editing empty and editingTask cleared; - (c) composition ending: compositionChanged(false), and the text view's unmarkText / marked text committed or cancelled; - (d) the generation catching up: projectionGeneration changes.
SwiftUI's updateNSView / updateUIView no longer retries renders, so these hooks are the only triggers. A test covers each, including (b) and (c) with no later publication: storage must converge with nothing else arriving.
Two events are not triggers (revision 3 listed them; S1a review, #170 finding 6, coordinator's ruling). canRender reads neither inputPaused nor renderedGeneration, so neither inputPaused being cleared nor didRender advancing renderedGeneration can be the event that unblocks a waiting publication. canRender must not start reading inputPaused: a reader's input is paused for good, and it would then never see a peer's change. A writer paused by a refused command still holds it in editing, as pending input, so (b) draws when the queue drains after the retry. The implementation still calls flushIfDeferred() at both points, because it costs nothing, but no test claims them as triggers.
- Per-block rendering: -
NativeTextProjection.renderBlock(node, neighbours:)renders one top-level block, including inline code and the list numbering inside it. - After a block changes, spacing attributes are recomputed for its neighbours only (DocumentBlockSpacingcollapses margins between neighbours). - When an image arrives, only the blocks containing it are re-rendered. A late font registration marks every block that uses that family. - Whole-documentrenderremains for open, the full-diff path's first build, and the tests' oracle. - Per-block reconciliation: - For each changed block,
DocumentRenderReconciliationruns against the storage's substring for that block's run(s) in the block index, not the whole storage. - It keeps the optimistic-text, marked-text and generation guards exactly as today. - iOS uses the same reconciliation, and setsattributedTextonce, at open. - Render isolation: - The text view's representable is created once per document. Its
update…Viewhandles only identity-level inputs: editable, paged, zoom, and the surface reference. - Projection changes flow model → surface → storage by direct call, never through SwiftUI state. - The view that hosts the text view reads none of:syncStatus,outboxSummary,selection,detail,editing,typingMarks,inputPaused,connectivity,hasPendingInput, the projection. - Each of these is read only by the small view that shows it: the title area, the undo/redo pill, the inspector, the keyboard bar, the banners,DocumentHeaderState. - Editability changes are pushed to the text view by the surface. - Selection and toolbar state: - The selection lives in the text view. The model learns it by callback, without an observed property. -
DocumentToolbarSelection(marks, block, font, size, alignment,canUndo/canRedo) is computed from the live storage at the selection, and published as one observed value assigned only when it differs. - No redundant observed assignments: every assignment to observed model state is guarded by inequality (
detail,pendingTitle,draftToken,errorKey,inputPaused).
Incremental pagination (Mac)
Today:
DocumentPageLayout.measureruns over an unpaginated copy of the storage. It walks top-level blocks with absolute tops andused.maxY, breaks before a block whenbottom − pageTop > 648, and recordsstarts[characterIndex] = top + addedand the separators.DocsPageTextContainer.blockStartsis keyed by character index, and setting it callstextContainerChangedGeometry, which invalidates all layout.
New:
- A retained measurement stack on the same storage (finding 4). This is production's one definition of "natural geometry". - A second
NSLayoutManagerwith a plain rectangular container, as wide as the paper's text, is attached to the same liveNSTextStorage. There is no copy, nomeasurementContentand noisEqual. - It is unpaginated, so its geometry is exactly the natural one today's measurement computes. Live edits reach it automatically. - It uses non-contiguous layout, so an edit re-lays out only the edited lines there. - It never draws, and nothing reads its coordinates except the caches below. - The code comment atDocsPagedTextView.swift:66(never clear the live container to measure) stays true: the live container is never cleared. - Per-block caches (finding 3), indexed by block-index run: -
advance(i): from block i's first line-fragmentminYto block i+1's first line-fragmentminY. For the last block, to itsused.maxY. -usedBottom(i): the last line'sused.maxYminus block i's firstminY. - The two margin attributes.
Natural tops are prefix sums of advance, starting at the first block's top (which includes docsFirstMargin). Inserting or removing blocks is a splice in these arrays. Off-screen blocks need only their cached numbers.
- The full path fills the caches by laying out the whole measurement stack once. It runs: - at open; - when Pages is turned on; - when a font registration affects every block; - when the paper's text width changes.
Before S2a the Mac's width changes alter only paperX, not the text width, so they do not trigger it. Zoom is magnification and never triggers it. - At open the full path runs contiguously up to the visible bottom first, synchronously. The rest runs in idle chunks of 50 blocks per run-loop turn. Until it completes, page breaks below the measured frontier are provisional and the frame height is estimated from the average measured advance. - A jump (scroll, ⌘↓, find-to-caret) past the frontier first measures contiguously up to the target.
- Per edit, structural or not: - The dirty blocks are the block-index runs touched since the last pass. That covers an edit inside a block, an optimistic Return (the provisional run grows by one paragraph), a block delete, a multi-block paste, and a flush with several dirty blocks. - Each dirty run is re-measured on the measurement stack (
ensureLayout(forCharacterRange:)over that run only), and its cache entries are spliced or replaced. - Today's break algorithm then runs, unchanged, over the cached natural coordinates. It starts at the page holding the first dirty block and continues past the last dirty block until it reaches a break that lands on the same block with the sameextraas before. Becauseextradepends only on margins, everything after that point is a pure shift and is not recomputed. - A block taller than a page needs nothing special, and is not a full-path trigger. It is one cached advance like any other, so typing in a long list or code block costs only that block's re-measure. - All of this runs at most once per run-loop turn, from a run-loop observer that runs before the window's display pass. - Break table and lookup (findings 2 and 8): - The container's table becomes
breaks: [BlockID: extra]. -lineFragmentRect(…at characterIndex:)asks the block index whethercharacterIndexstarts a run that begins a paragraph and has a break. If so, it returnsrect.origin.y = max(proposedRect.minY, topLive(j)), wheretopLive(j) = topU(j) + X(j): the natural top from the caches, plus the sum ofextraover breaks at or before block j. - Because it usesmaxagainst an absolute top, it is idempotent when TextKit proposes a rect twice for one line, as today'smax(rect.minY, top)is. - Keys are block ids, so typing before a break re-keys nothing. -docsFirstMarginat index 0 is kept as today. - Invalidation: - A break-table change never calls
textContainerChangedGeometry. The surface callsinvalidateLayout(forCharacterRange:)on the live layout manager, from the first block whosetopLivechanged to the end, withinvalidateDisplayfor the visible part. - The live manager uses non-contiguous layout, so the lines after it are laid out again only when they are displayed. - If no height changed, nothing beyond the edited block's own lines is invalidated. - Frame height comes from the caches:
topU(last) + usedBottom(last) + X(last) + verticalMargin, with the existingdocumentHeightrounding. It is never read from the last glyph. layout()no longer callsensureLayout(for:)on the whole container. The caret's line is laid out synchronously before AppKit draws the caret.- Oracle: today's
DocumentPageLayout.measure, with its copy and separate stack, moves verbatim into the test target asDocumentPageLayoutOracle. It is a test reference only and differs from production's full path (item 1) by construction. The property test compares production's breaks, every live line-fragment origin (within 0.5pt) and the frame height against a fresh oracle run. - Large-document check (Mac): - Open p200h. Wait until the full path's idle chunks complete (a probe flag); the live layout manager then holds no layout beyond the first screen (asserted through its non-contiguous holes). - Then ⌘↓ to the end and type. - The caret-against-glyph check passes; no line straddles a separator; the page numbers equal the oracle's. - A second variant jumps to the end immediately at open, before the idle chunks complete. The jump's contiguous measurement makes the same assertions pass.
iPhone layout (finding 5)
layoutSubviewsstops callingensureLayout(for: pages).- iOS pagination stays geometric:
lineRectsnaps a line topage(at: proposal.minY). There is no break table. - Layout is non-contiguous, and content height comes from the layout manager's estimate, corrected as layout completes.
- Check: open p200h paged in the simulator and jump to the end before the live container has laid out past the first screen. Then: - the caret-against-glyph check passes; - no line straddles a page gap; - after layout settles, every line origin near the end equals that of a fully laid-out container's.
S1b finding and ruling (#173, coordinator, 2026-11-26): this plan does not hold with UIKit's TextKit 1, and the iPhone moves to TextKit 2 in S3.
- The iOS container is not a simple rectangle, so the layout manager never lays it out non-contiguously; and its background layout (on, and not public API on iOS) lays the rest of the document out synchronously inside every storage edit that changes a line count, whatever
layoutSubviewsdoes. Measured on 200 pages paged in the simulator: opening lays out all of it (21,808 line requests, 1.5 s); a key that makes a new line lays out the rest (12,349 requests, about 0.5 s); plain keys 4–6. The "Fallback" below is not available on iOS either, since TextKit lays out to the end itself. - Turning the non-public
backgroundLayoutEnabledoff fixed a bare stack, but it is private API (App Store risk) and crashed the test on the text view's own layout manager. Not used. - Ruling: iPhone pagination stays as it is for S1b. S3 rebuilds the iPhone editor on TextKit 2 (the iPhone redesign rebuilds that editor anyway), and S3's acceptance carries this check and the p200h targets: per key at p200h paged, main-thread time ≤ 8 ms median with no stall over 16.7 ms on a key that changes a line count; opening p200h paged lays out no further than the visible bottom (target ≤ 250 ms main-thread to the first screen).
- For S3 to investigate (noted, not fixed): on today's iPhone code, at the end of a 200-page document, the
UITextViewcaret rect was 72.7 pt above its glyph's line (PhoneLargeDocumentTests, env-gated). Unverified on a device; it may be the probe's.
Fallback, both platforms
If a platform's large-document check fails with non-contiguous layout, that platform switches the live layout manager to contiguous layout, laid out only to the visible bottom: ensureLayout(forBoundingRect:) on the visible rect at open and on every jump. That is exact. It costs O(position) once per jump, never per key, and the edit-path gates still hold, because edits invalidate from the edited block and only the visible lines are laid out again. The measurement stack keeps non-contiguous layout either way. The slice's discussion records which mode each platform ships.
Measurement and targets (finding 6)
- Probes on main. S1 brings
native/benchmarks/realtime/(the ui-probe,run-ui.py,run-e2e.py,RealtimeAudit*Tests,DocsAuditProbe) onto main. - The counters compile under their own Swift compilation condition,DOCS_PROBES, set only by the probe builds. They are measured in the Release configuration withDOCS_PROBESon. Shipping builds never set it. - New counters: host-view body evaluations, block renders, whole-document renders,attributedTextassignments, and line-fragment requests made by TextKit to our containers. - That last counter sees TextKit's own re-layout as well as ours, so it cannot pass vacuously (finding 6). - Baseline first. S1a's first step records main's numbers after phase 2 (
c715478or later), for every row below, innative/benchmarks/README.md. The timing targets below are then confirmed or adjusted, with the reason, in the S1a discussion before implementation continues. - Engine time and main-thread time are reported separately. Peer → visible is split into network plus engine (out of scope here) and main thread (in scope). Only the main-thread part is a target.
- Hard gates (deterministic; exact; a regression blocks the merge):
| Counter, after open | Per key (40 keys) | Per peer change | Per sync-status change | |---|---|---|---| | Whole-document renders | 0 | 0 | 0 | | Block renders | ≤ 3 (the block and two neighbours) | ≤ 3 per touched block | 0 | | Body evaluations of the text view's host | 0 | 0 | 0 | | iOS attributedText assignments | 0 | 0 | 0 | | Line-fragment requests in DocsPageTextContainer.lineFragmentRect (Mac live manager) and the iOS container | ≤ the edited block's lines + the visible lines + 8 | ≤ the touched blocks' lines + the visible lines + 8 | 0 |
- Timing targets (indicative until the baseline confirms them). Each target holds when the median over three runs is within 20% of it. If it misses, re-run three more with the machine's load average under 4; it fails if the median of all six misses. p95 figures use 200 keys, not 40.
| Measure (probe) | p20 | p200h | |---|---|---| | Mac keyDown → return, paged (run-ui.py) | ≤ 5 ms median, ≤ 10 ms p95 | ≤ 8 ms median | | Mac keyDown → return, pageless | ≤ 3 ms | ≤ 5 ms | | Main-queue stalls > 16.7 ms over 40 keys at 8 keys/s | 0 | ≤ 2 | | Peer change: main-thread time from publication to drawn | ≤ 5 ms | ≤ 10 ms | | iPhone main-thread time per one-block publication (RealtimeAuditIOSTests) | ≤ 4 ms | ≤ 8 ms | | Longest main-thread block on Pages toggle, width change or zoom | ≤ 150 ms | ≤ 250 ms | | Mac inspector toggle and live resize (main-thread per frame; from S2a) | ≤ 4 ms | ≤ 4 ms |
- Caveats, stated beside the numbers in the README: - The UI probe uses an in-memory store and skips the sealed outbox's disk writes. - iPhone figures come from the simulator on the Mac's CPU, not a phone. §11's device pass is the sanity check, not a measurement. - Machine, load and build are recorded with every run.
8. Strings
- Where: in
Resources/<lang>.lproj/Localizable.strings, all twelve languages (ar, bn, en, es, ga, hi, ja, pt, ru, vi, yue, zh-Hans). - Reuse: a web key is reused where one exists, with the web's English. The ones not yet in the native catalogs are added under their web names with all twelve translations: -
docs.editor.toolbar.history-docs.editor.toolbar.group.style/.text/.align/.lists-docs.editor.toolbar.code,.quote,.bulletlist,.orderedlist(if missing) -docs.editor.inspector.label,docs.editor.inspector.toggle-docs.editor.menu.view.infinite,docs.editor.menu.file.open,docs.editor.menu.tools.shortcuts,docs.editor.menu.help,docs.help.colophon-docs.share.action,docs.share.panel.*(all) -docs.editor.menu.file.delete,docs.delete.heading/.body/.confirm/.cancel-docs.chrome.account - New native keys (English shown; every one goes through copy review before its slice lands): -
native.subtitle.saved"Saved" -native.subtitle.viewOnly"View only" -native.subtitle.joined"%1$@ · %2$@" -native.subtitle.unavailable"No longer available" -native.unavailable.body"This document was deleted or is no longer shared with you." -native.subtitle.signedOut"Signed out" -native.more"More" -native.keyboard.hide"Hide keyboard" -native.format.show"Show Format",native.format.hide"Hide Format" -native.list.recent"Recent" (moved fromMac.strings, where it is an English key) -native.share.offline"Connect to share this document." -native.export.offline"Connect to export this document." -native.delete.unsent"Wait until your changes are saved, then delete." - Rules: - Never interpolate a key.
check-native.shalready refuses\(…)in key literals. Keys built from parts are built as a String first. - Placeholders{title}and{address}are replaced in the looked-up value. -Mac.stringsEnglish keys left with no reader after a slice are deleted in that slice. - A test asserts that every key the new views use resolves in all twelve tables, and that no value is the key itself.
9. Accessibility, RTL and long languages
- VoiceOver: - Every icon control has the web's name (Undo, Redo, Format, Bold, Italic, Code, Align left/center/right, Bulleted list, Numbered list, Quote, Increase/Decrease indent, Clear formatting, More, Hide keyboard). - Selected states use
.isSelected, never colour alone. Format is a toggle (§1). - The inspector and the sheet are containers named "Format", with the four named groups. - The subtitle follows §6's announcement rule. - The shelf is a list named "Recent". A row reads as title, date, excerpt and "Shared". - Dynamic Type (iPhone and iPad): - The title, subtitle, library rows, sheet and menus scale to AX5. - The sheet re-flows to two rows per section from AX1, and the keyboard bar scrolls instead of shrinking. - The page's text does not scale. The Mac and iPad have Zoom (View menu); the iPhone page fits its width and has no zoom of its own. System Zoom remains available.
- Keyboard (Mac and iPad): - The shortcuts in §1. - Full Keyboard Access reaches every header and inspector control. - Esc closes the popover and the sheet and returns focus.
- Targets and motion: - Targets are at least 28pt on the Mac and at least 44pt on iPhone and iPad. - Under Reduce Motion: no slide on the inspector, a fade on the title collapse. - Reduce Transparency gives opaque glass. Increase Contrast keeps the inspector's rim and the pressed outlines visible.
- Right-to-left (ar is shipped): - The window chrome mirrors: the title area at the leading edge, the controls at the trailing edge, the inspector at the trailing edge (the left in RTL), and the centring rule's leading and trailing padding swapped. - The paper does not mirror. The text's own paragraph direction comes from the document, as today. - Glyphs mirror where they mean direction: undo/redo arrows and indent/outdent (use
.flipsForRightToLeftLayoutDirection(true)or the SF Symbols' built-in RTL variants). Alignment glyphs and the list glyphs do not mirror. - The keyboard bar's order and the shelf's scrolling direction mirror. - Long languages: the 248pt inspector, the header pills and the keyboard bar must not truncate a label in ru or ga. Pills grow, and inspector labels wrap to two lines. A snapshot per new screen in ar and ru proves both (§11).
10. Hard rules (restated; each has a test that must stay green)
- No observed state is mutated in a view's
initorbody(the Docs 0.1.7/0.1.8 launch hang). All new views derive. State changes happen in actions,.task,.onChangeand callbacks; the saving debounce is a.task.WorkspaceInitTestsandSignedInLaunchTestscover the new document and home bodies. - Never FOUT.
DocsFonts.register()runs before the first scene, as now. The style chips, the style pop-up and the font menus draw bundled faces that are already registered. The snapshot gate registers first. - Offline and outbox behaviour is unchanged. Every keystroke still reaches the sealed outbox first. Pacing, echo suppression, persistence and the K3 crash rules are untouched.
OfflineDurabilityTests,OfflineKillTestsandtest-offline-kill.pystay green. - Oficina ID straight-in is unchanged. The account items are Teams, Use another Oficina ID, Other ways and Sign out, with today's guards.
OficinaIDAdoptionTestsstay green. - Accessibility as §9.
- The snapshot gate is updated (§11) and compared before every merge.
- Window identity (account, origin, document) and the close and quit guards stay as
2026-09-20-mac-document-windows.mdspecifies. The inspector state is app-wide, and document window restoration is unchanged from that spec.
11. Test plan
- Editor snapshots, before S1 (S0; finding 3): - Today the gate excludes the editor (
DocsSnapshots.swift:20). S0 adds fixed-fixture editor screens drawn by today's renderer, on main, and records them: - Mac paged and pageless at 100% and 150%; - iPhone paged and pageless; - an iPad-width editor (regular width, today's iPad layout), because S1 changes iPad rendering and nothing else looks at iPad until S5; - an "after a scripted edit" screen on Mac and iPhone: open the fixture, type a line before the first page break, and apply a peer insert in a later block, then capture. Recorded from today's renderer, it compares S1's incremental path by pixels too; - light and dark, iPhone at default and AX3. - The fixture is the mock-ups' Millbrook document, plus a list, quote, code, a heading at a page break and an image. It is laid out synchronously before capture:ensureLayouton the container, then a run-loop turn. - S1 must leave these baselines unchanged, pixel for pixel. That is S1's visual acceptance. - Unit (DocsKit): - Subtitle: every §6 row gives its text, style and announcement, including rows 1, 6, 9 (with the 1 s debounce restarting on
.saved), 10 and 12. 401, 403 and 404 each go to their row. - Header capability: reader, writer, owner and draft give the controls and menu items specified, on all three layouts. - Inspector state: open by default, app-wide, never shown to readers, and a reader's window does not write it. - Page centring:Eat the six widths and two zooms, open and closed, including the 1,108pt boundary. In RTL the paddings swap. - Share panel model: a switch holds and reverts; the once-only URL appears once, is gone after close, and blocks outside dismissal while it shows; Share while open is a no-op; a second submit is refused. - Library: shelf of five, the four groups in a fixed time zone, searching ungrouped,Excerptdecoded, dates via the locale. - Replica dirty log: revisions advance on every projection call; the dirty set returned with a presentation covers exactly(since, resultRevision]; it is nil past the log or across an unknown entry (includingdelta.appliedreturning nil); a stale publication (resultRevision ≤ appliedRevision) is dropped. - Block index under optimistic typing: typing, Return, Backspace at a block's start and a paste go through the real text view with no publication. The index's runs equal the.docsTopBlockruns read fresh from storage, including provisional blocks. When the publication then arrives, reconciliation produces a full render's storage. - Deferred flush triggers (finding 2): one test per trigger (a)–(d) in §7 Design 6. Each has a publication arriving while that condition blocks rendering, and no later publication. Storage converges to a full render once the condition clears. - Block render equivalence (property test, Low 17): random edit sequences over fixtures with nested lists, quotes, headings, inline code, images and alignment. The edits include: - insert and remove at index 0; - split and merge across blocks; - multi-block paste; - undo and redo of each.
After each publication, storage built per block equals a full render of the same projection, attribute for attribute. - Delta safety through the real text view (finding 1): a hosted NativeDocumentTextView (Mac NSTextView, iOS UITextView in the simulator) with optimistic typing, plus: - publications dropped by publishCurrent's guards; - publications delayed past further projections; - extra replica.projection() calls; - marked text from a ja and a zh input (setMarkedText) while peer edits land in the same block and in another; - a forced log overflow.
At quiescence, storage equals a full render of the replica's projection. - Pagination equivalence (property test, finding 2): - The edits are typed through the real DocsPagedTextView, and the checks run both before the publication arrives and after it. - The edits include: edits before a break; an optimistic Return and a Backspace at a block's start; a block delete; a multi-block paste; a flush with several dirty blocks; typing inside a block taller than a page; and typing that moves a break forward and back. - The fixtures include a large heading and an image as the first line after a break (finding 8). - After each edit (before and after the publication): - production's breaks equal a fresh DocumentPageLayoutOracle run's; - every live line-fragment origin equals the oracle's within 0.5pt; - the frame height equals the oracle's. - Render isolation: host a document window, type 40 keys, flip the sync status 10 times and move the selection 20 times. The host body counter does not move, and whole-document renders stay at zero after open. - Line-fragment requests (finding 6): per key, at p20 and p200h, the requests our containers receive stay within the §7 gate. They are counted inside lineFragmentRect, so TextKit's own re-layout is seen. - Large documents: the Mac check (§7 Incremental pagination 10, both variants) and the iPhone check (§7 iPhone layout). If either fails, the platform takes the §7 fallback, and the check must then pass on it. - Strings: every used key resolves in all twelve tables (§8). - Delete: the Go matrix and the Swift client rule in §1.
- Hosted-window launch tests (
DocsWindowTests): - Building the new document body and home body changes nothing they watch. - ⌥⌘I flips the inspector in every open window and persists across relaunch. - The window title equals the document title, with exactly one visible title and no.principalitem. - The page and inspector frames match the centring rule at the six widths (finding 5). - Share popover focus in and out, and its non-transient mode. - Format and Show/Hide Format are disabled for a reader and in the home window. - A window moves to View only and to No longer available in place, keeping scroll and selection. - iOS (simulator,
review-ios.py/ XCUITest): - The keyboard bar appears with the keyboard, for writers only, and with a hardware keyboard connected (simulator "Connect Hardware Keyboard"). - Aa opens the sheet at medium with the selection highlight still visible above it. - The title collapses on scroll and on typing. - The ••• items match each capability. - VoiceOver check (Low 18): with the caret mid-paragraph, a peer edit to another block does not move the VoiceOver cursor or the caret. -performAccessibilityAudit()passes on the library, document, sheet and share sheet at default and AX3. - Snapshot gate (
snapshots.sh): add, in light and dark, with iPhone at default and AX3, and every new screen also in ar and ru (default size): - Mac: document with the inspector open and closed, reader, share popover, home, home empty, home with no results. - iPhone: document, reader, format sheet, share sheet, library, library empty.
Their baselines replace library*. If the snapshot kit (rastrillo/native RastrilloSnapshots) cannot set a locale per screen, adding that is a listed kit change in S0.
- Physical devices (Low 19): before each slice's release, one pass on a physical Mac and a physical iPhone (and an iPad for S5), recorded in
native/REVIEW.md: - open p20; - type; - a peer edit; - the Format sheet or inspector; - VoiceOver on the header. - Performance: §7's gates and targets, before S1, after S1, and before each later slice merges.
- Existing gates:
make ciandcheck-native.sh(including the 200-page document),test-document-window.py,test-home-loading.py,test-offline-kill.py,test-sync-latency.py, and hub CI exit 0.
12. Out of scope
- Import… (the web's Word and Google imports). Native has no import client.
- Web changes. The only server change is Delete…'s native JSON answer.
- Comments, history, find/replace and insert menus, as on the web.
- Engine work beyond the revision, the dirty log and the atomic dirty set in
CRDTReplica. Peer-visible engine and network time is not targeted here. - iPad multi-window and new state restoration.
- Release and TestFlight steps. Each slice ships by the existing release process once approved.
13. Open questions for Paul
- Import on native. The web's header has Import…. Should the Mac home and the iPhone library get it later (a new client for
/import), or stay web-only? Fable's default: later. - The inspector's second Lists row (indent, outdent, clear formatting) is native-only, as drawn. Should the web inspector gain it too? Fable's default: later.
- Share… while offline is disabled with "Connect to share this document." The alternative is to open the panel showing the last-loaded state, read-only. Fable's default: disabled.
- The subtitle's team on a private document (D7). Keep the account's team as context, or add
visibilityto the detail answer and say "Private" instead?
Revision 2: changes from #157 (Claude Fable 5.2, CHANGES NEEDED)
| # | Finding | Where answered | |---|---|---| | 1 | Delta forwarding is unsafe | §7 Design 1–4: replica revisions and a bounded dirty log; publications carry resultRevision; the surface's pendingDirty accumulates across deferred renders; a full diff when the log cannot answer; a real-text-view test with ja/zh marked text, dropped and delayed publications, and log overflow (§11) | | 2 | Pagination against today's container | §7 Incremental pagination: breaks keyed by block id with relative offsets; per-block natural geometry reconstructed from the live layout; invalidation from the first moved break, lazily; frame height from the plan; the old measurement as DocumentPageLayoutOracle, compared on plan, line origins and height; the p200h jump-to-end caret check | | 3 | S1's snapshot check was vacuous | §11 S0: editor snapshots recorded on main from today's renderer before S1; S1 must leave them unchanged | | 4 | .navigationSubtitle cannot carry §6 | §1 Header contract: a custom title area with the system title hidden but set, a spike at the start of S2a, a stated fallback; the kit's SyncStatusAnnouncer export listed as a rastrillo/native change | | 5 | Centring formula and threshold | §1 Page centring: the web's clamp with upper bound R, threshold P + 16 + R (1,108pt), coordinate spaces stated, page moved by translation (O(1)), a hosted-window frame test; "without moving the text" withdrawn | | 6 | Measurability | §7 Measurement: DOCS_PROBES condition measured in Release; baseline first; engine split from main thread; deterministic counters as hard gates; timing tolerance and re-run rule; caveats stated | | 7 | §6 gaps | §6 rows 1, 6, 9, 12; notes on 401, the cache-opened case, drafts and the debounce; D7 and §13 Q4 for the private-document team | | 8 | Delete… under-specified | §1 Delete…: client rule for version skew and lost answers; deploy order; the full Go and Swift matrices; refresh of list, Recent and thumbnails; pop to library; drafts have no Delete… | | 9 | iPhone feasibility | §3: inputAccessoryView; the hardware keyboard; an empty inputView keeps the selection; typing marks; the large title inside the text view's scroll view via DocumentHeaderState; the iPhone zoom claim removed (§9) | | 10 | RTL and long languages | §9 RTL and long languages; ar and ru snapshots per new screen (§11) | | 11 | Menus vs the web | §1 Menus: Keyboard shortcuts in Help; the Paged/Infinite pair; Zoom stated as native-only (D2); Format menu on the inspector's web keys; ⌘K's behaviour; Show/Hide Format disabled for readers and in home | | 12 | Slice safety | Coordinator's rulings: the iPad gate (§5) and the S2a/S2b split (plan) | | 13 | Toggle semantics | §1: Format is a toggle, nothing else | | 14 | Once-only URL in a transient popover | §1 Share: non-transient while the URL shows; no swipe dismissal on iPhone | | 15 | Copy review | Coordinator's ruling: every new English string through copy review before its slice lands (§8; plan acceptance) | | 16 | iPad pagination, multi-window, restoration | §5 notes; §10 rule 7; §12 | | 17 | Property-test coverage | §11 block render equivalence edit list | | 18 | VoiceOver and peer edits | §11 iOS | | 19 | Physical devices | §11 physical-device pass per platform before each release |
Revision 3: fixes from the re-review (#157, APPROVE AFTER FIXES)
| # | Finding | Where answered | |---|---|---| | 1 | Block ranges under optimistic typing | §7 Design 4: the index tracks the storage's .docsTopBlock runs, updated in didProcessEditing; provisional blocks defined; §11 block-index test and pagination test typing before the publication | | 2 | Deferred flush was circular | §7 Design 6: five named triggers (a)–(e), and SwiftUI no longer retries; §11 one test per trigger with no later publication | | 3 | Structural edits, oversized blocks, zoom | §7 Incremental pagination 2–4: per-block advance and usedBottom caches, with tops by prefix sum and splices; Return, delete, paste and multi-dirty flushes specified; oversized blocks and zoom are not full-path triggers | | 4 | Full path vs oracle | §7 Incremental pagination 1, 3, 9, 10: production's full path is a retained measurement layout manager on the same storage; the oracle is today's code in the test target; the p200h check defined in terms of the live container, with a second variant | | 5 | iPhone non-contiguous layout | §7 iPhone layout: a p200h jump-to-end check; §7 Fallback for both platforms (contiguous to the visible bottom) | | 6 | Vacuous invalidation gate | §7 Measurement: counts TextKit's line-fragment requests inside our containers, bounded per key | | 7 | Actor hop; unknown entries; structural | §7 Design 1–2, 5: the dirty set returned atomically with the presentation for (since, resultRevision]; stale publications dropped; unknown = any full project branch, including a nil delta.applied; structural dropped | | 8 | Relative offset not idempotent | §7 Incremental pagination 5: max(proposed.minY, topU + X) from the cache, idempotent; large-heading and image-after-break fixtures | | 9 | §6 leftovers | Row 6 keeps today's input behaviour; a 401 pauses input without flipping can_write and resumes on re-mint, with its expected rows named; row 1 is left on a later 200 | | 10 | Delete… POST 404 ambiguity | §1 Delete…: a POST 404 is re-GOT too; lane and replica dropped only on ok or a re-GET 404; Swift cases added | | 11 | Spike checklist, fallback rename | §1 Header contract: a six-item checklist; Rename by sheet in the fallback | | 12 | Centring mechanism | §1 Page centring: a flipped DocsDeskView as the document view, with the text view's frame origin at leading / m | | 13 | S0 coverage | §11: an iPad-width editor screen, and an after-scripted-edit screen on Mac and iPhone | | 14 | S1 split (coordinator's ruling) | Plan: S1a (probes, log, surface, per-block, isolation, iOS reconciliation) and S1b (pagination, lazy layout, fallbacks) |
S1a amendments (#170, coordinator's rulings, 2026-11-24)
| # | Finding | Where answered | |---|---|---| | 2 | A second text view on one surface was never drawn; should reset() drop the text view? | §7 Design 3: attaching a different view draws it whole; reset() keeps the attached view | | 6 | Triggers (e) and didRender's half of (d) cannot unblock anything | §7 Design 6: four triggers, (a)–(d); the two events are no longer triggers, and why |
S1b amendments (#173, coordinator's rulings, 2026-11-26)
| # | Finding | Where answered | |---|---|---| | 1 | The iPhone plan (no whole-document layout, non-contiguous, or the contiguous fallback) cannot hold with UIKit's TextKit 1; the only lever found is private API | §7 iPhone layout: iPhone pagination unchanged in S1b; no private API; S3 moves the iPhone editor to TextKit 2 and carries the p200h per-key and open-time targets in its acceptance | | 2 | A possible 72.7 pt caret offset at the end of a 200-page document on the iPhone | §7 iPhone layout: an S3 investigation item | | 3 | The Mac ships the live layout on §7's fallback (TextKit does not lay out a non-rectangular container non-contiguously). Pages off or on at the end of a 200-page document re-lays out from the first break to the visible end: 0.50–0.63 s measured at load 450–600, against the ≤ 250 ms target | Known gap, recorded here and in the plan; not an S1b blocker |