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:
1 parent
36393a9e8e
commit
eca90a981c
9 files changed
+438
-64
No files matched your search
+3
-3
@@ -26,9 +26,9 @@ The map and the contracts, one bullet per file. Pin-level detail lives in the te
|
||||
- `WorkspaceView.swift` — first-frame main surface, rendered unconditionally (gateless: the engine check runs async beside it). Nav rail Posts / Sessions / Learnings / Trends / Archive + engine-status pill + Settings. Column collapse mirrors the export's media queries as pane collapse — library hides < 1100 px, mentor < 920 px; never a fixed four-column minWidth. Window-level `.dropDestination`: the drop surface for drags that land OUTSIDE the editor — macOS 27.2.1 routes a drag to the DEEPEST destination, so over the editor the text view takes the drag itself (`FileDropTextView`'s drag handlers) and this destination never fires (the inverse of the 27.0.1 ruling #141 was verified on); both route through `AppGateState.routeFileDrop` — the ONE file-drop router (pure-markdown → external guest, anything else → `ingestDrop`, Cold Turkey–guarded; a mixed md+image set and web URLs refuse loudly). A landed drop hops to Posts (unreachable for images today — the editor mounts only there). The house ask sheets present here (pending-state + binding pattern; the sheet structs live in `WorkspaceViewSheets.swift`, #193). #193 splits: `ArchivePaneView` → `ArchivePaneView.swift`, shared chrome (`SelectedRowStrip`/`BorderedSecondaryButtonStyle`/`PaneHeader`) → `WorkspaceChrome.swift`; `RailButton` stays here (the rail is its only caller).
|
||||
- `ArchivePaneView.swift` — #193: the #108 Archive pane (moved from WorkspaceView.swift) — archive/ as a rail destination, List-only: clicking a piece selects it and hops to Posts (where the editor column lives); reuses `LibraryPostRow`. Row menu: Move Back / Rename / Convert, plus #205 Reveal in Finder / Copy Path and #206 Open on Micro.blog.
|
||||
- `WorkspaceViewSheets.swift` — #193: the house ask sheets (moved from WorkspaceView.swift) — `OriginAskSheet` (the ONE origin ask per import batch, #94), `OutlineGuardSheet` (#111 mixed-content), `ConvertSheet` (#114), `NewProjectSheet` (#108).
|
||||
- `WorkspaceChrome.swift` — #193: the shared chrome (moved from WorkspaceView.swift) — `SelectedRowStrip` (the selected-row capsule), `BorderedSecondaryButtonStyle` (the bordered secondary button), `PaneHeader` (the 52pt pane-head row); every pane reuses them. #205 `FinderHandOffButtons` — the ONE Reveal in Finder / Copy Path fragment every piece-listing row menu mounts directly (library column, Archive pane); both act on `model.fileURL(for:)`, a nil URL no-ops. #206 `MicroblogHandOffButton` — Open on Micro.blog, only for a PUBLISHED piece (a draft's final URL answers Not Found until the post is published — owner-verified 2026-12-04); mounted beside the Finder pair in both menus.
|
||||
- `WorkspaceChrome.swift` — #193: the shared chrome (moved from WorkspaceView.swift) — `SelectedRowStrip` (the selected-row capsule), `BorderedSecondaryButtonStyle` (the bordered secondary button), `PaneHeader` (the 52pt pane-head row); every pane reuses them. #205 `FinderHandOffButtons` — the ONE Reveal in Finder / Copy Path fragment every piece-listing row menu mounts directly (library column, Archive pane); both act on `model.fileURL(for:)`, a nil URL no-ops. #206 `MicroblogHandOffButton` — Open on Micro.blog, only for a PUBLISHED piece (a draft's final URL answers Not Found until the post is published — owner-verified 2026-12-04); mounted beside the Finder pair in both menus. `InitialFocusReset` (r8, moved here in the #207 follow-up once the publish sheet needed it) — the ONE window-focus rider: at the window's FIRST become-key it resigns AppKit's initial first responder (the first text input) back to the window; `.oncePerProcess` = the library column's launch reset, `.oncePerWindow` = the publish sheet.
|
||||
- `PostsPaneView.swift` — Posts destination (#193: the library column and the row live in their own files): editor column, mentor column (fixed 356). Editor column renders the external guest ahead of the post session (one guest at a time). Focused branch mounts the Cold Turkey chrome as overlays; lock transitions never restructure the editor column.
|
||||
- `PostsLibraryColumn.swift` — #193: the library column (moved from PostsPaneView.swift), shared by the unfocused layout and the focus-mode left reveal — one implementation, both surfaces. Project section heads + Pass-State groups, collapse toggle per-view; owns the rename + move sheets (`RenamePostSheet`, `MoveToProjectSheet`) and the row context menu (#205: the shared hand-off fragment — #206 `MicroblogHandOffButton`, then #205 `FinderHandOffButtons` — between Move to Archive and Trash). Library search: debounced, title+body over non-archived pieces through the file-scope `librarySearch` mount, body scan off-main through `readBody` (frontmatter never searched). `LaunchFocusReset` (r8) rides the column: the window's first become-key resigns focus back to the window, once per process.
|
||||
- `PostsLibraryColumn.swift` — #193: the library column (moved from PostsPaneView.swift), shared by the unfocused layout and the focus-mode left reveal — one implementation, both surfaces. Project section heads + Pass-State groups, collapse toggle per-view; owns the rename + move sheets (`RenamePostSheet`, `MoveToProjectSheet`) and the row context menu (#205: the shared hand-off fragment — #206 `MicroblogHandOffButton`, then #205 `FinderHandOffButtons` — between Move to Archive and Trash). Library search: debounced, title+body over non-archived pieces through the file-scope `librarySearch` mount, body scan off-main through `readBody` (frontmatter never searched). `InitialFocusReset(scope: .oncePerProcess)` (r8 — the rider itself lives in `WorkspaceChrome.swift`) rides the column: the window's first become-key resigns focus back to the window, once per process.
|
||||
- `LibraryPostRow.swift` — #193: the post row (moved from PostsPaneView.swift) — 2px leading strip, ✳ on outline pieces, row menu Rename/Convert/Move to Project/Move to Archive/Reveal in Finder/Copy Path/Open on Micro.blog (#206, published pieces)/Trash (the menu is attached by the callers — `PostsLibraryColumn.swift`, `ArchivePaneView.swift`); the Archive pane reuses it. #206: the mono-11 micro-label shows the piece's Micro.blog status when it has one (`published <date>` / `draft on Micro.blog`) in origin's place — 178pt of row content cannot carry both — and VoiceOver reads both (`accessibilityText`); origin stays one hover away (the label's tooltip).
|
||||
- `PostLibrary.swift` — `Post` + `Post.scan`: two-level scan over `projects/<name>/<id>/post.md` AND `archive/<name>/<id>/post.md` (ADR-0012), skip guards at both levels (lazy folders, loose files, hidden dirs, symlinked dirs); frontmatter keys read leniently (First Draft/writer/post defaults); title = first non-empty body line, `untitled` fallbacks; runs off-main. `stats_*` keys load only if EVERY value parses finite (a non-finite peak would trap the chart y-domain); read-back re-gates on the named immutable pair (`PostFrontmatter.isUnaidedFirstDraftPair` — origin writer, type post; never pass_state, which legitimately advances). `scan(home:cache:)` takes a `PostScanCache` (path+mtime+size memo; the stamp is taken BEFORE the read, so a mid-scan rewrite can never pin as fresh). `micropubURL` through the ONE trust gate (`Micropub.rememberedURL`, format-only — ownership is settled upstream: the import boundary drops the key, so only Museion or the writer's own hand writes one); #206 `micropubPublished` (frontmatter `micropub_published`, the `stats_captured` stamp shape, read by the shared `parseStamp`) and the row label `micropubStatus` (`published <date>` / `draft on Micro.blog` / nil).
|
||||
- `PostFrontmatter.swift` — #180: the Post frontmatter codec — the ONE lenient read (`parse`/`split`/`decoded`), `stampFormat` (the frontmatter timestamp shape both stamp writers and the reader share), and the three write postures behind one known-key table (`ownedKeys`: type, pass_state, origin — one insertion-order rule): fresh stamp (`stamped`), merge-import (`mergingImport` — external keys verbatim, ours win, and the Micro.blog bookkeeping dropped: `micropubKeys` — #206, a foreign file carries no post of this library), update-keys (`updating` — the in-place line-walk, every other line byte-identical; `dropping:` removes named keys' lines — the import and the 404 forget). Absorbed and deleted `PostStore.stamped/splitFrontmatter/mergedFrontmatter` and `LearningDecay.stampingFrontmatter` byte-identically (merge-import's documented prefix-preservation divergence excepted). Owns the two named eligibility predicates both gates consume: `isUnaidedFirstDraftPair` (writer ∧ post — the scan's read-back gate) and `isCaptureEligible` (pair ∧ First Draft — the capture gate). Learning/Fix Card documents stay out of scope; the learnings dismiss stamp rides the generic update posture. #207 the one-line `category:` list codec: `categories(in:)` reads the line (bracketed list, a bare scalar = ONE category, empty/absent = none) and `categoryValue(_:)` renders it — both over the unbracketed `categoryList`/`categoryListValue` and the one segment scanner `categorySegments` the publish sheet's field also speaks (ONE quote-aware comma-list parser: commas outside double quotes split, one pair of quotes stripped, `\\` and `\"` escaped on render and unescaped on read, empties dropped, first occurrence wins; newlines/control characters never reach the line-bounded sink). #208 the one-line `summary:` scalar: `summaryValue(_:)` renders it (every run of whitespace — a newline included — collapses to one space, control characters drop; a value holding a quote or backslash renders QUOTED with both escaped — the category codec's own escape, ONE grammar for both keys) and `summary(inText:)` reads it back off the RAW line, never through `parse`: the lenient decode trims EVERY edge quote, so a teaser's closing `"why"` would vanish through that door — the wire (`updateRememberedOrCreate`, `openPieceSummary`) and the sheet's settle all read the raw line. The read walks the block the way `parse` does (past the opening fence to the next `---`) — NOT via `split`, whose closing-fence check a mixed-ending file defeats (a stray `\r` fuses `---` onto the last block line: `parse` sees the key, `split` sees no block) — and cuts a fused `\r\n---` tail off the value; a BODY line named `summary:` never claims the key (no fence, no block). Empty/blank/absent = `""` — the field's settled empty.
|
||||
@@ -41,7 +41,7 @@ The map and the contracts, one bullet per file. Pin-level detail lives in the te
|
||||
- `Pass.swift` — `PassKind` (pass1/pass2 — the app's own names) + `PassContext.stub` (the pinned minimal engine prompt: verdict in the reply, findings as fix-card tool calls, research as candidate tool calls — the engine never writes to the piece folder) + `estimateTokens` (chars/4).
|
||||
- `BlindRead.swift` — neutral "Version A/B" prompt (both bodies inline, origin-free words never appear — the judge must not know which is the rewrite; caller randomizes order), ask = pick + one line why; `reveal` mapping appended by the model ONLY after the turn ends.
|
||||
- `SummaryPrompt.swift` — #208: the AI post summary's prompt vocabulary (pure) — `prompt(title:body:)` carries the Title and body inline and asks for a first-person teaser that entices the reader to read the full piece; `cleaned(_:)` is the reply as the field's text (trimmed, ONE leading `Summary:` label dropped — colon required, so prose opening with the word keeps it; one pair of surrounding quotes stripped; then the codec's round-trip — `summaryValue` → the raw-line read — so the FIELD shows exactly the text the wire will carry, one line, no escapes). The model half is `PostsModelMicropubSummary.swift`; the summary's HOME is the frontmatter `summary:` line the SEND stamps — this half only drafts text for the publish sheet's field.
|
||||
- Micropub (`Micropub.swift`, `MicropubMedia.swift`, `MicropubCategories.swift`, `MicropubPublishSheet.swift`) — the Micro.blog publish path. Client over the injectable Transport: draft = h=entry (name, markdown content verbatim, post-status draft, sorted keys; #207 the piece's `category:` list travels — a create carries `category` ONLY when non-empty, and naming a category Micro.blog doesn't know CREATES it there (no separate create call); #208 the piece's `summary:` line travels the same way — a create carries `properties.summary` ONLY when non-empty, a re-send carries `summary` in `replace` only when the piece has the line (opt-in by key, `""` is sent and CLEARS the post's summary); NO `photo` property — uploaded illustrations ride INLINE in content, refs rewritten to uploaded URLs on the WIRE only, the piece on disk never changes). Every URL through `trustworthyURL` (https + host + no line/control characters — the URL is trust-boundary data landing in frontmatter; #206 the remembered URL is also an OWNERSHIP question the format gate cannot answer — the import boundary drops both micropub keys (`PostFrontmatter.micropubKeys`), so a foreign file never aims a send at one of the writer's posts); 401/403 → authFailed with `error_description`; a 5xx over Micro.blog's HTML error page names their outage (`unavailable on their side — retry in a few minutes`), never a bare `HTTP 503` — ONE decode (`decodeFailure`), every step; `preview` is display-only, never the publish target. `MicropubTokenStore` = the app's own login-keychain credential (ADR-0014's no-Keychain rule covers only provider keys) — entered in the sheet on first use, managed from Settings → Micro.blog (saved status, replace, remove; the page reads the slot back after every write — a locked keychain fails visibly, never a false "stored"; the status is a standing `✓ Token saved in your Keychain` row in the Settings verdict idiom, not an intro-line swap). Media: `illustrations(in:)` parses only `` refs (remote refs ride as prose; multi-line alts don't parse at all — by design); parse + rewrite share ONE regex; markdown-active URLs ride the angle form; `queryRequest(_:token:)` is the one `GET <endpoint>?q=…` builder (config + the category list). Categories: `blogCategories(token:)` (`q=category`, `MicropubCategories.swift`) = the blog's own category names for the sheet's suggestions — the root `categories` strings, else `microblog-categories`'s `name` fields, trimmed, empties dropped; any failure or non-2xx is `[]` (no suggestions is not an error — the sheet stays silent, and a rejected token surfaces on the send itself). The sheet's Categories field (`MicropubPublishSheet.swift`) is a comma list in the codec's unbracketed form with the system completion menu over `blogCategories` (fetched on open; a failed fetch is silent — a typed new name creates the category at the send); the system REPLACES the whole field text with a completion, so `MicropubCategoryField.completion` IS the merge — a pick ADDS, a half-typed last word is replaced, a present name is never offered; the edit lands at the send via `micropubSend(categories:)` (Publish applies it first and flips the post that send touched — never the sheet's possibly-stale URL); the field syncs from disk over `openPieceCategories()` (the model's read of the open piece — never the scan snapshot) on open and after a forget, settles to the canonical text after a successful send, and after a failed step only its BASELINE re-syncs (the send writes the line before the wire, so a later clear of the field must still count as an edit). #208 the sheet's Summary field — the same discipline over the one-line `summary:` scalar: a multi-line `TextEditor` with an `AI summary` button (a bordered small control in the label row) that runs `posts.summarize(mentor:)` — the sheet holds `let mentor: MentorSessionModel` (PostsPaneView passes its own; the ONE construction site) and the reply fills the field for the writer to edit; the button and the field hold still while the turn runs; the button is ALSO disabled while a Pass or Blind Read owns the one-shot rail, with the hover reason saying so (the pass bar's disabled-with-reason idiom — the guard behind it is `guardOpenPieceRun`), and a refusal shows inline with the field's text kept. The sheet is MODAL — the pass bar's Cancel sits behind it — so while this sheet's own summary turn runs the AI button IS the Stop (the spinner stays clickable, `cancelPass` ends the turn on the shared rail); `summarizing` is the MODEL's flag (`PostsModel.summarizing`, the third rider beside `runningPass`/`runningBlindRead`), read by the sheet, the pass bar's Cancel visibility, and `cancelPass`/`guardOpenPieceRun` through the ONE `oneShotRailBusy` predicate — a fourth rider joins the predicate and every site follows. The edit-for-send test is `MicropubSummaryField.pendingSummary` — a STRING compare on trimmed text, so whiLine truncated
|
||||
- Micropub (`Micropub.swift`, `MicropubMedia.swift`, `MicropubCategories.swift`, `MicropubPublishSheet.swift`) — the Micro.blog publish path. Client over the injectable Transport: draft = h=entry (name, markdown content verbatim, post-status draft, sorted keys; #207 the piece's `category:` list travels — a create carries `category` ONLY when non-empty, and naming a category Micro.blog doesn't know CREATES it there (no separate create call); #208 the piece's `summary:` line travels the same way — a create carries `properties.summary` ONLY when non-empty, a re-send carries `summary` in `replace` only when the piece has the line (opt-in by key, `""` is sent and CLEARS the post's summary); NO `photo` property — uploaded illustrations ride INLINE in content, refs rewritten to uploaded URLs on the WIRE only, the piece on disk never changes). Every URL through `trustworthyURL` (https + host + no line/control characters — the URL is trust-boundary data landing in frontmatter; #206 the remembered URL is also an OWNERSHIP question the format gate cannot answer — the import boundary drops both micropub keys (`PostFrontmatter.micropubKeys`), so a foreign file never aims a send at one of the writer's posts); 401/403 → authFailed with `error_description`; a 5xx over Micro.blog's HTML error page names their outage (`unavailable on their side — retry in a few minutes`), never a bare `HTTP 503` — ONE decode (`decodeFailure`), every step; `preview` is display-only, never the publish target. `MicropubTokenStore` = the app's own login-keychain credential (ADR-0014's no-Keychain rule covers only provider keys) — entered in the sheet on first use, managed from Settings → Micro.blog (saved status, replace, remove; the page reads the slot back after every write — a locked keychain fails visibly, never a false "stored"; the status is a standing `✓ Token saved in your Keychain` row in the Settings verdict idiom, not an intro-line swap). Media: `illustrations(in:)` parses only `` refs (remote refs ride as prose; multi-line alts don't parse at all — by design); parse + rewrite share ONE regex; markdown-active URLs ride the angle form; `queryRequest(_:token:)` is the one `GET <endpoint>?q=…` builder (config + the category list). Categories: `blogCategories(token:)` (`q=category`, `MicropubCategories.swift`) = the blog's own category names for the sheet's suggestions — the root `categories` strings, else `microblog-categories`'s `name` fields, trimmed, empties dropped; any failure or non-2xx is `[]` (no suggestions is not an error — the sheet stays silent, and a rejected token surfaces on the send itself). The sheet's Categories field (`MicropubPublishSheet.swift`) is a comma list in the codec's unbracketed form with the system completion menu over `blogCategories` (fetched on open; a failed fetch is silent — a typed new name creates the category at the send); the sheet opens with NOTHING focused — a sheet window takes its initial first responder like any window (its first text input, the Categories field — the completion menu popped on open), and `InitialFocusReset(scope: .oncePerWindow)` resigns it at the sheet's first become-key (`.defaultFocus(…, false)` does not; macOS 27.2.1, `prototypes/MicropubSheetFocusProbe.swift`); the system REPLACES the whole field text with a completion, so `MicropubCategoryField.completion` IS the merge — a pick ADDS, a half-typed last word is replaced, a present name is never offered; the edit lands at the send via `micropubSend(categories:)` (Publish applies it first and flips the post that send touched — never the sheet's possibly-stale URL); the field syncs from disk over `openPieceCategories()` (the model's read of the open piece — never the scan snapshot) on open and after a forget, settles to the canonical text after a successful send, and after a failed step only its BASELINE re-syncs (the send writes the line before the wire, so a later clear of the field must still count as an edit). #208 the sheet's Summary field — the same discipline over the one-line `summary:` scalar: a multi-line `TextEditor` with an `AI summary` button (a bordered small control in the label row) that runs `posts.summarize(mentor:)` — the sheet holds `let mentor: MentorSessionModel` (PostsPaneView passes its own; the ONE construction site) and the reply fills the field for the writer to edit; the button and the field hold still while the turn runs; the button is ALSO disabled while a Pass or Blind Read owns the one-shot rail, with the hover reason saying so (the pass bar's disabled-with-reason idiom — the guard behind it is `guardOpenPieceRun`), and a refusal shows inline with the field's text kept. The sheet is MODAL — the pass bar's Cancel sits behind it — so while this sheet's own summary turn runs the AI button IS the Stop (the spinner stays clickable, `cancelPass` ends the turn on the shared rail); `summarizing` is the MODEL's flag (`PostsModeLine truncated
|
||||
- `PostsModelMicropubSummary.swift` — #208: the AI summary's model half — `summarize(mentor:)`: the shared open-piece guard rail (`guardOpenPieceRun`, the brief-28 Home identity) → flush-first → ONE disk read feeds the prompt → `mentor.runSummary` on a fresh one-shot chat-profile engine → `SummaryPrompt.cleaned`. Returns the text or nil with `lastError` naming the blocker; a stale guard refusal never survives into the strip (`lastError` cleared once the guards pass). Writes NOTHING — the text is the publish sheet's to place, and the SEND stamps the `summary:` line.
|
||||
- `PostsModel.swift` — @MainActor @Observable, app-scoped. Domain extensions live in their own files (guard+Convert `PostsModelOutline.swift`, passes+Blind Read `PostsModelPasses.swift`, fix cards `PostsModelCards.swift`, write rail+structural ops `PostsModelWrites.swift`, external guest+imports `PostsModelImports.swift`, watcher+rescan `PostsModelWatcher.swift` (home of `PostsWatcher`), (Home, ID) identity `PostsModelIdentity.swift` — `openSessionTargets` + #205 `fileURL(for:)`, the row menus' post.md path, a pure read) — the #146/#193 splits. **#179 write rail**: every library store write (draft save, session-born post, rename, move to project, archive/restore, trash, convert, project creation, import batch, pass advance) rides `performWrite` — ONE seam pairing the write with exactly one rescan and owning the error strip (cleared BEFORE the write, so importFiles' mid-closure per-file failures survive; a nil-Home refusal writes nothing); the MODEL owns the Home (`watchedHome` — written only by the watcher extension's `startWatching` behind `bind`, driven by WorkspaceView's root `.task(id: museionHome)` (first frame + every repoint, whichever pane is showing); no public method takes a Home parameter); the editor's debounced flush and the micropub publish stay OUTSIDE the rail (own error semantics). `PostDraft` in-memory until first save; `mountID` keys the editor `.id` so every staging REMOUNTS (the outliner re-seeds its tree). Mixed-outline guard: a lossy outline select HOLDS the ask over an empty editor (nothing can normalize on ⌘S before the choice); reselect of the held piece is a no-op. Convert: consent rechecked at answer time (Headings aborts when the body went lossy behind the ask); converting the open piece tears down and reopens routed prose. `runPass` chain: guards through `guardOpenPieceRun` (#181: the ONE guard rail shared with blindRead — nothing running, mentor not mid-turn, engine ready, open saved piece) → readiness (missingKey names the provider) → flush → snapshot (unconditional, even for a later cancel) → capture stats → lint emit → `runningPass` live → own-engine run → advance ONLY on `.ended` with stopReason ≠ "refusal"; #179 audit: a Home repoint across the engine's turn REFUSES the advance with a strip message (the rail resolves `watchedHome` at call time — stamping into the repointed library would be silent on a slug collision). `blindRead` rides the same guard rail; nothing advances or records. `refreshCards` rides the rescan + open tails; `applyCard` = flush-first, stale anchor flags the card with no text change, the edit lands through `EditorSession.adoptText`; `promoteCard` writes a Learning and touches no text; #204 `revealCard` stamps ONE `revealRequest` (the anchor's span in the LIVE session text + a per-jump token) — a view act, nothing written; the editor column feeds it into the #71 caret rail (`caretHint`, now a `FixCardRevealRequest` — a non-zero range selects the span). `micropubSend` (#206; was `micropubSendDraft`) = guards → flush → (#207 a non-nil `categories:` edit lands as the piece's `category:` line FIRST — a failed write REFUSES the send with nothing on the wire; #208 a non-nil `summary:` edit lands the same way, sanitized through `summaryValue`) → ONE disk read serves the wire fields, the categories, the summary, and the remembered URL — no URL → create + stamp `micropub_url`, a remembered URL → the in-place update (`stampCategories` + `stampSummary` + `updateRememberedOrCreate` are its steps); `micropubPublish` (step 2, model-owned since #206) trust-gates its URL (`trustworthyURL` — it lands in frontmatter), #207/#208 runs `micropubSend` FIRST when `categories:` or `summary:` is non-nil — the remembered post, or the fresh draft a create returned, is what gets published, and a failed send returns its outcome with NO publish (disk and blog never silently disagree) — then stamps the publish record `micropub_published` and heals `micropub_url` in the same write; both share the (Home, ID) identity guard `openMicropubPiece`. `canArmWritingLock`/`editorBodyText` mirror the editor's outline routing (prose only). #200: quit is a document departure — `shutdown()` routes both sessions through `documentsMayDepart` (void — the verdict channel is quitReply's); `PostsModel.active` (weak static, registered by `AppGateState.init` — the `WritingLockState.active` precedent) is the quit gate's reachability, bare test rigs never register.
|
||||
- `PostsModelWatcher.swift` — #193: the watching domain of PostsModel (moved from PostsModel.swift) — `PostsWatcher` (recursive FSEvents stream, file-level, 0.5 s latency) on BOTH `projects/` and `archive/`; `bind(home:)` (WorkspaceView's root `.task(id: museionHome)` drives it); `startWatching` (the one `watchedHome` writer); `rescan` off-main through the app-scoped scan cache, skipping the `posts` assignment on equality (@Observable invalidates on assignment — panes would regroup on autosave echoes), bumping `contentRevision` on list change OR cache miss (#144), handing the session the open post's disk text (the #67 check, watcher echo suppressed by equality), riding the cards refresh at the tail.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -4,11 +4,9 @@
|
||||
//
|
||||
// #193: the Posts library column, moved from PostsPaneView.swift
|
||||
// (file-length ceiling) — PostsLibraryColumn with its rename/move
|
||||
// sheets, the file-scope librarySearch mount (#144), and
|
||||
// LaunchFocusReset (r8), code unchanged.
|
||||
// sheets and the file-scope librarySearch mount (#144). The r8 focus
|
||||
// rider is InitialFocusReset (WorkspaceChrome.swift).
|
||||
//
|
||||
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
/// #21: the library column, shared by the unfocused layout and the focus-mode
|
||||
@@ -36,8 +34,8 @@ struct PostsLibraryColumn: View {
|
||||
/// onAppear-unfocus could never work — the launch focus is AppKit
|
||||
/// assigning the window's INITIAL first responder to its first text
|
||||
/// input (this field), at window-become-key, AFTER onAppear. FocusState
|
||||
/// merely mirrors that back as true. LaunchFocusReset (below) resigns
|
||||
/// it at the first become-key; from then on only the user drives this.
|
||||
/// merely mirrors that back as true. InitialFocusReset (WorkspaceChrome)
|
||||
/// resigns it at the first become-key; from then on only the user drives this.
|
||||
@FocusState private var searchFocused: Bool
|
||||
|
||||
private var trimmedQuery: String {
|
||||
@@ -156,8 +154,8 @@ struct PostsLibraryColumn: View {
|
||||
}
|
||||
.frame(width: DesignTokens.libraryWidth)
|
||||
// r8 (argon#6, mercury#12): the focus-rider replaces the r6/r7
|
||||
// onAppear-unfocus — see LaunchFocusReset below for the mechanism.
|
||||
.background(LaunchFocusReset())
|
||||
// onAppear-unfocus — see InitialFocusReset (WorkspaceChrome) for the mechanism.
|
||||
.background(InitialFocusReset(scope: .oncePerProcess))
|
||||
.sheet(item: $renamingPost) { post in
|
||||
RenamePostSheet(post: post) { title in
|
||||
model.rename(post, to: title)
|
||||
@@ -384,57 +382,6 @@ private nonisolated func librarySearch(
|
||||
}
|
||||
}
|
||||
|
||||
/// r8 (argon#6, mercury#12 — the launch auto-focus ROOT CAUSE, killed at
|
||||
/// the source): the search field is the window's first — and at launch,
|
||||
/// only — text input, and AppKit assigns the window's initial first
|
||||
/// responder to it when the window becomes key. That happens AFTER
|
||||
/// onAppear, so the r6/r7 `searchFocused = false` writes were always
|
||||
/// overridden (FocusState mirrors the assignment back as true: terracotta
|
||||
/// ring + caret, the strongest element on screen). This invisible rider
|
||||
/// rides the library column and, at the window's FIRST become-key,
|
||||
/// resigns focus back to the window itself (`makeFirstResponder(nil)` —
|
||||
/// the neutral state; nothing gains focus instead). ONCE per process: a
|
||||
/// pane-switch remount must never steal a focus the user set on return.
|
||||
/// The second, next-runloop resign covers an assignment that lands after
|
||||
/// the notification (the PostEditorView layout-race precedent).
|
||||
private struct LaunchFocusReset: NSViewRepresentable {
|
||||
/// Process-wide once-flag — launch is a once-per-process event.
|
||||
private static var hasRun = false
|
||||
|
||||
final class RiderView: NSView {
|
||||
private var keyObserver: NSObjectProtocol?
|
||||
|
||||
override func viewDidMoveToWindow() {
|
||||
if let keyObserver {
|
||||
NotificationCenter.default.removeObserver(keyObserver)
|
||||
}
|
||||
keyObserver = nil
|
||||
guard let window else { return }
|
||||
keyObserver = NotificationCenter.default.addObserver(
|
||||
forName: NSWindow.didBecomeKeyNotification,
|
||||
object: window,
|
||||
queue: .main,
|
||||
) { _ in
|
||||
MainActor.assumeIsolated {
|
||||
// The observer is scoped to `window` (object:), so the
|
||||
// notification carries nothing we don't already hold —
|
||||
// reading `note` here would cross a Sendable boundary.
|
||||
guard !LaunchFocusReset.hasRun else { return }
|
||||
LaunchFocusReset.hasRun = true
|
||||
window.makeFirstResponder(nil)
|
||||
DispatchQueue.main.async { window.makeFirstResponder(nil) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func makeNSView(context _: Context) -> RiderView {
|
||||
RiderView()
|
||||
}
|
||||
|
||||
func updateNSView(_: RiderView, context _: Context) {}
|
||||
}
|
||||
|
||||
/// #108: Move to Project ask — radio list of the non-archived projects,
|
||||
/// default = the piece's current project. Matches RenamePostSheet's shape.
|
||||
struct MoveToProjectSheet: View {
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
// #193: the shared workspace chrome, moved from WorkspaceView.swift
|
||||
// (file-length ceiling) — SelectedRowStrip, BorderedSecondaryButtonStyle,
|
||||
// PaneHeader; every pane reuses them, code unchanged. #205 adds
|
||||
// FinderHandOffButtons, #206 MicroblogHandOffButton (both born here).
|
||||
// FinderHandOffButtons, #206 MicroblogHandOffButton (both born here), and
|
||||
// InitialFocusReset (the r8 launch-focus rider — #207 follow-up: once per
|
||||
// window for the publish sheet too).
|
||||
//
|
||||
|
||||
import AppKit
|
||||
@@ -136,3 +138,71 @@ struct MicroblogHandOffButton: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// r8 (argon#6, mercury#12 — the launch auto-focus ROOT CAUSE, killed at the source): AppKit assigns a
|
||||
/// window's INITIAL first responder to its first text input when the window becomes key — AFTER onAppear,
|
||||
/// so a FocusState write can't undo it (FocusState merely mirrors the assignment back as true: terracotta
|
||||
/// ring + caret, the strongest element on screen). This invisible rider, at the window's FIRST become-key,
|
||||
/// resigns focus back to the window itself (`makeFirstResponder(nil)` — the neutral state; nothing gains
|
||||
/// focus instead). The second, next-runloop resign covers an assignment that lands after the notification
|
||||
/// (the PostEditorView layout-race precedent). #207 follow-up: a SHEET window takes the focus the same way
|
||||
/// (the publish sheet's Categories field — its completion menu popped on open; `.defaultFocus(…, false)`
|
||||
/// changes nothing on macOS 27.2.1, `prototypes/MicropubSheetFocusProbe.swift`), so the rider carries a
|
||||
/// scope — the library column's launch reset and the sheet's, two callers.
|
||||
struct InitialFocusReset: NSViewRepresentable {
|
||||
/// `.oncePerProcess` — the launch: a pane-switch remount must never steal a focus the user set on
|
||||
/// return. `.oncePerWindow` — a sheet: every presentation is a new window, and its later re-keys keep
|
||||
/// the user's focus.
|
||||
enum Scope {
|
||||
case oncePerProcess
|
||||
case oncePerWindow
|
||||
}
|
||||
|
||||
private static var processHasRun = false
|
||||
let scope: Scope
|
||||
|
||||
final class RiderView: NSView {
|
||||
var scope: Scope = .oncePerProcess
|
||||
private var windowHasRun = false
|
||||
private var keyObserver: NSObjectProtocol?
|
||||
|
||||
override func viewDidMoveToWindow() {
|
||||
if let keyObserver {
|
||||
NotificationCenter.default.removeObserver(keyObserver)
|
||||
}
|
||||
keyObserver = nil
|
||||
guard let window else { return }
|
||||
keyObserver = NotificationCenter.default.addObserver(
|
||||
forName: NSWindow.didBecomeKeyNotification,
|
||||
object: window,
|
||||
queue: .main,
|
||||
) { _ in
|
||||
MainActor.assumeIsolated {
|
||||
// The observer is scoped to `window` (object:), so the
|
||||
// notification carries nothing we don't already hold —
|
||||
// reading `note` here would cross a Sendable boundary.
|
||||
switch self.scope {
|
||||
case .oncePerProcess:
|
||||
guard !InitialFocusReset.processHasRun else { return }
|
||||
InitialFocusReset.processHasRun = true
|
||||
case .oncePerWindow:
|
||||
guard !self.windowHasRun else { return }
|
||||
self.windowHasRun = true
|
||||
}
|
||||
window.makeFirstResponder(nil)
|
||||
DispatchQueue.main.async { window.makeFirstResponder(nil) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func makeNSView(context _: Context) -> RiderView {
|
||||
// The scope is set once at creation: it is a `let` on the representable and never changes
|
||||
// for the view's lifetime.
|
||||
let view = RiderView()
|
||||
view.scope = scope
|
||||
return view
|
||||
}
|
||||
|
||||
func updateNSView(_: RiderView, context _: Context) {}
|
||||
}
|
||||
Reference in new issue
Block a user