fix(microblog): publish sheet opens unfocused

Since the categories field landed, the Micro.blog publish sheet
opened with that field focused and its completion menu popping. A
sheet window takes its initial first responder like any window — its
first text input — and textInputSuggestions shows its list when the
editing interface is activated, so the menu popped the moment the
sheet opened.

The sheet now rides the launch-focus-reset rider from r8, once per
window: it resigns the auto-focus at the sheet's first become-key,
and a later re-key keeps whatever the writer focused. The rider is
InitialFocusReset(scope:) in the shared chrome; the library column
mounts the once-per-process scope exactly as before. The SwiftUI door
is closed: defaultFocus with false or nil changes nothing for this
assignment on macOS 27.2.1.

Verified with a bundle-launched OS-behaviour probe kept under
prototypes/ (re-run it after every macOS point release): the three
non-fix variants reproduce the auto-focus and the suggestions
window, the rider variant never shows either, and a run whose sheet
never became key exits 2 instead of printing the green verdict.
Owner live check passed.

Reviewed (three-reviewer finish-audit): the probe's false-green
verdict, a snippet missing its scope label, and duplicated mechanism
comments were found and fixed before this commit. Rail 814/814;
SwiftFormat and SwiftLint clean.

Docs: Museion/AGENTS.md bullets, an AGENTS.md learning, CHANGELOG
[Unreleased], the devlog, and the swift wiki (a sheet hands its
initial focus to its first text input).

Unticketed follow-up to the Micro.blog categories work; owner
report 2026-12-05.
This commit is contained in:
AlexKucera committed 2026-12-05 14:59:16 +01:00
1 parent 36393a9e8e
commit eca90a981c
9 files changed
+438 -64

No files matched your search

+7
View File
@@ -34,6 +34,11 @@
// discipline as Categories: the edit lands AT THE SEND, the field
// syncs on open/forget and settles from disk after a send. While the
// turn runs the button is the sheet's own Stop (the sheet is modal).
// #207 follow-up: the sheet opens with NOTHING focused — a sheet window
// takes its initial first responder like any window (the Categories field,
// so the completion menu popped on open). `InitialFocusReset`
// (WorkspaceChrome) resigns it at the sheet's first become-key; the
// mechanism and its probe are documented there.
//
import SwiftUI
@@ -335,6 +340,8 @@ struct MicropubPublishSheet: View {
}
.padding(16)
.frame(width: 420, alignment: .leading)
// Opens unfocused — InitialFocusReset's doc has the mechanism.
.background(InitialFocusReset(scope: .oncePerWindow))
.onAppear {
// A piece sent in an earlier session still has its record:
// the remembered URL, and (#206) its publish stamp.