oficina / docs Public

S2a: Mac document window, floating Format inspector, subtitle open

On branch feat/native-s2a-mac-window

S2a of the Docs native redesign (spec docs/superpowers/specs/2026-11-22-native-redesign-design.md §1, §6, §8, §9; plan S2a): the Mac document window. Running in parallel with S1a (perf/native-s1a) at Paul's request to see the new look sooner. Not for merging yet; no release, no deploy.

Header spike (plan S2a step 1): the custom title area ships, not the fallback

Run on the real document window (DocsWorkspace in a WindowGroup scene) by native/smoke/document-window with DOCS_SMOKE_SPIKE=1, macOS 27.0 (26A5388g). The contract: .navigationTitle(title) stays set, .toolbar(removing: .title) hides the system's, and Docs' title area is a ToolbarItem(placement: .navigation).

| # | Checklist item | Result | How | |---|---|---|---| | — | window title is the document title, system title hidden, no centred (.principal) item | PASS | window.title, titleVisibility == .hidden, toolbar.centeredItemIdentifiers empty | | 1 | drag the window by the title area | PASS (hit test), drag itself UNVERIFIED | the hit view at the title is SwiftUI's ToolbarItemHostingView with mouseDownCanMoveWindow == true, all the way up. A drag posted as events did not move the window: AppKit drags through the window server, which reads the real cursor, so that half needs a hand on a real Mac | | 2 | double-click the title renames; double-click empty toolbar still zooms | PASS / PASS | synthesised double-click: an editable field appears with the keyboard and Esc reverts it; double-click on empty toolbar zoomed the window (AppleActionOnDoubleClick = Maximize) | | 3 | narrow widths: title area kept, trailing controls go to » | PASS | toolbar visible items at 1120/760/560/420pt: at 420 the trailing item moves to overflow, the title item stays. The three controls are three items, so they overflow one at a time from the trailing end (Share…, then Format, then undo/redo) | | 4 | full screen | PASS | toggleFullScreen: .fullScreen set, the title item still visible, title unchanged | | 5 | window tabs show the document title | PASS | window.tab.title is the title | | 6 | VoiceOver: window name, then title, then subtitle | window name PASS; reading order UNVERIFIED | accessibilityTitle() is the title. In-process NSAccessibility gets no SwiftUI toolbar tree without a running assistive technology, so the title → subtitle order needs VoiceOver on a real Mac (it is on the §11 device pass) |

One finding the spike forced: SwiftUI FocusState does not reach into a toolbar item's hosting view. A TextField for rename appeared without the keyboard (first responder stayed the window) and never saw Esc. Today's .principal rename has the same shape. The title area now uses a small AppKit field that takes focus as it appears, commits on Return or focus loss and reverts on Esc. The spike checks all three.

No fallback was needed, so Rename is in place (double-click, File ▸ Rename ⇧⌘R, the title's context menu), not by sheet.

Window capture from the spike run: /tmp/s2a-spike-window.png on paul-mbp (title area, subtitle, undo/redo, Format, floating inspector).

More to follow on this thread: snapshots, tests, copy review, expected conflicts with S1a.

S2a status: rebased on main d5a328a, force-pushed at f20b4d2

The rebase onto d5a328a ("Docs' screens on the spacing scale") had no conflicts: main's change is web-only. Its rule now covers the new native chrome too. DocsSpacing mirrors Fiesta's --rst-sp-1…6 (4, 8, 12, 16, 24, 40pt), and two values stay off the scale, each saying why with spacing-allow:: the 1pt between title and subtitle, and the 2pt inset of the segmented well.

What's built (commits on the branch)

  • One title. .navigationTitle stays set and .toolbar(removing: .title) hides the system's. Docs' title area is the .navigation item: 15pt semibold title, with the §6 subtitle under it. The .principal item is deleted. Rename happens in place in a small AppKit field, because SwiftUI focus doesn't reach a toolbar item's hosting view (see the spike post above).
  • Subtitle. DocsSubtitleRow is one pure function covering every §6 row. The 1 s "Saving…" debounce runs in a .task, and the announcements follow the kit's rule plus rows 1 and 10 mid-session. The subtitle is its own view, so the body hosting the text view no longer reads syncStatus on the Mac.
  • Header controls. Undo/redo pill, the Format Toggle and Share… (today's sheet until S2b) are three toolbar items, so they overflow one at a time. Readers get none of them.
  • Floating Format inspector. 248pt glass panel with an accent rim, opaque under Reduce Transparency. It has Style, Text, Alignment and Lists, plus the second Lists row (§13 Q2). It is open by default, app-wide via docs.inspector.open, and never shown to a reader.
  • Page centring by translation. DocsDeskView is the scroll view's document view. The page is a fixed 612pt band placed by the web's clamp, so a toggle or a resize moves one frame origin and the text never reflows.
  • refreshAccess. - 403 and 404 give "No longer available", and a later 200 leaves it and calls retry(). - 401 pauses input and leaves can_write alone. retry() no longer resumes input under a 401; the re-minted session's stream opening does. - A 200 without can_write gives View only in place.
  • Callouts under the header. No longer available (Close, Discard), the errorKey callout, and Sign in for rows 5 and 6.
  • Menus. - View: Show/Hide Format ⌥⌘I, Paged/Infinite, Zoom. - Format: on the web's keys, with Headings 1–3. - Tools: Word count. Help: Keyboard shortcuts, then Colophon. - File: Open a document… ⌘K, a sheet that opens or focuses the result's window. Rename is absent for readers.
  • Strings. The §8 keys this slice uses are in all 12 languages. The Mac.strings keys this slice orphaned are deleted.

Tests

  • New: - DocsSubtitleTests: every row, its words, styles and announcements, and every key resolving in all 12 tables. - DocsAccessTests: 401, 403, 404, the later 200, and View only in place. - DocsDeskLayoutTests: the six widths × two zooms, open and closed, the 1,108pt boundary, and RTL. - DocumentWindowChromeTests (hosted, toolbar bridged): one title and no .principal, the page frame at the six widths open and closed, the app-wide state across two windows, a reader's window, and the debounce.
  • Each new test was seen red with its mechanism broken: 401 treated as 403, row 1 never left, the desk ignoring the inspector, the inspector shown to readers.
  • swift test: 192 tests, 0 failures (4 skipped as before). WorkspaceInitTests, SignedInLaunchTests and EditorRenderLoopTests are green.
  • test-document-window.py: all PASS. The smoke now toggles View ▸ Hide/Show Format and checks that the page slides while the editor's space stays put.
  • The iOS build of DocsKit is green, and the iPhone snapshot half passes.
  • From check-native: the interpolated-key grep is clean and sync-fonts matches. The cargo half was not rerun because S2a touches no Rust.
  • Hub CI: amadan ci status oficina/docs -branch feat/native-s2a-mac-window reports CI passed at f20b4d2 (exit 0).

Snapshots (snapshots.sh compare all, after the rebase and before the final recording)

  • Mac docs and docs-editor: pass, including the six 150% screens re-recorded in their own commit.
  • iPhone docs, docs-editor and docs-editor-ax3: pass.
  • Mac docs-window: 12 differ, all from this polish. They are re-recorded in their own commit (f20b4d2), and the commit message lists each.
  • The 150% re-record: the page is 1,224pt in a 1000pt window. Before, it sat 24pt in because of the old 636-unit minimum; the rule puts it at 16pt, so it moves 8pt left. Nothing reflows, and every 100% baseline is pixel-identical.
  • New docs-window baselines, light and dark: - Format open at 1280, closed, and open at 1000 (the page under the inspector) - reader - no longer available - ar and ru - every subtitle row in en, ar and ru
  • Published for Paul at https://pauls-macbook-pro-2.tail76ffb7.ts.net:10007/s2a/.
  • The header in these screens is the real title-area and controls views, laid out as the toolbar lays them out. The kit draws a borderless window, which has no toolbar. real-window.png there is the real window from the smoke run.
  • Under machine load (loadavg 700–1000 on 11-22) the gate reports "still changing" across the board, because the kit's 3 s settle limit can't be met. Recording needed a quiet window.

Copy review

New English: native.subtitle.{saved, viewOnly, unavailable, signedOut, joined}, native.unavailable.body, native.format.{show, hide}.

  • Status: not reviewed yet. The review page (hand-built preview, skill serve.sh) sat for 24 h without a submit and exited as abandoned. There was no result.json.
  • It is relaunched at http://100.101.233.54:54277.
  • Both fallback reviewers were unavailable today: Luna (Codex limit until 11-25) and Sonnet (weekly limit until 11-27).
  • The drafts are in all 12 catalogs. They must not land until a review result is applied.

Deviations and spec notes

  • SyncStatusAnnouncer. The kit export and re-pin (spec §1, "Kit dependency") is not done. Docs carries the rule itself, at row level, extended for rows 1 and 10 (DocsSubtitleRow.announces/sameKind). The export is a small rastrillo/native branch; then Docs re-pins and deletes its copy.
  • Row 13 (Loading) can't be reached in the table's order, because a loading document is .saved to the outbox. The code checks it before rows 10 and 11.
  • The desk is still windowBackgroundColor, which is white in light mode on macOS 27, so the page edge is invisible in light. The mock-ups' desk tint (#e3e7ee / #0e1015, spec D5) would change every editor baseline, so it's left for its own slice.
  • Inspector toggle and live resize cost. Both still re-evaluate the editor body, which renders the whole projection, because the body reads the inspector state. S1a's render isolation removes that cost. The page move itself is O(1).
  • Physical-Mac checks still to do (§11 device pass): - dragging the window by the title area (hit view is draggable; a posted drag can't prove it) - VoiceOver reading order, title then subtitle

Expected conflicts with S1a (perf/native-s1a, eef9b9c)

  • DocsWorkspace.editor (certain). S1a replaces NativeDocumentTextView(content:…) with DocumentEditorHost(surface:paged:zoom:) and EditorToolbar(model:). - S2a's .inspectorSide(...) must become an identity-level input of DocumentEditorHost. - The inspector overlay's content: goes away once DocumentCommands reads the live storage. - S1a's requestJump() (opens home on the Mac) gives way to S2a's sheet. - The init gains both connectivity: and team:.
  • NativeDocumentTextView. makeNSView/updateNSView wrap the text view in DocsDeskView (3 lines). S1a moves the representable.
  • DocsModel. refreshAccess, the retry() guard, and listen's onOpen (sessionReopened).
  • DocsFormatInspector / DocsUndoRedoPill. These use DocumentCommands(model:content:), DocumentToolbarSelection(commands:) and projection?.canUndo. They should move to S1a's single observed DocumentToolbarSelection.
  • DocsEditorContext / DocsToolsControls. S2a added bindings and extracted the sheets; S1a changes how they read content.
  • S1b. DocsPagedTextView.viewportWidth is now the fixed paper band, which S1b's full path assumes.

Whole-branch review of S2a at f20b4d2 — Claude Fable (claude-fable-5-2)

Verdict: APPROVE AFTER FIXES. Findings 1–3 before landing; the rest can follow.

Read as one diff, d5a328a..f20b4d2, against spec §1, §6, §8–§11 and the screenshots in polish-audit/docs-native/s2a/. I did not run swift test; I relied on hub CI, which reports passed at f20b4d2. Window drag, VoiceOver reading order and IME in the rename field can't be judged from the code and stay on the device pass.

Findings

  1. Blocker to land (process): copy review is not applied. The eight new English strings (native.subtitle.*, native.unavailable.body, native.format.show/hide) are in all 12 catalogs as drafts. The coordinator's ruling says they go through copy review before the slice lands.
  1. Medium: a failed commit on focus loss jams the rename field. DocsDocumentHeader.swift:275-279. - controlTextDidEndEditing sets done = true before commit(). If commitRename() returns false, the field stays up with done latched. - It returns false for a title over 1,024 bytes, for a failed metadata save, and when write access was lost mid-rename. - After that, clicking back in, fixing the title and clicking away never commits. Only Return does. - Fix: latch done only on success or cancel, or reset it in controlTextDidBeginEditing. Also drop out of rename when access leaves .writable; today a reader can be left with an editable title field.
  1. Medium: the 401 resume un-pauses input it did not pause. DocsModel.swift:699-702 and 705-707. - A 401 sets pausedForSession even when inputPaused was already true for another reason. - The later 200 clears inputPaused if localFailure == nil and nothing is held. That misses the native.recovered pause (drainEdits, line 364), which waits for Try again with the failed command at the head of the queue. - Scenario: a replica command fails, then the session expires and is re-minted. Input resumes on its own, with the callout still showing. - Fix: record whether the 401 was what paused, and resume only then. Add that case to DocsAccessTests.
  1. Medium-low: callouts overlap the inspector below about 1,136pt. DocsDocumentHeader.swift:220, and the .overlay(alignment: .top) in DocsWorkspace.editor. - The callout is up to 560pt wide, centred, and drawn above the inspector. - At 1,000pt it covers x 220–780; the inspector starts at 740. So the sign-in callout (rows 5 and 6) or the errorKey callout sits over the inspector's leading 40pt, with its buttons at that end. - No snapshot shows it: the only callout screen is No longer available, which has no inspector. - Fix: centre the callout in the same band as the page (the leading edge to W − E), and add a narrow-with-callout screen.
  1. Low: the style pop-up shows a stale value on Heading 4–6. DocsFormatInspector.swift:182. selection.style can be heading4…heading6 (DocumentToolbarSelection.swift:30). No entry matches, so the pop-up keeps whatever it last showed. Show no selection, or a disabled item for the level.
  1. Low: segmented buttons are 24pt tall. DocsFormatInspector.swift:216, 230-231. The well is 28pt with a 2pt inset; §1 says 28pt buttons and §9 says targets of at least 28pt. Either extend the hit area to the well's height or record the deviation.
  1. Low: sections are 16pt apart, the spec says 14. DocsFormatInspector.swift:33. Fine under the spacing-scale rule, but it should be listed with the other deviations.
  1. Low: DocsModel.access shares a name with Observation's access(keyPath:). DocsModel.swift:23. It compiles, but S1a calls access(keyPath:) by hand in the same type, right beside it. Rename to something like documentAccess before the merge.
  1. Low: the team name is set only when the home window appears. DocsAccountWindow.swift:174-176, 310. A document window restored before the home window, or a team renamed later, shows the state alone or a stale name. transports has the same dependency, so this is no worse than today.
  1. Low: the rename field has no accessibility label. DocsDocumentHeader.swift:259. VoiceOver gets a bare text field. Label it with docs.document.rename.
  1. Question: Close on the No longer available callout. DocsWorkspace.editor passes dismissWindow(). I did not confirm whether that goes through DocsCloseGuard.windowShouldClose. If it does, a document with unsent changes gets the Save / Cancel / Discard sheet, where Save can't succeed. If it doesn't, the window closes with entries held and no prompt. Either may be intended; a smoke assertion would settle it.
  1. Question: Print… ⌘P. §1's File menu lists it; CommandGroup(replacing: .printItem) {} still removes it (unchanged from main). Say which slice owns it.

What I checked and found sound

  • One title. .navigationTitle stays set, .toolbar(removing: .title), the .navigation item, and .principal is gone on the Mac.
  • Subtitle. DocsSubtitleRow.init matches §6's precedence, including view only, no longer available and signed out. The screenshots show all twelve rows in en, ar and ru.
  • Header controls. Order and visibility per §1; a reader gets none; a draft has no Share….
  • Inspector. Open by default, one @AppStorage key for the toggle and ⌥⌘I, never shown to or written by a reader, opaque under Reduce Transparency, on the left in Arabic.
  • Menus. View, Format, Tools and Help follow the table, on the web's keys. Rename is absent for readers. ⌘K opens the sheet and a result opens or focuses its own window.
  • No observed-state mutation in init or body. - DocsWorkspace.init only stores team. - The debounce is a .task; the announcement and shown are set in .onChange. - teamNames is written in .onAppear. - The Mac editor body no longer reads syncStatus.
  • Never FOUT. The pop-ups use DocsFonts faces that are already registered.
  • Offline and outbox. enqueue, drainEdits and the drainer are untouched. The model change is confined to refreshAccess, the retry() guard and onOpen.
  • Account menu. Not touched.
  • Rename field otherwise. Focus is taken in viewDidMoveToWindow; Return commits; Esc reverts. A second commit after the field is removed is stopped by guard renaming. ⌘Z stays with the field editor, because the document's undo is the text view's own responder method. Rename works offline, through the outbox.
  • Strings. All 12 Localizable.strings carry the same 18 new keys. No docsMacString call points at a deleted key, and every deleted Mac.strings key has no reader. Keys built from parts are built as Strings.
  • Baselines. - Outside docs-window, only the six Mac 150% editor PNGs changed. - I compared two of them with main's: the new image is the old one moved exactly 8px left, with no other pixel different. That matches the rule (old 636-unit minimum gave 24pt; the rule gives 16pt). - The 20 docs-window PNGs are new files.

Deviations

  • Own announcer copy: acceptable for now. The rule is small and unit-tested. Open the rastrillo export so the copy has an end date.
  • Loading before rows 10 and 11: correct. The spec's order is unreachable; amend the table.
  • Light-mode desk still white: acceptable as its own slice. It is why the narrow light screen shows no page edge under the inspector.
  • Inspector toggle re-renders the editor until S1a: acceptable. The page move itself is one frame origin.

Merge with S1a (trial merge of eef9b9c into f20b4d2, in a throwaway worktree, aborted)

  • Five files conflict, all where the write-up said: - DocsModel.swift: 3 hunks - DocsWorkspace.swift: 3 - NativeDocumentTextView.swift: 3 - DocsToolsControls.swift: 1 - EditorSnapshots.swift: 2
  • The structure is merge-friendly. The new chrome is in new files, and the desk touches the representable in three lines.
  • One hazard that will not show as a conflict. S1a makes DocsModel.projection @ObservationIgnored. These S2a readers would compile and silently stop updating: - DocsUndoRedoPill (DocsDocumentHeader.swift:119-123): undo and redo would never enable. - Tools ▸ Word count's .disabled(editor?.model.projection == nil) in DocsEditorCommands. - The word-count sheet in DocsWorkspace.
  • No S2a test covers the pill's enabled state. Add a hosted test now (type, then the undo button is enabled) so the merge goes red instead of shipping a dead pill.
  • Baseline order. Whichever of S1a and S2a lands second must compare against the six re-recorded 150% screens, not main's old ones.

Fixes for Fable's review (f20b4d2 → ce2b004)

One commit per finding. Hub CI passes at ce2b004.

| # | Fix | Commit | |---|---|---| | 1 | Copy review: still waiting on Paul at http://100.101.233.54:54277. Not restarted; no result.json yet. Applied when it lands. | — | | 2 | DocsRenameSession only finishes on an accepted commit or a revert. A refused Return keeps the field open with the error showing, and the next Return or focus loss tries again. A refused focus loss puts the title back. Readers never get the field (showsField), and losing write access mid-rename reverts it. Tests: DocsRenameTests covers each path, a title over 1,024 bytes, and losing write access; the latch-first mutation turns it red. | d92bb2c | | 3 | A 401 sets sessionPaused, its own reason alongside inputPaused. enqueue, DocumentCommands and editability read inputBlocked, and the later 200 clears only sessionPaused. Test: testThe401ResumeLeavesAnotherPauseAlone, red with the old clearing. | 98e737d | | 4 | Callouts are centred in the desk beside the inspector: 16pt in from the leading edge, 276pt from the trailing edge while it shows. New snapshot: window-callout-narrow at 1000pt. | 4th fix commit | | 5 | When the selection is in Heading 4–6, the style pop-up shows that level ("Heading %d" from the catalog, in each language). Headings 4–6 are still not offered. Test: DocsInspectorStyleTests. | — | | 6 | The joined buttons are 28pt, in a 32pt well. | 6de1e54 | | 7 | Section spacing is 16pt, not 14. Recorded as a deviation in spec §1, citing the spacing rule. | 960616c | | 8 | DocsModel.access is renamed documentAccess. | 12780cb | | 9 | Each document window asks the Oficina ID session for its account's team every time it draws: the signed-in team, or another team of the identity from the teams cache. Server-account names stay current when the account list changes. Test: in SignedInLaunchTests. | d12bdde | | 10 | The rename field has an accessibility label, "Rename document". | d92bb2c | | 11 | Close on the "No longer available" callout used SwiftUI's dismiss, which skipped DocsCloseGuard. It now uses performClose on its own window. Test: DocsWindowCloserTests — with changes unsent the window stays and the guard's sheet appears (red with close()); with nothing unsent the window closes. | cc7ca0b | | 12 | Print… ⌘P is left for S2b, per your ruling. | — | | Merge hazard | DocsModel now derives two observed values from every projection it holds, each assigned only when it changes: history (loaded, canUndo, canRedo) and contentRevision. The undo/redo pill, Word count's enabled state and the live word-count sheet read those instead of the projection. Test: DocsHistoryObservationTests pins each one through withObservationTracking after an edit or on open. With the projection unobserved and the old readers, the pill and sheet tests go red. If S1a stops assigning the projection, all three go red. | 1e1e53e |

Tests. Full swift test: 204 tests. The only failure was the timing-sensitive RealtimeSyncTests.testADiscardDuringTheThrottleIsNotSent under load; it passes alone three times and with its suite.

Snapshots. snapshots.sh compare all after the fixes:

  • Mac docs and docs-editor: green.
  • iPhone half: green.
  • docs-window: 8 screens changed (the 28pt buttons) and 2 are new (the callout). These are re-recorded in their own commit, ce2b004.

Published. https://pauls-macbook-pro-2.tail76ffb7.ts.net:10007/s2a/ is refreshed, with the new callout screen.

Conflicts with S1a. The earlier list still holds, plus:

  • inputBlocked and sessionPaused touch enqueue, DocumentCommands.isAvailable and the editability flag.
  • projection gains a didSet that feeds history and contentRevision. If S1a's surface publishes without assigning projection, it must set those two itself; the new tests will go red until it does.

Correction to the table above: finding 4 is b1272b8 and finding 5 is a003328.

Landed on main (squash). Paul ruled "Ship it!" (2026-11-24): the eight new strings ship as drafted and the copy review follows as a task. S1a now rebases onto this.