feat(editor): spellcheck posture toggle (#77)
CI / ci (push) Canceled after 0s

Neo triage input: continuous spell checking off by default, on when
asked — markdown on disk already carries the spelling; squiggles are
a presentation choice, per-launch with no persistence.

Edit ▸ Check Spelling While Typing binds AppGateState.spellChecking
and applies it to the live NSTextView in makeNSView/updateNSView.
Commands views take gate as a plain property — @Environment lookups
trap at launch there (crash-verified).

Verified in-app: toggle -> live view flag true -> squiggles render.
(The initial "does nothing" report was a machine-level kill switch:
NSAllowContinuousSpellChecking=0 in the global defaults domain, since
deleted; no app code change was needed for that part.)

Closes #77 follow-up.
This commit is contained in:
AlexKucera committed 2026-10-08 17:36:57 +02:00
1 parent 49fab56452
commit c1f5d707f8
4 files changed
+46 -4

No files matched your search

+2
View File
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. The format
### Added ### Added
- **editor:** spellcheck posture (#77, Neo triage input) — Edit ▸ Check Spelling While Typing now toggles continuous spell checking in the editor; off by default (markdown on disk carries the spelling, squiggles on request), per-launch with no persistence
- **editor:** M1 editor core (PRD S1.2) — posts open into a native TextKit2 editing surface (ADR-0010 mode B): styled source with scaled headings, paragraph spacing, and dimmed markdown syntax lifted from the proven spike; ~1 s debounced autosave with flush on selection change, window close, and app quit (⌘S stays immediate); a Saved → Saving… → Saved dot that turns accent on failure; cursor position and scroll restored across restarts via a per-post `.museion-state.json` sidecar that dies with the folder on Trash; and an explicit "File on Disk changed — Reload / Keep Local" alert on external edits, never a silent clobber (issue #19) - **editor:** M1 editor core (PRD S1.2) — posts open into a native TextKit2 editing surface (ADR-0010 mode B): styled source with scaled headings, paragraph spacing, and dimmed markdown syntax lifted from the proven spike; ~1 s debounced autosave with flush on selection change, window close, and app quit (⌘S stays immediate); a Saved → Saving… → Saved dot that turns accent on failure; cursor position and scroll restored across restarts via a per-post `.museion-state.json` sidecar that dies with the folder on Trash; and an explicit "File on Disk changed — Reload / Keep Local" alert on external edits, never a silent clobber (issue #19)
- **workspace:** M1 Post lifecycle (PRD S1.1) — Posts are now writable end to end: New Post holds an in-memory draft (no folder until first save), ⌘S lazily materializes `posts/<slug>/post.md` stamped with flat frontmatter (`pass_state: First Draft`, `origin: writer`), the slug is the Title's (lowercased, diacritic-folded, CJK-keeping) form with case-insensitive `-2`/`-3` collision suffixes, Explicit Rename retitles the `# Title` line and moves the folder (file stays `post.md`), and Delete moves the folder to the Trash; a recursive FSEvents watcher keeps the list mirroring `posts/` (external Finder edits included), and a plain-TextEditor stub stands in for the S1.2 editor (issue #18) - **workspace:** M1 Post lifecycle (PRD S1.1) — Posts are now writable end to end: New Post holds an in-memory draft (no folder until first save), ⌘S lazily materializes `posts/<slug>/post.md` stamped with flat frontmatter (`pass_state: First Draft`, `origin: writer`), the slug is the Title's (lowercased, diacritic-folded, CJK-keeping) form with case-insensitive `-2`/`-3` collision suffixes, Explicit Rename retitles the `# Title` line and moves the folder (file stays `post.md`), and Delete moves the folder to the Trash; a recursive FSEvents watcher keeps the list mirroring `posts/` (external Finder edits included), and a plain-TextEditor stub stands in for the S1.2 editor (issue #18)
- **workspace:** M1 Home & Posts list (PRD S1.1) — the post-gate main surface is now the workspace shell from the design contract: nav rail (Posts, Sessions, Learnings, Settings), a Posts pane that mirrors the Museion Home's `posts/` folder on disk (Pass State groups, origin meta, empty state, lazy folders skipped), a Settings pane where the Home can be repointed (repoint-only — Museion never moves content; NSOpenPanel picker, UserDefaults persistence, default `~/Documents/Museion`), and placeholder panes for Sessions/Learnings until their milestones; the M0 mentor pane becomes the workspace's fourth column (issue #17) - **workspace:** M1 Home & Posts list (PRD S1.1) — the post-gate main surface is now the workspace shell from the design contract: nav rail (Posts, Sessions, Learnings, Settings), a Posts pane that mirrors the Museion Home's `posts/` folder on disk (Pass State groups, origin meta, empty state, lazy folders skipped), a Settings pane where the Home can be repointed (repoint-only — Museion never moves content; NSOpenPanel picker, UserDefaults persistence, default `~/Documents/Museion`), and placeholder panes for Sessions/Learnings until their milestones; the M0 mentor pane becomes the workspace's fourth column (issue #17)
+1 -1
View File
@@ -26,7 +26,7 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro
- `PostLibrary.swift` — `Post` (nonisolated: id/title/passState/origin) + `Post.scan(home:) -> [Post]`: reads `posts/<id>/post.md`, skips dirs without post.md (lazy folders), loose files, hidden dirs (dot-prefix), and symlinked dirs; Title = first non-empty line after frontmatter (`untitled` on blank, marker-only, or unterminated-frontmatter bodies); `pass_state`/`origin` frontmatter keys read leniently (First Draft/writer defaults, quoted YAML values unquoted, leading blank line before `---` tolerated). Scan runs off-main (bind/rescan in PostsModel). - `PostLibrary.swift` — `Post` (nonisolated: id/title/passState/origin) + `Post.scan(home:) -> [Post]`: reads `posts/<id>/post.md`, skips dirs without post.md (lazy folders), loose files, hidden dirs (dot-prefix), and symlinked dirs; Title = first non-empty line after frontmatter (`untitled` on blank, marker-only, or unterminated-frontmatter bodies); `pass_state`/`origin` frontmatter keys read leniently (First Draft/writer defaults, quoted YAML values unquoted, leading blank line before `---` tolerated). Scan runs off-main (bind/rescan in PostsModel).
- `PostStore.swift` — #18 write side (nonisolated): the shared slug function (#60: lowercase, diacritic-fold, strip punctuation, whitespace→hyphens, keep CJK, 80-char cap, `untitled` fallback), `availableSlug` collision suffixes `-2`/`-3`…, `writeNew` (lazy folder + #59 stamp `pass_state: First Draft` / `origin: writer` — the only values #18 writes), `overwrite` (preserves existing pass_state/origin, normalizes bare posts on save), `rename` = retitle + move (rewrites/inserts `# Title` as first non-empty body line, moves the folder, file stays `post.md`; a title slugging to the current id only retitles), `trash` (`FileManager.trashItem` — recoverable), `readBody` (frontmatter stripped for editing). - `PostStore.swift` — #18 write side (nonisolated): the shared slug function (#60: lowercase, diacritic-fold, strip punctuation, whitespace→hyphens, keep CJK, 80-char cap, `untitled` fallback), `availableSlug` collision suffixes `-2`/`-3`…, `writeNew` (lazy folder + #59 stamp `pass_state: First Draft` / `origin: writer` — the only values #18 writes), `overwrite` (preserves existing pass_state/origin, normalizes bare posts on save), `rename` = retitle + move (rewrites/inserts `# Title` as first non-empty body line, moves the folder, file stays `post.md`; a title slugging to the current id only retitles), `trash` (`FileManager.trashItem` — recoverable), `readBody` (frontmatter stripped for editing).
- `PostsModel.swift` — `PostsModel` (@MainActor @Observable, app-scoped via `AppGateState.posts`): posts list + selection + New Post draft (`PostDraft`, in-memory, no folder until first save); the open post's `EditorSession` (#19) — `select(_:home:)` ends the prior session with a flush and opens a new one, rename/trash of the open post drops the session, `shutdown()` flushes on app quit; recursive FSEvents stream (`kFSEventStreamCreateFlagFileEvents`, 0.5 s latency — the debounce; file-level so nested `post.md` edits fire) on `posts/`, rescan reusing `Post.scan` off-main (#61 — own ops route through the same rescan; the rescan also hands the session the open post's disk text — the #67 external-change check, watcher-echo suppressed by equality with the session's last-flushed text); `bind(home:)` from `.task(id: home)` creates `posts/` if missing + rebinds on repoint; lifecycle ops (`saveDraft`/`rename`/`trash`) set `lastError` on failure, never alert; the session's `onError` routes save failures into the same strip. - `PostsModel.swift` — `PostsModel` (@MainActor @Observable, app-scoped via `AppGateState.posts`): posts list + selection + New Post draft (`PostDraft`, in-memory, no folder until first save); the open post's `EditorSession` (#19) — `select(_:home:)` ends the prior session with a flush and opens a new one, rename/trash of the open post drops the session, `shutdown()` flushes on app quit; recursive FSEvents stream (`kFSEventStreamCreateFlagFileEvents`, 0.5 s latency — the debounce; file-level so nested `post.md` edits fire) on `posts/`, rescan reusing `Post.scan` off-main (#61 — own ops route through the same rescan; the rescan also hands the session the open post's disk text — the #67 external-change check, watcher-echo suppressed by equality with the session's last-flushed text); `bind(home:)` from `.task(id: home)` creates `posts/` if missing + rebinds on repoint; lifecycle ops (`saveDraft`/`rename`/`trash`) set `lastError` on failure, never alert; the session's `onError` routes save failures into the same strip.
- Editor core (#19 / S1.2, ADR-0010 mode B): `ProsePresenter.swift` (nonisolated) — **#77 reading-parity rework**: line-kind → attributes map mirroring the calm-ruled reading surface (#78) — leading calibrated to CSS `--lh 1.8` via font metrics (`lineHeightMultiple(font:cssLineHeight:)` — copying the CSS number would overshoot ~20%, TextKit multiplies the natural box), heading ladder h1 30 / h2 22 / h3 19 body-face-bold / h4+ bold body (blank source lines = 9pt half-height separators), quote = secondary ink + 20pt firstLineHeadIndent, fence interiors mono-14 on substrate (fence-state scan of the prefix for reattribute), inline traits: `**bold**` / `_italic_` / `` `code` `` / link labels (ink + underline; brackets+URL dim; CommonMark intraword-`_` never emphasizes), list markers + heading hashes + quote markers dim; full-doc `attribute` on load, per-paragraph `reattribute` on edit; plain store stays the source of truth (ADR-0010: presentation-only attributes). `EditorSession.swift` — @MainActor @Observable session per open post: `edit` re-arms a ~1 s debounce (#64) → `flush` (⌘S / selection change / window close / app quit also flush); `flush` writes `PostStore.overwrite` + the cursor sidecar, tracks `saveState` Saved→Saving…→Saved (+ Save failed in accent, #65, routed to `lastError` too); `diskDidChange(diskText:)` raises the #67 conflict when disk ≠ last-flushed AND ≠ local; `reloadFromDisk` (alert Yes) bumps `loadGeneration` + re-reads the sidecar; `keepLocal` (No/Esc) marks disk as seen — next autosave overwrites (explicit choice); the debounce never fires while the conflict alert is unanswered (#67 — only ⌘S is explicit enough to overwrite then); `teardown(flushFirst:)` is the owner's lifecycle exit (flush before rename's disk read, cancel-only on trash/vanish so the debounce can't fire at a dead path); `folderURL` exposes `posts/<id>/` for reading image resolution (#71). `PostEditorView.swift` — toolbar (mono crumb + `SaveStateDot`: 6px dot + label, accessibilityLabel role=status; drafts show "⌘S saves" instead — no Save button, the stub's died) + `ProseTextView` (NSViewRepresentable: plain `isRichText = false` NSTextView, presentation-only attributes, native undo/IME/find, 640pt measure, loads keyed by session `loadGeneration` — never per keystroke; cursor state pushed on selection change, restored clamped on load); window-close observer flushes (#64); the #67 alert (Reload / Keep Local) lives here, above the surface swap (shows while reading too). `PostStore` cursor sidecar (#66): `CursorState{selectionLocation,selectionLength,scrollOffset}` Codable in `posts/<id>/.museion-state.json` — Finder-invisible, dies with the folder on Trash, drafts skip it; content write and sidecar write are separate (a failed sidecar never reads as a failed save). - Editor core (#19 / S1.2, ADR-0010 mode B): `ProsePresenter.swift` (nonisolated) — **#77 reading-parity rework**: line-kind → attributes map mirroring the calm-ruled reading surface (#78) — leading calibrated to CSS `--lh 1.8` via font metrics (`lineHeightMultiple(font:cssLineHeight:)` — copying the CSS number would overshoot ~20%, TextKit multiplies the natural box), heading ladder h1 30 / h2 22 / h3 19 body-face-bold / h4+ bold body (blank source lines = 9pt half-height separators), quote = secondary ink + 20pt firstLineHeadIndent, fence interiors mono-14 on substrate (fence-state scan of the prefix for reattribute), inline traits: `**bold**` / `_italic_` / `` `code` `` / link labels (ink + underline; brackets+URL dim; CommonMark intraword-`_` never emphasizes), list markers + heading hashes + quote markers dim; full-doc `attribute` on load, per-paragraph `reattribute` on edit; plain store stays the source of truth (ADR-0010: presentation-only attributes). `EditorSession.swift` — @MainActor @Observable session per open post: `edit` re-arms a ~1 s debounce (#64) → `flush` (⌘S / selection change / window close / app quit also flush); `flush` writes `PostStore.overwrite` + the cursor sidecar, tracks `saveState` Saved→Saving…→Saved (+ Save failed in accent, #65, routed to `lastError` too); `diskDidChange(diskText:)` raises the #67 conflict when disk ≠ last-flushed AND ≠ local; `reloadFromDisk` (alert Yes) bumps `loadGeneration` + re-reads the sidecar; `keepLocal` (No/Esc) marks disk as seen — next autosave overwrites (explicit choice); the debounce never fires while the conflict alert is unanswered (#67 — only ⌘S is explicit enough to overwrite then); `teardown(flushFirst:)` is the owner's lifecycle exit (flush before rename's disk read, cancel-only on trash/vanish so the debounce can't fire at a dead path); `folderURL` exposes `posts/<id>/` for reading image resolution (#71). `PostEditorView.swift` — toolbar (mono crumb + `SaveStateDot`: 6px dot + label, accessibilityLabel role=status; drafts show "⌘S saves" instead — no Save button, the stub's died) + `ProseTextView` (NSViewRepresentable: plain `isRichText = false` NSTextView, presentation-only attributes, native undo/IME/find, 640pt measure, loads keyed by session `loadGeneration` — never per keystroke; cursor state pushed on selection change, restored clamped on load); window-close observer flushes (#64); the #67 alert (Reload / Keep Local) lives here, above the surface swap (shows while reading too). #77 spellcheck posture: `AppGateState.spellChecking` (default false — Neo triage, markdown on disk carries the spelling; per-launch, no persistence) toggled by Edit ▸ Check Spelling While Typing (`EditSpellingToggle` in MuseionApp.swift — commands views take `gate` as a plain property, they don't inherit the window environment) and applied to the live NSTextView in `makeNSView`/`updateNSView`. `PostStore` cursor sidecar (#66): `CursorState{selectionLocation,selectionLength,scrollOffset}` Codable in `posts/<id>/.museion-state.json` — Finder-invisible, dies with the folder on Trash, drafts skip it; content write and sidecar write are separate (a failed sidecar never reads as a failed save).
- `SettingsPaneView.swift` — Home control (NSOpenPanel folder pick; files/canCreate on). Repoint-only semantics stated in-UI. #72 rework: the Typography/Text Flow sections are deleted — single-user app, prose type is hardcoded (ProseTypography constants + reading.css). - `SettingsPaneView.swift` — Home control (NSOpenPanel folder pick; files/canCreate on). Repoint-only semantics stated in-UI. #72 rework: the Typography/Text Flow sections are deleted — single-user app, prose type is hardcoded (ProseTypography constants + reading.css).
- Reading mode (#76 / S1.2, map #20; ADR-0011 apex HTML pipeline; decisions #68/#69/#70/#73): `ReadingPresenter.swift` (nonisolated, pure) — `stampSource` prepends `<!--S:N-->` sentinels before every blank-line chunk (apex passes HTML comments through); `apexRender` runs the **bundled apex binary** (`Museion/Resources/apex`, fs-sync group ships it in Resources automatically; fallback chain bundle → `APEX_PATH` → Homebrew, dev-only) with `-t html --no-mixed-lists --embed-images [--base-dir <postFolder>]` (no-mixed-lists REQUIRED: apex default merges ordered-after-bullets into one <ul>, killing `1. 1. 1.` renumbering; embed-images inlines base64 so `loadHTMLString` needs no file access and nothing is written to the vault); `stampHTML` regex-rewrites sentinels to `data-source-line="N"` on the following element (0 mis-stamps corpus-wide, #74); `blocks(for:)` builds the line↔UTF-16-range map (the #68 click→edit/scroll-sync contract); `page(for:postFolder:)` assembles the shell with `styleSheet()` — #72 rework: the whole stylesheet is `Museion/Resources/reading.css`, read FRESH per page build (dev builds prefer the repo copy via DerivedData-path detection, so CSS edits apply on the next reading toggle with no rebuild; the bundle copy ships in release). Values hardcoded for Alexander's fonts: Valkyrie OT B body 17/1.5, Concourse OT headings (w600), UbuntuMono code 14, 66ch measure — no UserDefaults, no Settings. **#72 polish (critique-directed, 2026-10-07):** flow defaults leading 1.5 / para 0.65 lines / code 14px; heading ladder h1 1.15× / h2 0.85× / h3 body×1.12 body-face w600 with cling margins (hN→content margin-top 0, hN+hN 0.35em, `body > :first-child` no offset); blockquote confident (near-ink #48484d, 3px rail #a1a1a6, nesting degrades to hairline); tables booktabs (top/bottom rules, heavier header rule, no vertical grid, full width); code = substrate-tint panel, inline code 0.88em relative; link underline #a1a1a6 → ink on hover; `::selection`/`:focus-visible` themed; secondary tokens `--secondary/--rule/--substrate`. Fallback on apex failure = escaped source in a `<pre>` (#69 rule: fallback is the source, not a second renderer); footnotes render natively (apex upgrade over #69's fallback-decision). `ReadingSurface.swift` — `ReadingStateBox`/`CaretHintBox` (flow state, #68) + one **WKWebView reloaded in place** (remount was the dominant switch cost, #74; keyed render on generation+text+flowKey, never per keystroke): injected `probeJS` maps click→source line (tap = edit intent at that block), ⌘-click→`NSWorkspace.open`, scroll→top-visible-line into `stateBox.topSourceLocation`; `decidePolicyFor` allows only our own about:blank main-frame load, cancels the rest; entry-caret mapping scrolls the caret's block to top after `didFinish`; reload keyed on generation+text only (#72 rework: no flow knobs — the CSS file is read per build). DELETED with the pivot: `ReadingCanvasView`, `Decoration`, `framesForRange`, `ImagePopoverView` (ADR-0011: fallbacks rot; the #71 stale-flow defect dies unfixed). Editing side untouched: `ProsePresenter`, `EditorSession`, `ProseTextView`, toggle wiring (#68) all stand; editing-side spacing obligation lives in #77. - Reading mode (#76 / S1.2, map #20; ADR-0011 apex HTML pipeline; decisions #68/#69/#70/#73): `ReadingPresenter.swift` (nonisolated, pure) — `stampSource` prepends `<!--S:N-->` sentinels before every blank-line chunk (apex passes HTML comments through); `apexRender` runs the **bundled apex binary** (`Museion/Resources/apex`, fs-sync group ships it in Resources automatically; fallback chain bundle → `APEX_PATH` → Homebrew, dev-only) with `-t html --no-mixed-lists --embed-images [--base-dir <postFolder>]` (no-mixed-lists REQUIRED: apex default merges ordered-after-bullets into one <ul>, killing `1. 1. 1.` renumbering; embed-images inlines base64 so `loadHTMLString` needs no file access and nothing is written to the vault); `stampHTML` regex-rewrites sentinels to `data-source-line="N"` on the following element (0 mis-stamps corpus-wide, #74); `blocks(for:)` builds the line↔UTF-16-range map (the #68 click→edit/scroll-sync contract); `page(for:postFolder:)` assembles the shell with `styleSheet()` — #72 rework: the whole stylesheet is `Museion/Resources/reading.css`, read FRESH per page build (dev builds prefer the repo copy via DerivedData-path detection, so CSS edits apply on the next reading toggle with no rebuild; the bundle copy ships in release). Values hardcoded for Alexander's fonts: Valkyrie OT B body 17/1.5, Concourse OT headings (w600), UbuntuMono code 14, 66ch measure — no UserDefaults, no Settings. **#72 polish (critique-directed, 2026-10-07):** flow defaults leading 1.5 / para 0.65 lines / code 14px; heading ladder h1 1.15× / h2 0.85× / h3 body×1.12 body-face w600 with cling margins (hN→content margin-top 0, hN+hN 0.35em, `body > :first-child` no offset); blockquote confident (near-ink #48484d, 3px rail #a1a1a6, nesting degrades to hairline); tables booktabs (top/bottom rules, heavier header rule, no vertical grid, full width); code = substrate-tint panel, inline code 0.88em relative; link underline #a1a1a6 → ink on hover; `::selection`/`:focus-visible` themed; secondary tokens `--secondary/--rule/--substrate`. Fallback on apex failure = escaped source in a `<pre>` (#69 rule: fallback is the source, not a second renderer); footnotes render natively (apex upgrade over #69's fallback-decision). `ReadingSurface.swift` — `ReadingStateBox`/`CaretHintBox` (flow state, #68) + one **WKWebView reloaded in place** (remount was the dominant switch cost, #74; keyed render on generation+text+flowKey, never per keystroke): injected `probeJS` maps click→source line (tap = edit intent at that block), ⌘-click→`NSWorkspace.open`, scroll→top-visible-line into `stateBox.topSourceLocation`; `decidePolicyFor` allows only our own about:blank main-frame load, cancels the rest; entry-caret mapping scrolls the caret's block to top after `didFinish`; reload keyed on generation+text only (#72 rework: no flow knobs — the CSS file is read per build). DELETED with the pivot: `ReadingCanvasView`, `Decoration`, `framesForRange`, `ImagePopoverView` (ADR-0011: fallbacks rot; the #71 stale-flow defect dies unfixed). Editing side untouched: `ProsePresenter`, `EditorSession`, `ProseTextView`, toggle wiring (#68) all stand; editing-side spacing obligation lives in #77.
- `AppGateState.museionHome` — app-scoped Home (UserDefaults `museionHome`, default `~/Documents/Museion` = `defaultMuseionHome`; non-file URLs read back as nil — the Home is always a folder). Explicit init: `Self` in a stored-property initializer breaks `@ObservationTracked` (covariant-Self error). - `AppGateState.museionHome` — app-scoped Home (UserDefaults `museionHome`, default `~/Documents/Museion` = `defaultMuseionHome`; non-file URLs read back as nil — the Home is always a folder). Explicit init: `Self` in a stored-property initializer breaks `@ObservationTracked` (covariant-Self error).
+25
View File
@@ -24,6 +24,10 @@ final class AppGateState {
let mentor = MentorSessionModel() let mentor = MentorSessionModel()
/// #18: the app-scoped Posts state — FSEvents watcher + lifecycle ops. /// #18: the app-scoped Posts state — FSEvents watcher + lifecycle ops.
let posts = PostsModel() let posts = PostsModel()
/// #77 (Neo triage input): spellcheck posture — off by default, on when
/// asked via Edit ▸ Check Spelling While Typing. Per-launch only, no
/// persistence; markdown on disk already carries the spelling.
var spellChecking = false
/// #17: the Museion Home — repoint-only (ADR-0004). Defaults to /// #17: the Museion Home — repoint-only (ADR-0004). Defaults to
/// `~/Documents/Museion`; UserDefaults is the persistence floor: a Home is /// `~/Documents/Museion`; UserDefaults is the persistence floor: a Home is
/// a plain folder, nothing app-owned to put in a database. Non-file URLs /// a plain folder, nothing app-owned to put in a database. Non-file URLs
@@ -74,6 +78,12 @@ struct MuseionApp: App {
CommandGroup(replacing: .appInfo) { CommandGroup(replacing: .appInfo) {
OpenAboutButton() OpenAboutButton()
} }
// #77: spellcheck posture — Edit ▸ Check Spelling While Typing,
// default off (Neo posture: on when asked). Explicit rather than
// relying on the stock submenu's presence in a WindowGroup app.
CommandGroup(after: .textEditing) {
EditSpellingToggle(gate: gate)
}
// #68: View menu reading toggle — reaches the visible editor. // #68: View menu reading toggle — reaches the visible editor.
CommandMenu("View") { CommandMenu("View") {
Button("Toggle Reading Mode") { Button("Toggle Reading Mode") {
@@ -98,6 +108,21 @@ private struct OpenAboutButton: View {
} }
} }
/// #77: the spellcheck posture toggle — binds the app-scoped bool the editor
/// surface reads on every update pass. Takes `gate` as a plain property:
/// commands views don't inherit the window environment (@Environment lookup
/// traps at launch — crash-verified), but observation tracking still works.
private struct EditSpellingToggle: View {
let gate: AppGateState
var body: some View {
Toggle("Check Spelling While Typing", isOn: Binding(
get: { gate.spellChecking },
set: { gate.spellChecking = $0 },
))
}
}
/// #50: reveals `~/Library/Application Support/Museion/Backups` in Finder — /// #50: reveals `~/Library/Application Support/Museion/Backups` in Finder —
/// restore is manual Finder copy-back in v1 (help doc describes it). /// restore is manual Finder copy-back in v1 (help doc describes it).
private struct OpenBackupFolderButton: View { private struct OpenBackupFolderButton: View {
+18 -3
View File
@@ -35,6 +35,9 @@ struct PostEditorView: View {
@State private var closeObserver: AnyCancellable? @State private var closeObserver: AnyCancellable?
@State private var toggleObserver: AnyCancellable? @State private var toggleObserver: AnyCancellable?
/// #77: spellcheck posture (app-scoped, Edit menu) — applied to the live
/// text view on every representable update.
@Environment(AppGateState.self) private var gate
/// #68: reading is a transient act of inspection — no persistence; a /// #68: reading is a transient act of inspection — no persistence; a
/// fresh open always lands in editing. /// fresh open always lands in editing.
@State private var reading = false @State private var reading = false
@@ -107,9 +110,9 @@ struct PostEditorView: View {
@ViewBuilder @ViewBuilder
private var editingSurface: some View { private var editingSurface: some View {
if let session { if let session {
ProseTextView(session: session, caretHint: flipBackCaret) ProseTextView(session: session, spellChecking: gate.spellChecking, caretHint: flipBackCaret)
} else { } else {
ProseTextView(draft: draftMirror, onEdit: { newText in ProseTextView(draft: draftMirror, spellChecking: gate.spellChecking, onEdit: { newText in
draftMirror = newText draftMirror = newText
draftEdited?(newText) draftEdited?(newText)
}, caretHint: flipBackCaret) }, caretHint: flipBackCaret)
@@ -238,19 +241,27 @@ struct ProseTextView: NSViewRepresentable {
var session: EditorSession? var session: EditorSession?
var draft: String? var draft: String?
var onEdit: ((String) -> Void)? var onEdit: ((String) -> Void)?
var spellChecking = false
var caretHint: (location: Int, token: Int)? var caretHint: (location: Int, token: Int)?
init(session: EditorSession, caretHint: (location: Int, token: Int)? = nil) { init(
session: EditorSession,
spellChecking: Bool = false,
caretHint: (location: Int, token: Int)? = nil,
) {
self.session = session self.session = session
self.spellChecking = spellChecking
self.caretHint = caretHint self.caretHint = caretHint
} }
init( init(
draft: String, draft: String,
spellChecking: Bool = false,
onEdit: @escaping (String) -> Void, onEdit: @escaping (String) -> Void,
caretHint: (location: Int, token: Int)? = nil, caretHint: (location: Int, token: Int)? = nil,
) { ) {
self.draft = draft self.draft = draft
self.spellChecking = spellChecking
self.onEdit = onEdit self.onEdit = onEdit
self.caretHint = caretHint self.caretHint = caretHint
} }
@@ -273,6 +284,8 @@ struct ProseTextView: NSViewRepresentable {
tv.isAutomaticDashSubstitutionEnabled = false tv.isAutomaticDashSubstitutionEnabled = false
tv.isAutomaticTextReplacementEnabled = false tv.isAutomaticTextReplacementEnabled = false
tv.isAutomaticSpellingCorrectionEnabled = false tv.isAutomaticSpellingCorrectionEnabled = false
// #77: squiggles follow the posture toggle (default off).
tv.isContinuousSpellCheckingEnabled = spellChecking
tv.usesFindBar = true tv.usesFindBar = true
tv.backgroundColor = NSColor.white tv.backgroundColor = NSColor.white
tv.typingAttributes = ProseTypography.bodyAttributes tv.typingAttributes = ProseTypography.bodyAttributes
@@ -305,6 +318,8 @@ struct ProseTextView: NSViewRepresentable {
func updateNSView(_ scroll: NSScrollView, context: Context) { func updateNSView(_ scroll: NSScrollView, context: Context) {
guard let tv = scroll.documentView as? NSTextView else { return } guard let tv = scroll.documentView as? NSTextView else { return }
// #77: posture toggle while editing — cheap idempotent set.
tv.isContinuousSpellCheckingEnabled = spellChecking
if let session { if let session {
context.coordinator.sessionRef = session context.coordinator.sessionRef = session
// Load only when the generation moved (open, Yes-reload) — never // Load only when the generation moved (open, Yes-reload) — never