fix(workspace): audit fixes — dedupe failure chip, width-guard mentor overlay, a11y, NSColor bridge (#87)
Reviewer fan-out (ponytail/security/general) synthesis: - one failure surface in focus (chip carries it; toolbar stays recessed) - draft '⌘S saves' cue in focus (drafts have no autosave) - mentor reveal honors the #17 width verdict - hidden overlay panels leave the accessibility tree - NSColor(DesignTokens.background) bridge replaces the twin constant - HoverZone width plumbing deleted, zoneWidth hoisted as the knob - single >=1100 threshold read in WorkspaceView
This commit is contained in:
1 parent
9c2926f027
commit
d07d41859a
6 files changed
+49
-46
No files matched your search
+1
-1
@@ -28,7 +28,7 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro
|
|||||||
- `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` Changed→Saved (+ Save failed in accent, #65/#83, routed to `lastError` too — dirty = local text ≠ last flushed, shown honestly while the debounce holds); `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).
|
- 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` Changed→Saved (+ Save failed in accent, #65/#83, routed to `lastError` too — dirty = local text ≠ last flushed, shown honestly while the debounce holds); `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).
|
||||||
- Focus mode (#21 / S1.2, map #21; execution-carrying map — the build IS the prototype, the calibration gate judges calm): `AppGateState.isFocused` (transient like reading #68 — per-launch, no persistence; View ▸ Toggle Focus Mode beside Toggle Reading Mode + ⌘⇧F via `FocusModeToggle` in MuseionApp.swift; disabled when no post is open and no draft exists, but exit stays armed so trashing the open post can't trap). `FocusChrome.swift` — `HoverZone` (tracking-area edge strip, click-through via `hitTest → nil`), `FocusOverlayPanel` (slide-in overlay panel — floats over the measure, never pushes it; 140 ms hide grace covers the zone→panel transit), `CaretCentering` (soft caret centering: ±60pt comfort band, pure `targetOffset` math + animated clip-view scroll from `textDidChange` only — scrollback/drag-selection never fought, document clamp parks at the bottom, no jump). `WorkspaceView` hides the rail in focus (pane takes full width); left-edge hover slides rail+library back in (library only when window ≥1100px — #17's width collapse is not overridden). `PostsPaneView` hides library+mentor columns; right-edge hover slides the mentor back in. `PostsLibraryColumn` (extracted from PostsPaneView) is the shared library implementation, unfocused layout and focus overlay alike — rename sheet + context menu travel with it. `PostEditorView` — toolbar row recedes (unless save failed: the full SaveStateDot + "Save failed" widget reappears as a floating top overlay — failure stays loud); editor ground swaps surface → workspace background (`focusGround`); ⌘S moved to body level so it stays armed with the toolbar hidden (drafts have no autosave); `ProseTextView.focused` carries the ground + centering posture through the representable (NSColor twin `DesignTokens.workspaceBackground` — SwiftUI Color can't cross into NSTextView). Focus × reading orthogonal (⌘R works in focus, ⌘⇧F works while reading — independent state axes).
|
- Focus mode (#21 / S1.2, map #21; execution-carrying map — the build IS the prototype, the calibration gate judges calm): `AppGateState.isFocused` (transient like reading #68 — per-launch, no persistence; View ▸ Toggle Focus Mode beside Toggle Reading Mode + ⌃F via `FocusModeToggle` in MuseionApp.swift — ⇧⌘F collides with a system-wide shortcut on this machine; disabled when no post is open and no draft exists, but exit stays armed so trashing the open post can't trap). `FocusChrome.swift` — `HoverZone` (tracking-area edge strip, click-through via `hitTest → nil`; `zoneWidth` is the calibration knob), `FocusOverlayPanel` (slide-in overlay panel — floats over the measure, never pushes it; 140 ms hide grace covers the zone→panel transit; hidden = `opacity(0)` + `accessibilityHidden`), `CaretCentering` (soft caret centering: ±60pt comfort band, pure `targetOffset` math + animated clip-view scroll from `textDidChange` only — scrollback/drag-selection never fought, document clamp parks at the bottom, no jump). `WorkspaceView` hides the rail in focus (pane takes full width); left-edge hover slides rail+library back in (library only when window ≥1100px — #17's width collapse is not overridden). `PostsPaneView` hides library+mentor columns; right-edge hover slides the mentor back in (same width verdict — `showsMentor`). `PostsLibraryColumn` (extracted from PostsPaneView) is the shared library implementation, unfocused layout and focus overlay alike — rename sheet + context menu travel with it. `PostEditorView` — toolbar row recedes in focus; the failure surface is a floating chip at the top edge: save failure shows the full `SaveStateDot` (loud), a dirty draft shows the muted "⌘S saves" cue (drafts have no autosave); editor ground swaps surface → workspace background (`NSColor(DesignTokens.background)` bridge); ⌘S lives at body level so it stays armed with the toolbar hidden; `ProseTextView.focused` carries the ground + centering posture through the representable. Focus × reading orthogonal (⌘R works in focus, ⌃F works while reading — independent state axes).
|
||||||
- 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).
|
||||||
- `MentorPaneView` no longer carries a root min-frame — it lives in the 356pt mentor column.
|
- `MentorPaneView` no longer carries a root min-frame — it lives in the 356pt mentor column.
|
||||||
|
|||||||
@@ -19,13 +19,6 @@ enum DesignTokens {
|
|||||||
|
|
||||||
static let radius: CGFloat = 10
|
static let radius: CGFloat = 10
|
||||||
|
|
||||||
/// #21: NSColor twin of `background` — the focus-mode editor ground
|
|
||||||
/// (NSColor can't be derived from SwiftUI Color at runtime).
|
|
||||||
/// ponytail: nonisolated(unsafe) — NSColor isn't Sendable; never mutated.
|
|
||||||
nonisolated(unsafe) static let workspaceBackground = NSColor(
|
|
||||||
red: 0xFA / 255, green: 0xFA / 255, blue: 0xF7 / 255, alpha: 1,
|
|
||||||
)
|
|
||||||
|
|
||||||
/// The workspace grid: rail | posts library | editor | mentor (grid-template-columns
|
/// The workspace grid: rail | posts library | editor | mentor (grid-template-columns
|
||||||
/// `56px 232px minmax(420px, 1fr) 356px`). Editor min (420) has no enforcement
|
/// `56px 232px minmax(420px, 1fr) 356px`). Editor min (420) has no enforcement
|
||||||
/// yet — the editor column arrives with #19.
|
/// yet — the editor column arrives with #19.
|
||||||
|
|||||||
@@ -20,13 +20,14 @@ import SwiftUI
|
|||||||
struct HoverZone: NSViewRepresentable {
|
struct HoverZone: NSViewRepresentable {
|
||||||
enum Edge { case leading, trailing }
|
enum Edge { case leading, trailing }
|
||||||
|
|
||||||
|
/// Calibration knob: edge sensor strip width (pt).
|
||||||
|
static let zoneWidth: CGFloat = 14
|
||||||
|
|
||||||
var edge: Edge
|
var edge: Edge
|
||||||
var width: CGFloat
|
|
||||||
var onHover: @MainActor (Bool) -> Void
|
var onHover: @MainActor (Bool) -> Void
|
||||||
|
|
||||||
final class SensorView: NSView {
|
final class SensorView: NSView {
|
||||||
var edge: Edge = .leading
|
var edge: Edge = .leading
|
||||||
var zoneWidth: CGFloat = 14
|
|
||||||
var onHover: ((Bool) -> Void)?
|
var onHover: ((Bool) -> Void)?
|
||||||
|
|
||||||
private var trackingArea: NSTrackingArea?
|
private var trackingArea: NSTrackingArea?
|
||||||
@@ -36,9 +37,9 @@ struct HoverZone: NSViewRepresentable {
|
|||||||
if let trackingArea {
|
if let trackingArea {
|
||||||
removeTrackingArea(trackingArea)
|
removeTrackingArea(trackingArea)
|
||||||
}
|
}
|
||||||
let stripX = edge == .leading ? 0 : max(0, bounds.width - zoneWidth)
|
let stripX = edge == .leading ? 0 : max(0, bounds.width - HoverZone.zoneWidth)
|
||||||
let area = NSTrackingArea(
|
let area = NSTrackingArea(
|
||||||
rect: NSRect(x: stripX, y: 0, width: min(zoneWidth, bounds.width), height: bounds.height),
|
rect: NSRect(x: stripX, y: 0, width: min(HoverZone.zoneWidth, bounds.width), height: bounds.height),
|
||||||
options: [.mouseEnteredAndExited, .activeInActiveApp],
|
options: [.mouseEnteredAndExited, .activeInActiveApp],
|
||||||
owner: self,
|
owner: self,
|
||||||
userInfo: nil,
|
userInfo: nil,
|
||||||
@@ -73,9 +74,7 @@ struct HoverZone: NSViewRepresentable {
|
|||||||
|
|
||||||
private func configure(_ view: SensorView) {
|
private func configure(_ view: SensorView) {
|
||||||
view.edge = edge
|
view.edge = edge
|
||||||
view.zoneWidth = width
|
|
||||||
view.onHover = onHover
|
view.onHover = onHover
|
||||||
view.updateTrackingAreas()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,13 +99,14 @@ struct FocusOverlayPanel<Content: View>: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack(alignment: edge == .leading ? .leading : .trailing) {
|
ZStack(alignment: edge == .leading ? .leading : .trailing) {
|
||||||
HoverZone(edge: edge, width: 14) { hover($0) }
|
HoverZone(edge: edge) { hover($0) }
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
content()
|
content()
|
||||||
.background(DesignTokens.surface)
|
.background(DesignTokens.surface)
|
||||||
.shadow(color: .black.opacity(0.10), radius: 12, y: 0)
|
.shadow(color: .black.opacity(0.10), radius: 12, y: 0)
|
||||||
.frame(maxHeight: .infinity)
|
.frame(maxHeight: .infinity)
|
||||||
.allowsHitTesting(revealed)
|
.allowsHitTesting(revealed)
|
||||||
|
.accessibilityHidden(!revealed)
|
||||||
.onHover { hover($0) }
|
.onHover { hover($0) }
|
||||||
.opacity(revealed ? 1 : 0)
|
.opacity(revealed ? 1 : 0)
|
||||||
.offset(x: revealed ? 0 : hiddenOffset)
|
.offset(x: revealed ? 0 : hiddenOffset)
|
||||||
|
|||||||
@@ -86,25 +86,20 @@ struct PostEditorView: View {
|
|||||||
.frame(width: 1, height: 1)
|
.frame(width: 1, height: 1)
|
||||||
.accessibilityHidden(true)
|
.accessibilityHidden(true)
|
||||||
}
|
}
|
||||||
// #21: save failure is LOUD in focus — the full unfocused widget
|
// #21: save failure is LOUD in focus — the full widget floats where
|
||||||
// (dot + "Save failed") reappears, floating at the top edge where
|
// the toolbar stood. Drafts (no autosave): a muted cue appears once
|
||||||
// the toolbar row stood. Autosave keeps running underneath.
|
// there is text to lose; ⌘S stays armed either way (body level).
|
||||||
.overlay(alignment: .top) {
|
.overlay(alignment: .top) {
|
||||||
if gate.isFocused, session?.saveState == .failed {
|
if gate.isFocused {
|
||||||
HStack(spacing: 7) {
|
if session?.saveState == .failed {
|
||||||
Circle()
|
focusChip { SaveStateDot(state: .failed) }
|
||||||
.fill(DesignTokens.accent)
|
} else if session == nil, draftMirror != (draftText ?? "") {
|
||||||
.frame(width: 6, height: 6)
|
focusChip {
|
||||||
Text("Save failed")
|
Text("⌘S saves")
|
||||||
|
.font(.system(size: 11, design: DesignTokens.mono))
|
||||||
|
.foregroundStyle(DesignTokens.muted)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.font(.system(size: 12))
|
|
||||||
.foregroundStyle(DesignTokens.accent)
|
|
||||||
.padding(.horizontal, 14)
|
|
||||||
.padding(.vertical, 7)
|
|
||||||
.background(DesignTokens.surface.opacity(0.96), in: RoundedRectangle(cornerRadius: DesignTokens.radius))
|
|
||||||
.accessibilityElement(children: .ignore)
|
|
||||||
.accessibilityLabel("Save state: Save failed")
|
|
||||||
.transition(.move(edge: .top).combined(with: .opacity))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
@@ -135,9 +130,19 @@ struct PostEditorView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// #21: the toolbar row recedes in focus (unless failure is loud).
|
/// #21: the toolbar row recedes in focus — the floating chip above is
|
||||||
|
/// the failure surface there (never both at once).
|
||||||
private var showsToolbar: Bool {
|
private var showsToolbar: Bool {
|
||||||
!gate.isFocused || session?.saveState == .failed
|
!gate.isFocused
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The floating focus-mode chip: pill background + top-edge transition.
|
||||||
|
private func focusChip(@ViewBuilder _ content: () -> some View) -> some View {
|
||||||
|
content()
|
||||||
|
.padding(.horizontal, 14)
|
||||||
|
.padding(.vertical, 7)
|
||||||
|
.background(DesignTokens.surface.opacity(0.96), in: RoundedRectangle(cornerRadius: DesignTokens.radius))
|
||||||
|
.transition(.move(edge: .top).combined(with: .opacity))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// #21: focus runs on the workspace background, not the surface card —
|
/// #21: focus runs on the workspace background, not the surface card —
|
||||||
@@ -331,9 +336,9 @@ struct ProseTextView: NSViewRepresentable {
|
|||||||
// #77: squiggles follow the posture toggle (default off).
|
// #77: squiggles follow the posture toggle (default off).
|
||||||
tv.isContinuousSpellCheckingEnabled = spellChecking
|
tv.isContinuousSpellCheckingEnabled = spellChecking
|
||||||
tv.usesFindBar = true
|
tv.usesFindBar = true
|
||||||
// #21: focus ground joins the workspace background; drawsBackground
|
// #21: focus ground joins the workspace background (NSColor(Color)
|
||||||
// stays true either way (white in the unfocused card).
|
// bridges; white in the unfocused card).
|
||||||
tv.backgroundColor = focused ? DesignTokens.workspaceBackground : NSColor.white
|
tv.backgroundColor = focused ? NSColor(DesignTokens.background) : NSColor.white
|
||||||
tv.typingAttributes = ProseTypography.bodyAttributes
|
tv.typingAttributes = ProseTypography.bodyAttributes
|
||||||
tv.delegate = context.coordinator
|
tv.delegate = context.coordinator
|
||||||
tv.layoutManager?.allowsNonContiguousLayout = true
|
tv.layoutManager?.allowsNonContiguousLayout = true
|
||||||
@@ -356,7 +361,7 @@ struct ProseTextView: NSViewRepresentable {
|
|||||||
// out at rest (iOS-like), instead of always occupying the right edge.
|
// out at rest (iOS-like), instead of always occupying the right edge.
|
||||||
scroll.scrollerStyle = .overlay
|
scroll.scrollerStyle = .overlay
|
||||||
scroll.drawsBackground = true
|
scroll.drawsBackground = true
|
||||||
scroll.backgroundColor = focused ? DesignTokens.workspaceBackground : NSColor.white
|
scroll.backgroundColor = focused ? NSColor(DesignTokens.background) : NSColor.white
|
||||||
context.coordinator.textView = tv
|
context.coordinator.textView = tv
|
||||||
context.coordinator.sessionRef = session // strong: both die with the editor
|
context.coordinator.sessionRef = session // strong: both die with the editor
|
||||||
return scroll
|
return scroll
|
||||||
@@ -367,7 +372,7 @@ struct ProseTextView: NSViewRepresentable {
|
|||||||
// #77: posture toggle while editing — cheap idempotent set.
|
// #77: posture toggle while editing — cheap idempotent set.
|
||||||
tv.isContinuousSpellCheckingEnabled = spellChecking
|
tv.isContinuousSpellCheckingEnabled = spellChecking
|
||||||
// #21: the ground follows focus in/out without a remount.
|
// #21: the ground follows focus in/out without a remount.
|
||||||
let ground = focused ? DesignTokens.workspaceBackground : NSColor.white
|
let ground = focused ? NSColor(DesignTokens.background) : NSColor.white
|
||||||
tv.backgroundColor = ground
|
tv.backgroundColor = ground
|
||||||
scroll.backgroundColor = ground
|
scroll.backgroundColor = ground
|
||||||
context.coordinator.focused = focused
|
context.coordinator.focused = focused
|
||||||
|
|||||||
@@ -37,13 +37,16 @@ struct PostsPaneView: View {
|
|||||||
if gate.isFocused {
|
if gate.isFocused {
|
||||||
// #21: columns recede; the editor surface + centered measure on
|
// #21: columns recede; the editor surface + centered measure on
|
||||||
// the workspace background is all that remains. The mentor
|
// the workspace background is all that remains. The mentor
|
||||||
// returns by right-edge hover (overlay below).
|
// returns by right-edge hover (overlay below) — only while the
|
||||||
|
// width budget grants it (#17's collapse verdict stands here too).
|
||||||
ZStack(alignment: .trailing) {
|
ZStack(alignment: .trailing) {
|
||||||
editorColumn
|
editorColumn
|
||||||
|
if showsMentor {
|
||||||
FocusOverlayPanel(edge: .trailing, panelWidth: DesignTokens.mentorWidth) {
|
FocusOverlayPanel(edge: .trailing, panelWidth: DesignTokens.mentorWidth) {
|
||||||
mentorColumn
|
mentorColumn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
if showsLibrary {
|
if showsLibrary {
|
||||||
|
|||||||
@@ -43,11 +43,13 @@ struct WorkspaceView: View {
|
|||||||
// a collapsed pane is not summoned by focus).
|
// a collapsed pane is not summoned by focus).
|
||||||
.overlay {
|
.overlay {
|
||||||
if gate.isFocused {
|
if gate.isFocused {
|
||||||
FocusOverlayPanel(edge: .leading, panelWidth: leftRevealWidth(geo)) {
|
// #17 verdict: the library reveal honors the width collapse.
|
||||||
|
let showsLibrary = geo.size.width >= 1100
|
||||||
|
FocusOverlayPanel(edge: .leading, panelWidth: leftRevealWidth(showsLibrary)) {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
navRail
|
navRail
|
||||||
paneBorder
|
paneBorder
|
||||||
if geo.size.width >= 1100 {
|
if showsLibrary {
|
||||||
PostsLibraryColumn(home: gate.museionHome, model: gate.posts)
|
PostsLibraryColumn(home: gate.museionHome, model: gate.posts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,10 +86,10 @@ struct WorkspaceView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The left reveal panel's width: rail + border (+ library when the window
|
/// The left reveal panel's width: rail + border (+ library when the
|
||||||
/// width still grants it — the unfocused verdict, not the focused budget).
|
/// unfocused width verdict grants it).
|
||||||
private func leftRevealWidth(_ geo: GeometryProxy) -> CGFloat {
|
private func leftRevealWidth(_ showsLibrary: Bool) -> CGFloat {
|
||||||
DesignTokens.railWidth + 1 + (geo.size.width >= 1100 ? DesignTokens.libraryWidth : 0)
|
DesignTokens.railWidth + 1 + (showsLibrary ? DesignTokens.libraryWidth : 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 1px contract border between rail and pane (`.rail { border-right }`).
|
/// 1px contract border between rail and pane (`.rail { border-right }`).
|
||||||
|
|||||||
Reference in new issue
Block a user