diff --git a/AGENTS.md b/AGENTS.md index 67edbee..2e90c3c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -149,6 +149,8 @@ Single-context: `GLOSSARY.md` + `docs/adr/` at the repo root. See `docs/agents/d ### Testing - Gate-running rules are encoded in `scripts/full-test.sh` (#190) — run `./scripts/full-test.sh start` + `status` polling (`summary` for the finished counts), never hand-rolled xcodebuild/xcresult incantations. The rest of this section is authoring rules the script cannot encode. +- macOS 27.2 (verified on 27.2.1) routes a drag to the DEEPEST destination — a LIVE NSTextView registers itself for drag types (a bare `NSTextView(frame:)` reads `registeredDraggedTypes == []`, so a standalone probe lies; lldb on the running app shows the list), matches Finder drags via `NSFilenamesPboardType`, and its stock `performDragOperation` pastes the file path; the window-level SwiftUI `.dropDestination` never fires over it — the inverse of the 27.0.1 ruling #141 was verified on. Drag routing is an OS-version claim: own the drop at the view (override the `NSDraggingDestination` methods without super) and re-dogfood after every OS point release; instrumented real handlers + one human drag settle which destination fires (#141 follow-up, 2026-12-03) +- A pin that drives a seam introduced WITH the fix has no broken-build past to fail on — drive the framework entry point itself (`DragInfoStub` for `NSDraggingDestination`, the scripted transport for the ACP wire), or the pin passes with the fix reverted (#141 follow-up, `image-drop-27-2-drag-routing-pastes-path`) - A model-owned real-clock ticker races a test's injected decisive ticks — a >1 s main-actor stall lets the live ticker complete a met goal first, flipping pins on elapsed-time text; give `start(...)` a `spawnsTicker: Bool = true` seam and opt machine tests out (#162) - Two FSEvent-burst rescans can double-count one shared `PostScanCache` miss (both snapshot the count before either stamps it) → `contentRevision` double-bumps, benign over-invalidation — tests pinning settled-state revision must quiesce the burst (stability loop ≥ the 0.5 s FSEvents latency) before snapshotting (#197) - A scripted transport double fires onCrash/onMessage BEFORE resuming the continuation it answers — resume-first lets the awaiting task close its assertion window (confirmation count 0) before the callback lands (#178) @@ -175,14 +177,15 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu | Date | Log | | --- | --- | -| 2026-12-03 | [20261203-release-011-apex-refresh-is-step-one_log.md](docs/devlog/20261203-release-011-apex-refresh-is-step-one_log.md) | -| 2026-12-01 | [20261201-release-010-readme-notes-packaging_log.md](docs/devlog/20261201-release-010-readme-notes-packaging_log.md) | -| 2026-11-30 | [20261130-external-watch-compares-unnormalized-text_log.md](docs/devlog/20261130-external-watch-compares-unnormalized-text_log.md) | -| 2026-11-23 | [20261123-home-repoint-retains-old-editor-target_log.md](docs/devlog/20261123-home-repoint-retains-old-editor-target_log.md) | -| 2026-11-19 | [20261119-issue200-gate-quit-time-flushes-through-departure-gate_log.md](docs/devlog/20261119-issue200-gate-quit-time-flushes-through-departure-gate_log.md) | -| 2026-11-17 | [20261117-acp-backpressure-defeats-timeout-and-shutdown_log.md](docs/devlog/20261117-acp-backpressure-defeats-timeout-and-shutdown_log.md) | -| 2026-11-17 | [20261117-issue193-split-fat-files-along-postsmodel-pattern_log.md](docs/devlog/20261117-issue193-split-fat-files-along-postsmodel-pattern_log.md) | -| 2026-11-17 | [20261117-issue192-collapse-gate-running-learnings-into-verify-rail-pointer_log.md](docs/devlog/20261117-issue192-collapse-gate-running-learnings-into-verify-rail-pointer_log.md) | -| 2026-11-17 | [20261117-issue197-repo-wide-swiftlint-green-documented-lint-contract_log.md](docs/devlog/20261117-issue197-repo-wide-swiftlint-green-documented-lint-contract_log.md) | -| 2026-11-17 | [20261117-issue190-full-test-verify-rail-pre-push-hook_log.md](docs/devlog/20261117-issue190-full-test-verify-rail-pre-push-hook_log.md) | +| 2026-12-03 | [20261203-image-drop-27-2-drag-routing-pastes-path_log.md](20261203-image-drop-27-2-drag-routing-pastes-path_log.md) | +| 2026-12-03 | [20261203-release-011-apex-refresh-is-step-one_log.md](20261203-release-011-apex-refresh-is-step-one_log.md) | +| 2026-12-01 | [20261201-release-010-readme-notes-packaging_log.md](20261201-release-010-readme-notes-packaging_log.md) | +| 2026-11-30 | [20261130-external-watch-compares-unnormalized-text_log.md](20261130-external-watch-compares-unnormalized-text_log.md) | +| 2026-11-23 | [20261123-home-repoint-retains-old-editor-target_log.md](20261123-home-repoint-retains-old-editor-target_log.md) | +| 2026-11-19 | [20261119-issue200-gate-quit-time-flushes-through-departure-gate_log.md](20261119-issue200-gate-quit-time-flushes-through-departure-gate_log.md) | +| 2026-11-17 | [20261117-acp-backpressure-defeats-timeout-and-shutdown_log.md](20261117-acp-backpressure-defeats-timeout-and-shutdown_log.md) | +| 2026-11-17 | [20261117-issue193-split-fat-files-along-postsmodel-pattern_log.md](20261117-issue193-split-fat-files-along-postsmodel-pattern_log.md) | +| 2026-11-17 | [20261117-issue192-collapse-gate-running-learnings-into-verify-rail-pointer_log.md](20261117-issue192-collapse-gate-running-learnings-into-verify-rail-pointer_log.md) | +| 2026-11-17 | [20261117-issue197-repo-wide-swiftlint-green-documented-lint-contract_log.md](20261117-issue197-repo-wide-swiftlint-green-documented-lint-contract_log.md) | + diff --git a/CHANGELOG.md b/CHANGELOG.md index d538834..aeb549d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format ## [Unreleased] +### Fixed + +- **editor:** Dropping an image file on the prose editor pastes the file path instead of ingesting it (#141 follow-up; macOS 27.2.1 dogfood 2026-12-03; unticketed fix) — #141 was field-verified on 27.0.1, where the window-level SwiftUI `.dropDestination` starved every deeper destination; 27.2 routes a drag to the DEEPEST destination, and a live NSTextView registers itself for drag types (it matches Finder drags through `NSFilenamesPboardType`), so its stock `performDragOperation` → `readSelection` pasted the path and the window destination never fired — the same for a markdown file dropped on the editor (path instead of guest). The editor text views now share a `FileDropTextView` base that owns the drops landing on them: URL-bearing drags route (never `super`) — the prose editor through the one new `AppGateState.routeFileDrop` (Cold Turkey guard → markdown → guest, anything else → `ingestDrop`), which the window destination also uses for drops landing outside the editor (one router, one surface per drag; a landed drop hops to Posts as markdown always did); the outline rows have no route and bounce instead of pasting the path; text-only drags keep the stock drop; URL-less drags bounce. The pasteboard probe is memoized per `changeCount` (a 20k-URL drag measured 137 ms per mouse-move uncached). `ingestDrop` refuses web URLs loudly with the type strip (a browser image drag has no file to copy), and a file that vanished between drag and drop refuses as missing, not as a folder. +9 tests — the drag overrides driven through a real `NSDraggingInfo` mock (a Finder-shaped drag routes and never pastes the path, an unrouted view claims nothing, a text drag keeps the stock drop, raw image data bounces, the probe follows the pasteboard, the outline rows bounce, web URLs and vanished files refuse with the right notice) and the router's own pins (guest, Cold Turkey refusal, ingest hand-off, mixed refusal); all 9 flip-verified. Verified with one real Finder drag on 27.2.1. Suite 729 + ## [0.1.1] - 2026-12-03 Human-readable notes: [docs/releases/0.1.1.md](docs/releases/0.1.1.md). diff --git a/Museion/AGENTS.md b/Museion/AGENTS.md index 08fdb9b..c17391c 100644 --- a/Museion/AGENTS.md +++ b/Museion/AGENTS.md @@ -23,7 +23,7 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro The map and the contracts, one bullet per file. Pin-level detail lives in the test files' scenario headers (see MuseionTests/AGENTS.md); devlog narratives in `docs/devlog/`. - `DesignTokens.swift` — palette/geometry. Two-color world, live-calibrated (deliberate departure from the export palette): `background` #FAF9F3 (chrome + focus ground), `surface` #FFFEFB (one page color for edit AND read); light-only, the single semantic exception `readyGreen` (the mentor ready dot — a meaning, never a style color). Radius 10; column widths rail 56 / library 232 / mentor 356; chat face constructors `valkyrie`/`concourse`/`ubuntuMono` (Font.custom falls back to system). -- `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` (markdown only → external guest): ONE window-level destination is the whole routing surface under this hosting — nested editor-level SwiftUI destinations and NSTextView drag registrations starve (field-verified); a mixed md+image set refuses loudly. 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). +- `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`. - `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. @@ -32,7 +32,7 @@ The map and the contracts, one bullet per file. Pin-level detail lives in the te - `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/Trash; the Archive pane reuses it. - `PostLibrary.swift` — `Post` + `Post.scan`: two-level scan over `projects///post.md` AND `archive///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` gated on `Micropub.trustworthyURL` — imported YAML rides verbatim, so hostile values scan nil. - `PostFrontmatter.swift` — #180: the Post frontmatter codec — the ONE lenient read (`parse`/`split`/`decoded`) 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), update-keys (`updating` — the in-place line-walk, every other line byte-identical). 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. -- `PostStore.swift` — write side (nonisolated). Shared slug (lowercase, diacritic-fold, strip punctuation, whitespace→hyphens, keep CJK, 80-char cap); collision suffixes over the GLOBAL slug space (projects + archive — an archived slug is never reused), all comparisons through `folded` = NFC + lowercase (APFS is case- and normalization-insensitive); `folder(of:home:)` is the ONE id→folder resolver — write paths derive their target from the id alone. `writeNew` defaults `type: .post` / `origin: .writer` (session-born pieces pass `.ai`, immutable). `overwrite` preserves type/pass_state/origin and updates owned keys IN PLACE via the codec's update posture — block rewrites erase captured stats and foreign frontmatter. `rename` = retitle + move within the same parent. `importFile` copies (never moves), strips BOM + normalizes CRLF→LF at the boundary, external YAML keys verbatim with our `type`/`pass_state`/`origin` winning. Project ops (`move`/`archive`/`restore`/`unarchiveProject`/`createProject`) derive current state from the resolved DISK path, never the scan snapshot; post.md bytes are never rewritten by them; `createProject` validates names (empty/slash/dot/`:`/control + case-insensitive duplicates throw). Pass substrate: `snapshotPass` (pre-pass body verbatim to `passes/pass-.md`, fixed name per type), `advancePassState` (monotonic, in-place stamp; also ticks the decay clock — a failed tick never fails a pass). `writeResearchNote` is the ONLY path to `research/` (a symlinked dir refuses). `captureFirstDraftStats` — eligibility is the codec's named `isCaptureEligible` predicate over the file's own frontmatter; failure never fails the pass. `ingestImage` copies into `assets/`, publishable types only (what can't ship can't enter); `illustrationRef` is the one `![alt](assets/…)` builder. +- `PostStore.swift` — write side (nonisolated). Shared slug (lowercase, diacritic-fold, strip punctuation, whitespace→hyphens, keep CJK, 80-char cap); collision suffixes over the GLOBAL slug space (projects + archive — an archived slug is never reused), all comparisons through `folded` = NFC + lowercase (APFS is case- and normalization-insensitive); `folder(of:home:)` is the ONE id→folder resolver — write paths derive their target from the id alone. `writeNew` defaults `type: .post` / `origin: .writer` (session-born pieces pass `.ai`, immutable). `overwrite` preserves type/pass_state/origin and updates owned keys IN PLACE via the codec's update posture — block rewrites erase captured stats and foreign frontmatter. `rename` = retitle + move within the same parent. `importFile` copies (never moves), strips BOM + normalizes CRLF→LF at the boundary, external YAML keys verbatim with our `type`/`pass_state`/`origin` winning. Project ops (`move`/`archive`/`restore`/`unarchiveProject`/`createProject`) derive current state from the resolved DISK path, never the scan snapshot; post.md bytes are never rewritten by them; `createProject` validates names (empty/slash/dot/`:`/control + case-insensitive duplicates throw). Pass substrate: `snapshotPass` (pre-pass body verbatim to `passes/pass-.md`, fixed name per type), `advancePassState` (monotonic, in-place stamp; also ticks the decay clock — a failed tick never fails a pass). `writeResearchNote` is the ONLY path to `research/` (a symlinked dir refuses). `captureFirstDraftStats` — eligibility is the codec's named `isCaptureEligible` predicate over the file's own frontmatter; failure never fails the pass. `ingestImage` copies into `assets/`, publishable types only (what can't ship can't enter; a file the disk can't stat refuses as `missing`, never as a folder); `illustrationRef` is the one `![alt](assets/…)` builder. - `DraftStats.swift` — the four unaided-first-draft metrics (burstiness, typeTokenRatio, sentenceVariation, trigramRepetition), pure and never NaN; `words(in:)` is the ONE word-count rail (Cold Turkey counts with it — text metrics can never drift). - `WritingGoal.swift` — the pure goal engine (no UI, no clock): `now` injected, `isMet` live and unlatched (deleting below target un-mets). - `WritingLockState.swift` — the lock machine + kiosk: 1 s ticker + per-keystroke `feed(text:)` drive the goal run, `tick(at:)` completes on the first met tick; kiosk = the 6-option combo recipe, enter/exit replay only what entry toggled, exit clears options FIRST; ⌘W/⌃⌘F/⌘N refusals = a local keyDown monitor matched by KEY CODE + exact modifier set + lowercased character net (charactersIgnoringModifiers is layout- and Caps-Lock-dependent); hosted-test guard = full no-op (never kiosk the test machine); nothing persists — the block dies with the session. `WritingLockAppDelegate` (same file) owns BOTH quit refusals: #162 asks once while a block holds; #200 gates quit-time document departure FIRST (never walk away from a block the quit then refuses to complete) — `quitReply(posts:)` is the pure decision (nil posts passes; the pins inject here), the one spoken refusal alert is hosted-guarded like the kiosk. @@ -48,8 +48,9 @@ The map and the contracts, one bullet per file. Pin-level detail lives in the te - `OutlineTree.swift` — the one-file plain nested-bullet tree model (ADR-0013): lenient parse, canonical serialize, normalize on save (preamble verbatim, stray prose after the first item drops); `parsesWithLoss` shares `parseItem` so detector and parser never disagree; structural ops are path-addressed, id-preserving, boundary-nil; single-node moves CROSS parents at sibling boundaries (LogSeq-style); `enter` = split/outdent/new-sibling; `extract`/`insertRun` are the drag primitives; `headingsLadderBody` = the Convert transform. Folds live in the view, keyed by node UUID. - `OutlineEditorView.swift` — `OutlinePresenter` (pure projection: visible rows, fold skipping, zoom re-basing at a node's children, block selection, `applyBatch` sibling-only moves) + the SwiftUI surface: chrome bullets by depth, per-depth rails, ONE promoted `OutlineRowTextView` on the focused row, drag grip + drop chrome, zoom breadcrumbs, Esc stack (drag-cancel → selection-collapse → zoom-out). **Esc needs a local NSEvent keyDown monitor** — SwiftUI's hosting layer swallows Esc before keyDown AND before `.onExitCommand` (probe-pinned in EscEventProbeTests). Every keystroke serializes the whole tree through the existing session machinery; zoom/drag state is view-only, reset on load. - `OutlineDrag.swift` — drag plumbing: NSEvent monitors (global outside the app, so an Esc-cancel never resolves as a drop); the gesture holds STRONG arm-time captures (a mid-drag scroll can drop the origin row's catcher — mouse-up must still clear state); live geometry from `CatcherView.rowFrames` reading CURRENT window-space frames (SwiftUI 27 removed the `.window` coordinate space; cached frames go stale on scroll); the pure drop math (`DropTarget`, `draggedIDs`, `isValidDrop`, `applyDrop`, `hitTestDrop`) rides a nonisolated presenter extension — resolved by id AFTER extraction. -- `OutlineRowTextView.swift` — the promoted row editor: borderless NSTextView, native undo/IME, keyDown intercepts (every intercepted branch returns WITHOUT super), echo-guard update, `sizeThatFits` floors at 21 (no focus jump). -- Editor core — `ProsePresenter.swift` (line-kind → attributes map mirroring the reading surface; plain store stays the source of truth — presentation-only attributes, ADR-0010). `EditorSession.swift` — per-document session: `SessionTarget` (post | external file), ~1 s debounce → `flush` (⌘S / selection change / quit also flush); externals write in place with NO sidecar; `loadFailed` never opens a writable empty session over a failed read (the first keystroke would destroy the file); the #67 conflict raises when disk ≠ last-flushed ≠ local, and the debounce never fires while the alert is unanswered; `adoptText` = programmatic writer-consented adoption (the #67 guard is the CALLER's job). Cursor sidecar `.museion-state.json` in the piece folder, written separately (a failed sidecar is not a failed save). `PostEditorView`/`ProseTextView` — plain NSTextView representable, loads keyed by `loadGeneration` (never per keystroke); spellcheck off by default (markdown on disk carries the spelling). +- `OutlineRowTextView.swift` — the promoted row editor: borderless NSTextView, native undo/IME, keyDown intercepts (every intercepted branch returns WITHOUT super), echo-guard update, `sizeThatFits` floors at 21 (no focus jump). Rides `FileDropTextView` with no route mounted: a file drag landing on a row bounces (no path paste). +- `FileDropTextView.swift` — the editor text views' drag base (macOS 27.2.1 routing): a live NSTextView registers itself for drag types and receives the drag a window-level SwiftUI destination never sees; URL-bearing drops route through `onFileDrop` (nil = bounce), text-only drops keep the stock drop, everything else bounces — never `super` for URLs (stock NSTextView pastes the dropped file's PATH via `readSelection` on NSFilenamesPboardType). The pasteboard probe is memoized per `changeCount` (`draggingUpdated` fires per mouse-move). +- Editor core — `ProsePresenter.swift` (line-kind → attributes map mirroring the reading surface; plain store stays the source of truth — presentation-only attributes, ADR-0010). `EditorSession.swift` — per-document session: `SessionTarget` (post | external file), ~1 s debounce → `flush` (⌘S / selection change / quit also flush); externals write in place with NO sidecar; `loadFailed` never opens a writable empty session over a failed read (the first keystroke would destroy the file); the #67 conflict raises when disk ≠ last-flushed ≠ local, and the debounce never fires while the alert is unanswered; `adoptText` = programmatic writer-consented adoption (the #67 guard is the CALLER's job). Cursor sidecar `.museion-state.json` in the piece folder, written separately (a failed sidecar is not a failed save). `PostEditorView`/`ProseTextView` — plain NSTextView representable, loads keyed by `loadGeneration` (never per keystroke); spellcheck off by default (markdown on disk carries the spelling). `ProseListTextView` rides `FileDropTextView` with `onFileDrop` → the gate's `routeFileDrop`, so file drags landing on it ingest (never paste the path); `lastIngestNotice` is the refusal text the pins read. - Prose list machinery — `ProseList.swift` (pure item scan/mutation over the plain buffer; every structural edit is ONE range replacement = single undo step); `ProseListTextView.swift` — folds are VIEW state (buffer never changes; hidden scopes styled via `foldedAttributes`), re-keyed to the nearest same-marker parent, dying when the marker text vanishes; single-line edits re-key in place (`rekey`), the newline gate is `\.isNewline` NEVER literal `\n`/`\r` compares (a CRLF pair is one grapheme); wholesale restyles self-heal into the full pass via a font probe. Fold chrome renders as tiny per-glyph CALayers in a click-through overlay — NEVER a document-sized bitmap. Image drops bridge through `ProseDropBridge` into `ingestDrop` (saved posts only, publishable files only, PLAIN files only — a dropped symlink refuses); the drop point is solved by the pure `dropIndex` (sampling + bracket + binary search; the SwiftUI closure's `location` is unusable under this hosting, off-screen rects return garbage). - Settings — `SettingsPaneView.swift` (sidebar + detail: Content · Pass 1 · Pass 2 · Chat · Provider Keys; the pane takes the gate's `binaryPath` and hydrates at open; detail forms left-anchored). `SettingsModel.swift` — #181: `ModelProvider` is the provider-descriptor TABLE — label, effort ladder, flagship, default endpoint, env var, wire `dialect` (chat/models paths + the SSE decoder selector), `authMode` (Bearer vs Anthropic's header pair), `keyless` (nous rides the shared Portal login); the keyless UI branch, the probe's selectors, and both credential consumers key off it. `ProviderCredential` = the ONE credential resolution (provider key, else the Portal session key for keyless providers — official endpoint ONLY, never a user-set URL) serving Test Connection and pass readiness. Writes COALESCE: the newer write queues past an in-flight one, superseded writes never spawn (partial key prefixes of a secret never reach `.env`); `hydrate` reads only and never stomps a pending edit. `HermesSettingsWriter.swift` — the real write path: surface writes and the base_url write-through ride the HermesConfigRail (#182 — the writer only builds its key list: provider, default, effort set-or-unset, base_url LAST); provider keys upsert into ALL THREE profiles' `.env` (foreign lines byte-preserved, 0600, line-broken values REFUSED — env injection; paths via ProfileLayout). `ProviderProbe.swift` — Test Connection: every request carries `Content-Type: application/json` (without it z.ai answers 200 with an error envelope); per-provider dialects (OpenAI speaks the Responses API, Anthropic `x-api-key` + pinned version + required max_tokens, zai thinking+reasoning_effort, nous plain chat-completions) — #181: URL paths, auth shape, and the SSE decoder SELECT by the descriptor's dialect, the per-dialect code stays separate functions; 512 token cap; errors riding a 2xx decode as the provider error. `onChatSurfaceWrite` → `requestRestart` (chat surface only — pass engines are one-shot). `PassReadiness.swift` — #181: the per-surface readiness module (ready / missingKey / unknown): reads each surface's provider + `.env` key through the settings seam and resolves credentials through `ProviderCredential` (the keyless fallback included); MentorSessionModel stores the verdicts and reads no keys or auth files itself. - Focus mode — transient per-launch (no persistence); `FocusChrome` hover zones + overlay panels float over the measure, never push it; `CaretCentering` is EDITOR-WIDE, not focus-gated; focus × reading are orthogonal axes. Cold Turkey chrome (`ColdTurkeySeat`/`ColdTurkeyDot`) mounts as overlays on the focused branch only. diff --git a/Museion/FileDropTextView.swift b/Museion/FileDropTextView.swift new file mode 100644 index 0000000..065d848 --- /dev/null +++ b/Museion/FileDropTextView.swift @@ -0,0 +1,89 @@ +// +// FileDropTextView.swift +// Museion +// +// #141 (macOS 27.2.1): a drag goes to the DEEPEST destination, and a live +// NSTextView registers itself for drag types — so a file drag landing on +// an editor text view is delivered to the view, not to the window-level +// SwiftUI .dropDestination (the inverse of the 27.0.1 ruling #141 was +// verified on). Stock NSTextView handling pastes the dropped file's PATH +// (`readSelection` on NSFilenamesPboardType). This base replaces that for +// URL-bearing drags and leaves text-only drags to the stock behavior. The +// prose editor routes through the gate's one router (`AppGateState. +// routeFileDrop`); the outline rows have no route and bounce. +// + +import AppKit + +class FileDropTextView: NSTextView { + /// Where a URL-bearing drop routes. Nil = the view claims nothing + /// (outline rows: images don't ingest there, so the drag bounces + /// instead of pasting a path). + var onFileDrop: (([URL]) -> Bool)? + + /// One classification per pasteboard state — `draggingUpdated` fires on + /// every mouse-move and the read is a pasteboard round-trip (a hostile + /// 20k-URL drag measured 137 ms per move uncached). + private var dropProbe: (changeCount: Int, kind: DropKind)? + + enum DropKind: Equatable { + /// File URLs (Finder) or web URLs (browser) — routed, never pasted. + case urls([URL]) + /// Text only (a selection drag, text from another app) — the stock + /// NSTextView drop, which inserts text and nothing else. + case text + /// Raw image data, file promises — anything URL-less and text-less. + case none + } + + /// The drag's URLs — or nil when it carries none. + static func droppedURLs(from pasteboard: NSPasteboard) -> [URL]? { + let urls = pasteboard.readObjects(forClasses: [NSURL.self], options: nil) as? [URL] ?? [] + return urls.isEmpty ? nil : urls + } + + static func classify(_ pasteboard: NSPasteboard) -> DropKind { + if let urls = droppedURLs(from: pasteboard) { + return .urls(urls) + } + return pasteboard.types?.contains(.string) == true ? .text : .none + } + + /// `classify`, memoized on the pasteboard's changeCount. + func dropKind(of pasteboard: NSPasteboard) -> DropKind { + if let dropProbe, dropProbe.changeCount == pasteboard.changeCount { + return dropProbe.kind + } + let kind = Self.classify(pasteboard) + dropProbe = (pasteboard.changeCount, kind) + return kind + } + + override func draggingEntered(_ sender: any NSDraggingInfo) -> NSDragOperation { + switch dropKind(of: sender.draggingPasteboard) { + case .urls: onFileDrop != nil ? .copy : [] // accept so a refusal stays LOUD + case .text: super.draggingEntered(sender) + case .none: [] + } + } + + override func draggingUpdated(_ sender: any NSDraggingInfo) -> NSDragOperation { + switch dropKind(of: sender.draggingPasteboard) { + case .urls: onFileDrop != nil ? .copy : [] + case .text: super.draggingUpdated(sender) + case .none: [] + } + } + + override func performDragOperation(_ sender: any NSDraggingInfo) -> Bool { + switch dropKind(of: sender.draggingPasteboard) { + case let .urls(urls): onFileDrop?(urls) ?? false + case .text: super.performDragOperation(sender) + case .none: false + } + } + + /// Nothing to conclude — the ingest leaves the scroll stack as a + /// keystroke would. + override func concludeDragOperation(_: (any NSDraggingInfo)?) {} +} diff --git a/Museion/MuseionApp.swift b/Museion/MuseionApp.swift index 7a088d7..b44db2a 100644 --- a/Museion/MuseionApp.swift +++ b/Museion/MuseionApp.swift @@ -16,11 +16,9 @@ import SwiftUI @MainActor @Observable final class AppGateState { - /// #141: the live prose text view — the window-level drop destination - /// (the ONLY destination that ever fires; nested editor-level SwiftUI - /// targets are never consulted, and AppKit views registered for file - /// drags are starved by it — field-verified 2026-11-02) routes image - /// drops to the editor through this handle. + /// #141: the live prose text view — the window-level SwiftUI destination + /// (drops landing OUTSIDE the editor) reaches it through this handle; + /// routing lives in `routeFileDrop`. let proseDrop = ProseDropBridge() let gateModel = EngineGateModel() let provisioning = ProvisioningModel() @@ -118,6 +116,23 @@ final class AppGateState { } } } + + /// #91 + #141 — the ONE file-drop router. Two surfaces reach it, never + /// both for one drag (27.2 routing: the editor's text view when the + /// pointer is over it, the window-level SwiftUI destination elsewhere): + /// a PURE-markdown set opens as the guest; anything else goes to the + /// open piece's prose ingest, which refuses loudly (drafts, mixed + /// md+image sets, non-publishable or non-file URLs). + /// #162: no new buffers while a Cold Turkey block holds. + func routeFileDrop(_ urls: [URL]) -> Bool { + guard !writingLock.isLocked else { return false } + if urls.allSatisfy(PostStore.isMarkdown), let url = urls.first { + posts.openExternal(url) + return true + } + guard let textView = proseDrop.textView else { return false } + return textView.ingestDrop(urls) + } } /// #23: no `@main` here — MuseionLauncher (MCPServer.swift) branches diff --git a/Museion/OutlineRowTextView.swift b/Museion/OutlineRowTextView.swift index 6e4a73f..e06ff33 100644 --- a/Museion/OutlineRowTextView.swift +++ b/Museion/OutlineRowTextView.swift @@ -127,8 +127,11 @@ struct OutlineRowTextView: NSViewRepresentable { } } -/// The row NSTextView: structural key interception. -final class RowTextView: NSTextView { +/// The row NSTextView: structural key interception. `FileDropTextView` +/// base (27.2 routing): a file drag landing on a row bounces instead of +/// pasting the path — images don't ingest into outlines (#141); text +/// drags keep the stock drop. +final class RowTextView: FileDropTextView { weak var bridge: OutlineRowTextView.Coordinator? override func keyDown(with event: NSEvent) { diff --git a/Museion/PostEditorView.swift b/Museion/PostEditorView.swift index c04349d..14ce782 100644 --- a/Museion/PostEditorView.swift +++ b/Museion/PostEditorView.swift @@ -182,6 +182,7 @@ struct PostEditorView: View { focused: gate.isFocused, caretHint: flipBackCaret, dropBridge: gate.proseDrop, + routeDrop: { gate.routeFileDrop($0) }, // #162: the Cold Turkey word feed. onTextChange: { gate.writingLock.feed(text: $0) }, ) @@ -196,6 +197,7 @@ struct PostEditorView: View { }, caretHint: flipBackCaret, dropBridge: gate.proseDrop, + routeDrop: { gate.routeFileDrop($0) }, // #162: the Cold Turkey word feed. onTextChange: { gate.writingLock.feed(text: $0) }, ) @@ -338,8 +340,8 @@ private struct SaveStateDot: View { // MARK: - TextKit2 surface (the lifted spike pane) -/// #141: the SwiftUI drop target's handle down to the live prose text -/// view (weak — dies with the editor surface). +/// #141: the window-level SwiftUI destination's handle down to the live +/// prose text view (weak — dies with the editor surface). @MainActor final class ProseDropBridge { weak var textView: ProseListTextView? @@ -366,10 +368,11 @@ struct ProseTextView: NSViewRepresentable { /// only (drafts have no folder until first save; the external guest /// isn't a piece). Nil = image drags refuse loudly. var ingestFolder: URL? - /// #141: the drop bridge — the WINDOW-level SwiftUI drop target - /// reaches this text view through it (app-scoped, passed down from - /// the gate at both call sites — never optional). + /// #141: the window-level SwiftUI destination's handle to the live + /// view (drops landing OUTSIDE the editor); the gate's router for drops + /// landing ON it — both handed down from the gate at both call sites. var dropBridge: ProseDropBridge + var routeDrop: ([URL]) -> Bool init( session: EditorSession, @@ -377,6 +380,7 @@ struct ProseTextView: NSViewRepresentable { focused: Bool = false, caretHint: (location: Int, token: Int)? = nil, dropBridge: ProseDropBridge, + routeDrop: @escaping ([URL]) -> Bool, onTextChange: ((String) -> Void)? = nil, ) { self.session = session @@ -386,6 +390,7 @@ struct ProseTextView: NSViewRepresentable { self.onTextChange = onTextChange ingestFolder = session.postID != nil ? session.folderURL : nil self.dropBridge = dropBridge + self.routeDrop = routeDrop } init( @@ -395,6 +400,7 @@ struct ProseTextView: NSViewRepresentable { onEdit: @escaping (String) -> Void, caretHint: (location: Int, token: Int)? = nil, dropBridge: ProseDropBridge, + routeDrop: @escaping ([URL]) -> Bool, onTextChange: ((String) -> Void)? = nil, ) { self.draft = draft @@ -404,6 +410,7 @@ struct ProseTextView: NSViewRepresentable { self.caretHint = caretHint self.onTextChange = onTextChange self.dropBridge = dropBridge + self.routeDrop = routeDrop } /// Cursor state snapshot from the live view (#66). @@ -430,7 +437,8 @@ struct ProseTextView: NSViewRepresentable { func makeNSView(context: Context) -> NSScrollView { let tv = ProseListTextView() // #115: list shortcuts + folds on the plain surface tv.ingestFolder = ingestFolder // #141: image-drop ingest (nil on drafts/guests) - dropBridge.textView = tv // #141: the SwiftUI drop target's handle + dropBridge.textView = tv // #141: the window destination's handle + tv.onFileDrop = routeDrop // #141: the view's own drag handlers route here tv.isRichText = false // plain source of truth; attributes are presentation tv.allowsUndo = true tv.isAutomaticQuoteSubstitutionEnabled = false @@ -485,6 +493,7 @@ struct ProseTextView: NSViewRepresentable { tv.isContinuousSpellCheckingEnabled = spellChecking tv.ingestFolder = ingestFolder // #141: cheap idempotent set dropBridge.textView = tv // #141: idempotent re-point + tv.onFileDrop = routeDrop // #141: idempotent re-point // #21: the ground follows focus in/out without a remount. let ground = focused ? NSColor(DesignTokens.background) : NSColor(DesignTokens.surface) tv.backgroundColor = ground diff --git a/Museion/PostStore.swift b/Museion/PostStore.swift index 46d64a5..a3430e6 100644 --- a/Museion/PostStore.swift +++ b/Museion/PostStore.swift @@ -756,6 +756,12 @@ struct IngestError: LocalizedError { IngestError(message: "“\(name.prefix(40))” is a folder, not an image.") } + /// A file the drag named but the disk can no longer stat — moved or + /// deleted between drag and drop (or a URL that never was a file). + static func missing(_ name: String) -> IngestError { + IngestError(message: "“\(name.prefix(40))” couldn’t be read — it may have moved since the drag began.") + } + /// assets/ exists as a symlink or a file — never write through it /// (research/promote posture: the #34 rail would refuse the send). static func hostileAssets() -> IngestError { @@ -790,10 +796,12 @@ nonisolated extension PostStore { // AS a link (finish-audit 2026-11-02), and the #34 rail then // refuses the whole send — nothing enters assets/ that can't ship. let values = try? source.resourceValues(forKeys: [.isDirectoryKey, .isSymbolicLinkKey]) - guard source.isFileURL, let values, - values.isDirectory != true, values.isSymbolicLink != true - else { - throw values?.isSymbolicLink == true ? IngestError.isLink(name) : IngestError.isFolder(name) + guard source.isFileURL, let values else { throw IngestError.missing(name) } + if values.isSymbolicLink == true { + throw IngestError.isLink(name) + } + if values.isDirectory == true { + throw IngestError.isFolder(name) } let assets = pieceFolder.appendingPathComponent("assets", isDirectory: true) if FileManager.default.fileExists(atPath: assets.path) { diff --git a/Museion/ProseListTextView.swift b/Museion/ProseListTextView.swift index 2eddd10..f86af00 100644 --- a/Museion/ProseListTextView.swift +++ b/Museion/ProseListTextView.swift @@ -71,7 +71,7 @@ final class ProseChromeView: NSView { } } -final class ProseListTextView: NSTextView { +final class ProseListTextView: FileDropTextView { /// A fold: the marker line's buffer position + its text (the re-key /// identity when an edit above shifts offsets) + the hidden scope /// (shift-maintained by the #142 cheap path; the full pass re-derives @@ -338,8 +338,10 @@ final class ProseListTextView: NSTextView { return firstRect(forCharacterRange: NSRange(location: charIndex, length: 1), actualRange: nil).midY } - /// #141's SwiftUI entry — the window `.dropDestination`'s perform - /// routes here after markdown forwarding is ruled out upstream. + /// #141's ingest entry — `AppGateState.routeFileDrop` routes here + /// from whichever surface took the drag (the text view's own drag + /// handlers over the editor, the window `.dropDestination` elsewhere) + /// after markdown forwarding is ruled out upstream. /// The drop point is read from the live pointer (NSEvent.mouseLocation /// — the SwiftUI closure's location proved unusable, dogfood 2026-11-02). /// Gates: saved piece, every file publishable (#34's mimeType set) — @@ -354,8 +356,10 @@ final class ProseListTextView: NSTextView { } // The publish-able set IS #34's mimeType gate — nothing the rail // can't ship ever enters assets/. A mixed md+image set refuses - // here too (only pure-markdown sets are forwarded upstream). - guard urls.allSatisfy({ Micropub.mimeType(forDestination: $0.lastPathComponent) != nil }) else { + // here too (only pure-markdown sets are forwarded upstream), and + // so does a web URL (a browser image drag): the extension may + // look publishable, but nothing is on disk to copy. + guard urls.allSatisfy({ $0.isFileURL && Micropub.mimeType(forDestination: $0.lastPathComponent) != nil }) else { showIngestNotice("Drop images (PNG, JPEG, GIF, WebP, SVG) or markdown — one kind at a time.") return false } @@ -416,7 +420,12 @@ final class ProseListTextView: NSTextView { private var ingestNotice: NSTextField? private var ingestNoticeHide: DispatchWorkItem? + /// The last refusal text — the observable the pins read (the strip + /// itself is private chrome). + private(set) var lastIngestNotice: String? + private func showIngestNotice(_ text: String) { + lastIngestNotice = text let strip: NSTextField if let ingestNotice { strip = ingestNotice diff --git a/Museion/WorkspaceView.swift b/Museion/WorkspaceView.swift index 7ba362e..d723517 100644 --- a/Museion/WorkspaceView.swift +++ b/Museion/WorkspaceView.swift @@ -56,27 +56,14 @@ struct WorkspaceView: View { } } } - // #91: drag a markdown file onto the window — same guest slot as - // File ▸ Open… Non-markdown drops are refused. + // #91/#141: drops landing OUTSIDE the editor (over the editor the + // text view takes the drag itself — FileDropTextView); one router. .dropDestination(for: URL.self) { urls, _ in - // #162: no new buffers while a Cold Turkey block holds — - // the open Piece is the one being counted. - guard !gate.writingLock.isLocked else { return false } - // #141: the window destination is the only one that ever - // fires (field-verified 2026-11-02 — nested editor-level - // SwiftUI targets are never consulted, and AppKit views - // registered for file drags are starved by it). - // PURE-markdown sets keep #91's open-as-guest; a mixed - // md+image set falls through and ingestDrop refuses it - // loudly (images must not vanish silently behind the md). - // Nil text view: bounce. - if urls.allSatisfy(PostStore.isMarkdown), let url = urls.first { - gate.posts.openExternal(url) + let landed = gate.routeFileDrop(urls) + if landed { selection = .posts - return true } - guard let textView = gate.proseDrop.textView else { return false } - return textView.ingestDrop(urls) + return landed } // #21: left-edge hover slides rail+library back in as an overlay. // Library only while the window width allows it (#17 verdict stands: diff --git a/MuseionTests/AGENTS.md b/MuseionTests/AGENTS.md index 7881c91..2869299 100644 --- a/MuseionTests/AGENTS.md +++ b/MuseionTests/AGENTS.md @@ -44,7 +44,7 @@ Conventions every suite follows. Per-suite pin inventories are NOT kept here — - `FixCardApplyTests` — fix-card apply/skip/done lifecycle. - `PostsModelTests`, `PassRunTests`, `BlindReadTests`, `EngineLifecycleTests`, `SessionLifecycleTests`, `SessionScopeTests`, `TranscriptRailTests` — model orchestration over the scripted in-process engine (#178): passes, blind read, per-surface engines, session lifecycle, scoped hosting, the typed transcript rail (#177 — speaker/notice type facts through the scripted engine, prefix-free invariant, append-seam classifiers), and the #179 write-rail pins in PostsModelTests (write → one library refresh + strip cleared; failed write owns the strip; nil-Home refuses cleanly; import batch keeps per-file strip messages; mid-pass Home repoint refuses the advance — `endHeldPrompt` is the rig hook that ends a held turn normally, polled to via `hasHeldPrompt` first: `runningPass` flips before the one-shot engine parks its prompt, so firing into that window false-fails under load). - `DeslopLintTests` (with the `DeslopLintWiringTests` member) — native lint findings, config story, emit loop. -- `EditorSessionTests`, `ReadingPresenterTests`, `ProsePresenterTests`, `FocusModeTests`, `ImportExternalTests`, `ImageIngestTests` — editor session, reading pipeline, editing-surface parity, focus math, import + image ingest. +- `EditorSessionTests`, `ReadingPresenterTests`, `ProsePresenterTests`, `FocusModeTests`, `ImportExternalTests`, `ImageIngestTests` — editor session, reading pipeline, editing-surface parity, focus math, import, image ingest + the 27.2 drag-routing seam (`DragInfoStub`, the suite's NSDraggingInfo mock: a Finder-shaped drag routes through the text view and never pastes the path; text-only drags keep the stock drop; outline rows bounce; the probe follows `changeCount`; web URLs and vanished files refuse with the right notice) + the one router's pins (guest, Cold Turkey refusal, ingest hand-off, mixed refusal). - `OutlineTreeTests`, `OutlinePresenterTests`, `OutlineDragTests`, `EscEventProbeTests` — outliner model, projection, drag plumbing, Esc delivery probe. - `ProseListTests`, `ProseRekeyTests` — prose list model + fold rendering, fold rekey pipeline. - `SettingsModelTests`, `SettingsModelWritePathTests`, `HermesSettingsWriterTests`, `ProviderProbeTests`, `ProviderProbeTransportTests`, `ProviderCredentialTests` — settings model, real CLI write path, probe decode + request builders, the #181 ONE credential resolution (pasted key wins, keyless fallback on the official endpoint, custom-endpoint and no-login refusals). diff --git a/MuseionTests/ImageIngestTests.swift b/MuseionTests/ImageIngestTests.swift index 86b4982..7ed7831 100644 --- a/MuseionTests/ImageIngestTests.swift +++ b/MuseionTests/ImageIngestTests.swift @@ -25,6 +25,66 @@ import Foundation @testable import Museion import Testing +/// The smallest NSDraggingInfo the drag overrides read: only the +/// pasteboard matters (the stock text drop also wants a destination view, +/// which the hosted text view supplies itself). +@MainActor +final class DragInfoStub: NSObject, NSDraggingInfo { + let draggingPasteboard: NSPasteboard + init(_ pb: NSPasteboard) { + draggingPasteboard = pb + } + + var draggingDestinationWindow: NSWindow? { + nil + } + + var draggingSourceOperationMask: NSDragOperation { + [.copy] + } + + var draggingLocation: NSPoint { + .zero + } + + var draggedImageLocation: NSPoint { + .zero + } + + var draggedImage: NSImage? { + nil + } + + var draggingSource: Any? { + nil + } + + var draggingSequenceNumber: Int { + 0 + } + + func slideDraggedImage(to _: NSPoint) {} + override func namesOfPromisedFilesDropped(atDestination _: URL) -> [String]? { + nil + } + + var draggingFormation: NSDraggingFormation = .none + var animatesToDestination = false + var numberOfValidItemsForDrop = 0 + func enumerateDraggingItems( + options _: NSDraggingItemEnumerationOptions, + for _: NSView?, + classes _: [AnyClass], + searchOptions _: [NSPasteboard.ReadingOptionKey: Any], + using _: @escaping (NSDraggingItem, Int, UnsafeMutablePointer) -> Void, + ) {} + var springLoadingHighlight: NSSpringLoadingHighlight { + .none + } + + func resetSpringLoading() {} +} + @MainActor struct ImageIngestTests { /// Throwaway Home + a saved post standing in for the open editor @@ -96,9 +156,10 @@ struct ImageIngestTests { #expect(!FileManager.default.fileExists(atPath: folder.appendingPathComponent("assets").path)) } - // MARK: - #141 drag-layer entry (ingestDrop — the SwiftUI drop + // MARK: - #141 drag-layer entry (ingestDrop — whichever surface took - // target's perform lands on the text view) + // the drag routes here: the text view's own handlers over the editor, + // the window SwiftUI destination elsewhere) @Test func `ingestDrop copies lands the ref and selects alt`() throws { let (_, folder) = try ingestHome() @@ -129,6 +190,189 @@ struct ImageIngestTests { #expect(try !draft.ingestDrop([imageSource("x.png")])) } + // MARK: - 27.2 drag routing (a drag goes to the deepest destination: + + // FileDropTextView owns drops that land on the editor — stock NSTextView + // handling would paste the file PATH) + + /// A Finder-shaped drag pasteboard: `public.file-url` plus the legacy + /// filenames type NSTextView registers for. + private func finderDragPasteboard(_ urls: [URL]) -> NSPasteboard { + let filenames = NSPasteboard.PasteboardType(rawValue: "NSFilenamesPboardType") + let pb = NSPasteboard(name: .drag) + pb.declareTypes([.fileURL, filenames], owner: nil) + pb.setString(urls[0].absoluteString, forType: .fileURL) + pb.setPropertyList(urls.map(\.path), forType: filenames) + return pb + } + + /// A live text view in a window (the stock text drop inserts only into + /// a hosted view). Caller orders the window out. + private func hostedView() -> (tv: ProseListTextView, win: NSWindow) { + let win = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 200, height: 200), styleMask: [.titled], backing: .buffered, defer: false) + let tv = ProseListTextView() + tv.string = "Body.\n" + win.contentView?.addSubview(tv) + win.makeFirstResponder(tv) + return (tv, win) + } + + /// A temp markdown file standing in for a dragged guest. + private func markdownSource() throws -> URL { + let md = FileManager.default.temporaryDirectory.appendingPathComponent("imageingest-\(UUID().uuidString).md") + try "# Guest\n".write(to: md, atomically: true, encoding: .utf8) + return md + } + + @Test func `a file drag landing on the text view routes, never pastes the path`() throws { + let (_, folder) = try ingestHome() + let (tv, win) = hostedView() + defer { win.orderOut(nil) } + tv.ingestFolder = folder + tv.onFileDrop = { [weak tv] in tv?.ingestDrop($0) ?? false } // the gate's router in miniature + let source = try imageSource("sketch.png") + let drag = DragInfoStub(finderDragPasteboard([source])) + + #expect(tv.draggingEntered(drag) == .copy) + #expect(tv.draggingUpdated(drag) == .copy) + #expect(tv.performDragOperation(drag)) + #expect(tv.string.contains("![alt](assets/sketch.png)")) + #expect(!tv.string.contains(source.path), "the stock path paste survived") + + // Unrouted (no handler mounted): a Finder drag claims nothing and + // pastes nothing. + let (bare, bareWin) = hostedView() + defer { bareWin.orderOut(nil) } + let bareDrag = DragInfoStub(finderDragPasteboard([source])) + #expect(bare.draggingEntered(bareDrag) == []) + #expect(!bare.performDragOperation(bareDrag)) + #expect(bare.string == "Body.\n") + } + + @Test func `a text-only drag keeps the stock drop and never reaches the router`() { + let (tv, win) = hostedView() + defer { win.orderOut(nil) } + var routed: [URL]? + tv.onFileDrop = { routed = $0; return true } + let pb = NSPasteboard(name: .drag) + pb.declareTypes([.string], owner: nil) + pb.setString("dropped text", forType: .string) + + #expect(FileDropTextView.classify(pb) == .text) + #expect(tv.draggingEntered(DragInfoStub(pb)) == .copy) + #expect(tv.performDragOperation(DragInfoStub(pb))) + #expect(tv.string.contains("dropped text")) + #expect(routed == nil) + + // URL-less AND text-less (raw image data from Photos/Preview): bounces. + let png = NSPasteboard(name: .drag) + png.declareTypes([.png], owner: nil) + #expect(tv.draggingEntered(DragInfoStub(png)) == []) + #expect(!tv.performDragOperation(DragInfoStub(png))) + #expect(tv.string.contains("dropped text")) + } + + @Test func `the drag probe follows the pasteboard contents, not its memory`() throws { + let (tv, win) = hostedView() + defer { win.orderOut(nil) } + let source = try imageSource("sketch.png") + let pb = finderDragPasteboard([source]) + #expect(tv.dropKind(of: pb) == .urls([source])) + // Same pasteboard object, new contents (changeCount moved): follows. + pb.declareTypes([.string], owner: nil) + pb.setString("now text", forType: .string) + #expect(tv.dropKind(of: pb) == .text) + pb.clearContents() + #expect(tv.dropKind(of: pb) == .none) + } + + @Test func `the outline rows bounce a file drag instead of pasting the path`() throws { + let win = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 200, height: 200), styleMask: [.titled], backing: .buffered, defer: false) + defer { win.orderOut(nil) } + let row = RowTextView() + row.string = "- item" + win.contentView?.addSubview(row) + let drag = try DragInfoStub(finderDragPasteboard([imageSource("sketch.png")])) + + #expect(row.draggingEntered(drag) == []) + #expect(!row.performDragOperation(drag)) + #expect(row.string == "- item") + } + + @Test func `a web URL refuses loudly with the type notice and plants nothing`() throws { + // A browser image drag reaches the router as an https URL — the + // extension looks publishable, but nothing is on disk to copy. The + // sink would refuse it too; only the isFileURL gate names the type. + let (_, folder) = try ingestHome() + let tv = ProseListTextView() + tv.string = "Body.\n" + tv.ingestFolder = folder + let web = try #require(URL(string: "https://example.com/cat.jpg")) + #expect(!tv.ingestDrop([web])) + #expect(tv.lastIngestNotice?.hasPrefix("Drop images") == true, "notice: \(tv.lastIngestNotice ?? "nil")") + #expect(!FileManager.default.fileExists(atPath: folder.appendingPathComponent("assets").path)) + } + + @Test func `a file that vanished after the drag refuses as missing, not as a folder`() throws { + let (_, folder) = try ingestHome() + let tv = ProseListTextView() + tv.string = "Body.\n" + tv.ingestFolder = folder + let gone = try imageSource("ghost.png") + try FileManager.default.removeItem(at: gone) + #expect(!tv.ingestDrop([gone])) + let notice = try #require(tv.lastIngestNotice) + #expect(notice.contains("couldn’t be read"), "notice: \(notice)") + #expect(!notice.contains("folder"), "notice: \(notice)") + #expect(!FileManager.default.fileExists(atPath: folder.appendingPathComponent("assets").path)) + } + + // MARK: - The one router (AppGateState.routeFileDrop) + + @Test func `the router opens a pure-markdown set as the guest`() throws { + let gate = AppGateState() + let md = try markdownSource() + defer { try? FileManager.default.removeItem(at: md) } + #expect(gate.routeFileDrop([md])) + #expect(gate.posts.externalSession != nil) + } + + @Test func `the router refuses everything while a Cold Turkey block holds`() throws { + let gate = AppGateState() + gate.posts.newPost() + gate.posts.draft?.text = "seed words here" + gate.startWritingLock(goal: .words(2)) + defer { + gate.writingLock.feed(text: "seed words here plus two more") + gate.writingLock.tick() + } + let md = try markdownSource() + defer { try? FileManager.default.removeItem(at: md) } + #expect(gate.writingLock.isLocked) + #expect(!gate.routeFileDrop([md])) + #expect(gate.posts.externalSession == nil) + } + + @Test func `the router hands non-markdown to the open piece's ingest`() throws { + let gate = AppGateState() + let (_, folder) = try ingestHome() + let source = try imageSource("sketch.png") + // No editor mounted: bounce. + #expect(!gate.routeFileDrop([source])) + let tv = ProseListTextView() + tv.string = "Body.\n" + tv.ingestFolder = folder + gate.proseDrop.textView = tv + #expect(gate.routeFileDrop([source])) + #expect(tv.string.contains("![alt](assets/sketch.png)")) + // A mixed md+image set reaches the ingest's loud refusal, never the guest. + let md = try markdownSource() + defer { try? FileManager.default.removeItem(at: md) } + #expect(try !gate.routeFileDrop([imageSource("second.png"), md])) + #expect(tv.lastIngestNotice?.hasPrefix("Drop images") == true) + #expect(gate.posts.externalSession == nil) + } + // MARK: - #141 finish-audit pins @Test func `a dropped symlink refuses with nothing planted`() throws { @@ -149,8 +393,8 @@ struct ImageIngestTests { } @Test func `a mixed image and markdown set refuses loudly`() throws { - // The window destination forwards only PURE-markdown sets (#91); - // a mixed set must reach this refusal, not vanish behind the md. + // The router forwards only PURE-markdown sets (#91); a mixed set + // must reach this refusal, not vanish behind the md. let (_, folder) = try ingestHome() let tv = ProseListTextView() tv.string = "Body.\n" diff --git a/MuseionTests/ProseRekeyTests.swift b/MuseionTests/ProseRekeyTests.swift index eaeeb53..a4a3fe1 100644 --- a/MuseionTests/ProseRekeyTests.swift +++ b/MuseionTests/ProseRekeyTests.swift @@ -322,7 +322,7 @@ extension ProseFoldRekeyTests { debounce: .seconds(3600), ) let coordinator = ProseTextView.Coordinator( - representable: ProseTextView(session: session, dropBridge: ProseDropBridge()), + representable: ProseTextView(session: session, dropBridge: ProseDropBridge(), routeDrop: { _ in false }), ) textView.delegate = coordinator // production wiring (PostEditorView) textView.setSelectedRange(NSRange(location: 0, length: 0)) diff --git a/docs/devlog/20261203-image-drop-27-2-drag-routing-pastes-path_log.md b/docs/devlog/20261203-image-drop-27-2-drag-routing-pastes-path_log.md new file mode 100644 index 0000000..91faf46 --- /dev/null +++ b/docs/devlog/20261203-image-drop-27-2-drag-routing-pastes-path_log.md @@ -0,0 +1,96 @@ +# Image drop pastes the file path on macOS 27.2 — the editor's text views now own drops that land on them (#141 follow-up) + +> **Date:** 2026-12-03 +> **Type:** generic +> **Reference:** follow-up to #141 (unticketed fix; dogfood on macOS 27.2.1) + +## Goal + +Alexander dropped a Finder screenshot onto a saved post and got the file PATH pasted as plain text — no `assets/` copy, no `![alt](…)` ref. #141 shipped exactly this feature (field-verified 2026-11-02 on macOS 27.0.1). Find out why it broke and restore it with ONE path that targets the current OS (his ruling: "adjust for the latest OS. no two paths"). Closed with a finish-audit (three fresh-context reviewers; findings and dispositions below). + +## What Was Done + +- **Diagnosis from evidence, not theory.** The unified log of the release build showed the drag pasteboard read as `public.file-url` only; the user's post on disk held three `![…](images/…png)` refs and no `assets/` (so `ingestImage` had never run). `softwareupdate --history` dated the OS jump: 27.0.1 → 27.2.1 on 2026-11-16, two weeks after #141's verification. Then ONE instrumented Debug build (temporary `Logger(subsystem: "com.babylondreams.Museion", category: "dropprobe")` lines in the SwiftUI closure + `NSDraggingDestination`/`readSelection`/`paste` overrides on the text view, read through `log stream`/`log show --level notice`) and one human drag settled it: + - `textview draggingEntered → copy` … `performDragOperation BEGIN` → `readSelection type=NSFilenamesPboardType → true` → `performDragOperation → true` + - NO `swiftui destination fired`, NO `ingestDrop entry`. + - lldb on the live app (`expr -l Swift -- let $ws = NSApp.windows …`) showed the `ProseListTextView` registered for ~19 drag types (NSFilenames, Apple URL, TIFF, PNG, RTF, RTFD, file-promise …) — NSTextView registers itself once live; a bare `NSTextView(frame:)` probe reads `[]`, even inside a window. +- `FileDropTextView.swift` (NEW) — the editor text views' drag base: `onFileDrop: (([URL]) -> Bool)?`; `DropKind` (`urls` / `text` / `none`) classified from the pasteboard (`readObjects(forClasses: [NSURL.self])`, else the string type), memoized per `changeCount`; the `NSDraggingDestination` overrides route URL-bearing drags (never `super` — the stock path paste lives there), hand text-only drags to the stock drop, bounce the rest. `ProseListTextView` and the outliner's `RowTextView` ride it (rows mount no route → bounce). +- `MuseionApp.swift` — `AppGateState.routeFileDrop(_:)`: the ONE file-drop router (Cold Turkey guard → pure-markdown set → `posts.openExternal` → else `proseDrop.textView?.ingestDrop`). `proseDrop` is documented as the window destination's handle. +- `ProseListTextView.swift` — `lastIngestNotice` test seam (the refusal text the pins read); `ingestDrop`'s publishable gate requires `isFileURL` (a browser image drag refuses with the type strip instead of reaching the sink). +- `PostStore.swift` — `IngestError.missing(_:)`: a file the disk can't stat refuses as missing ("couldn't be read"), never as a folder; the sink's guards are three flat checks (missing / link / folder). +- `PostEditorView.swift` — `ProseTextView` gains a non-optional `routeDrop: @escaping ([URL]) -> Bool` beside `dropBridge`; `makeNSView`/`updateNSView` set `tv.onFileDrop = routeDrop`. Both `PostEditorView` call sites pass `{ gate.routeFileDrop($0) }`; `ProseRekeyTests`' direct construction passes `{ _ in false }`. +- `WorkspaceView.swift` — the window `.dropDestination` is four lines: `let landed = gate.routeFileDrop(urls); if landed { selection = .posts }; return landed`. The hop now fires on every landed drop, not only markdown — unreachable for images today (the editor mounts only on Posts). +- `MuseionTests/ImageIngestTests.swift` — `DragInfoStub`, the suite's `NSDraggingInfo` mock (pasteboard-only; the stock text drop inserts only into a hosted view). +9 pins: a Finder-shaped drag routes through the view and never pastes the path (and an unrouted view claims nothing); a text-only drag keeps the stock drop and never reaches the router (raw PNG data bounces); the probe follows the pasteboard contents; the outline rows bounce a file drag; a web URL refuses with the type notice; a vanished file refuses as missing; and the router's own pins (pure-markdown → guest, Cold Turkey refusal, ingest hand-off + mixed refusal). +- DOX: `Museion/AGENTS.md` (WorkspaceView, editor-core, OutlineRowTextView + the new FileDropTextView bullet, PostStore), `MuseionTests/AGENTS.md` (suite map), root `AGENTS.md` (learning: 27.2 drag routing is an OS-version claim), `CHANGELOG.md` `[Unreleased]` Fixed entry. + +## Decisions & Rationale + +| Decision | Rationale | +|----------|-----------| +| Target 27.2.1 only — no dual-surface compat for 27.0.1 | Alexander's ruling mid-session ("adjust for the latest OS. no two paths"); the repo already targets what the maintainer runs. The 27.0.1 "window destination starves everything" contract is deleted from the docs, not carried. | +| The view under the pointer owns the drop; ONE router behind both surfaces | AppKit delivers a drag to exactly one destination. Over the editor that is the text view (deepest, self-registered); elsewhere it is the window SwiftUI destination. Both call `routeFileDrop`, so the md→guest / image→ingest decision exists once and can never drift between surfaces. | +| Override the `NSDraggingDestination` methods without `super` for URL-bearing drags | The paste is the stock implementation (`performDragOperation` → `readSelection(NSFilenamesPboardType)`); accepting the drag and then refraining from pasting is not an option — the paste happens inside super. | +| Text-only drags keep the stock drop (`case .text: super…`) | Finish-audit (security + general): a blanket `[]` for URL-less drags had killed in-editor selection moves and text drops from other apps — a regression the fix itself introduced. The path paste needs file URLs, which never reach super. | +| One `FileDropTextView` base for the prose editor AND the outline rows | Finish-audit (general): `RowTextView` had the identical 27.2 exposure and the CHANGELOG claimed outlines refuse. One implementation, two subclasses, zero duplication; rows mount no route → bounce. | +| Accept every URL-bearing drag in `draggingEntered` (`copy`), refuse in `performDragOperation` | `.none` at entry bounces silently; #141's contract is a LOUD refusal (the rust strip). Web URLs ride the same gate. URL-less, text-less drags (raw image data) bounce — nothing to route. | +| Memoize the probe per `pasteboard.changeCount` | Finish-audit (security, measured): `draggingUpdated` fires per mouse-move and `readObjects` is a pasteboard round-trip — 5k URLs → 38 ms, 20k → 137 ms per move. Two lines make hover O(1). | +| Pasteboard-shaped seams replaced by a real `NSDraggingInfo` mock | Finish-audit (general): the first pins called seams that did not exist before the fix, so no code path in them could ever have pasted the path — green with or without the fix. `DragInfoStub` drives the real overrides; the mock is ~17 lines (the one trap: `namesOfPromisedFilesDropped(atDestination:)` sits on an NSObject informal protocol and needs `override`; the class must be `@MainActor`). | +| `lastIngestNotice` as the refusal observable | The web-URL pin was green with the `isFileURL` clause deleted (the sink refuses too; only the strip TEXT differs). One `private(set) var` set in `showIngestNotice` makes the message assertable. | +| No explicit `registerForDraggedTypes` call | The live view is already registered by AppKit (lldb-verified) and receives the drag; registering again changes nothing on 27.2.1. | + +## Gotchas & Fixes + +| Problem | Root Cause | Fix | +|---------|------------|-----| +| Dropped image → file path pasted, no ingest | macOS 27.2 routes a drag to the deepest destination; a live NSTextView self-registers for drag types and matches Finder via `NSFilenamesPboardType`; the window-level SwiftUI `.dropDestination` never fired — the inverse of the 27.0.1 ruling #141 was built on | Text views own the drop (overrides, no super for URLs) → one router | +| A bare `NSTextView(frame:)` probe reported `registeredDraggedTypes == []` and suggested NSTextView could never receive the drag | Registration happens lazily once the view is live in a real window/hosting; the standalone probe is the wrong instrument | Read the LIVE view over lldb (`$`-prefixed bindings persist across `-o` commands) | +| `log stream` caught nothing while `log show --last 5m` did | The stream attaches asynchronously; the app launched into the gap | Use `log show` for anything within the last minutes; keep the stream for live watching | +| Interpolated values read back as `` | os_log redacts non-public interpolations by default | `privacy: .public` on every value you need to read | +| First fixed build failed: `Consecutive statements on a line must be separated by ';'` | `a != nil, b != nil ? x : y` — a condition list inside a ternary does not parse | `guard … else { return [] }; return .copy` (swiftformat later folded the switches into expressions) | +| `xcodebuild test` failed to compile `ProseRekeyTests.swift:325` | A third `ProseTextView(…)` call site in the tests dir (my grep covered `Museion/` only) | Pass `routeDrop:` there; grep `dropBridge:` repo-wide next time | +| swiftformat turned `ingestDrop`'s `///` block into `//` | A blank line had slipped between the doc block and the function (docComments rule) | Re-attach the `///` block directly above the function | +| `open -n` launched the instrumented build once more after a failed compile | The launch command ran unconditionally after `build exit=65` | Gate every launch on the build exit code | +| Audit flip: the Cold Turkey pin stayed green with its guard flipped | I batched two guards on ONE path — the md-branch flip (`if false`) sent the lock pin's markdown input down the ingest branch before the missing lock guard mattered | Flip same-path guards one at a time: restored, flipped the lock guard alone → the pin reddened by name (1 failed / 19 passed) | +| Audit pin failed on the apostrophe | The message landed as `couldn't` (straight) while the test asserted `couldn’t` — the house voice is the curly one | Fix the message, not the pin | +| swiftlint `line_length` (180) on the mock's `enumerateDraggingItems` signature | swiftformat does not wrap that parameter list | Wrap the signature by hand | + +## Finish audit (three reviewers, one fanout) + +Accepted and fixed: the text-drag regression (security S6 + general G4/G5 converged); the web-URL pin's non-discrimination + the vanished-file "is a folder" message (S2 + G6); zero router pins (G3 + S4); the outline rows' identical exposure (G9); the per-mouse-move pasteboard read (S1, measured); stale `ProseDropBridge` doc and a test comment (G1, G2); the retold 27.2 story trimmed to pointers (ponytail P1); devlog/INDEX suite count (G10); "27.2" vs "27.2.1" precision (G11); the widened `selection = .posts` hop documented (G7 — unreachable for images today). +Deferred (visible, not dropped): magic-byte sniffing and a size cap in `ingestImage` (S3 — the pre-existing #34 extension-only posture; the drop is an explicit user action on a file the user chose; add if the posture is ever tightened); the non-atomic multi-image loop (pre-existing #141 `ponytail:` ceiling — a `[good, symlink]` drop orphans the good copy). +Recorded as checked, no change: lock gate order (S4), pasteboard spoofing — `..` segments never reach `assets/` through the slug (S5), `draggingExited` left to stock (G8). +Coherence: the general reviewer verified zero old-contract phrases outside the retained #141 history devlog, all three `ProseTextView(` call sites, the 723→729 count, `readObjects(forClasses: [NSURL.self])` behavior on Finder/browser/text pasteboards (empirical probe), override signatures against the SDK, and no retain cycle (`proseDrop.textView` weak; `onFileDrop` captures the app-lifetime gate). No overlap between the two surfaces was flagged as duplication after the base-class hoist — each drag still reaches exactly one. + +## Files Changed + +| File | Change Summary | +|------|---------------| +| `Museion/FileDropTextView.swift` | NEW — the drag base: `onFileDrop`, `DropKind`, `droppedURLs(from:)`, `classify`, per-`changeCount` memo, the four overrides | +| `Museion/MuseionApp.swift` | `AppGateState.routeFileDrop` (the one router); `proseDrop` doc rewritten | +| `Museion/ProseListTextView.swift` | rides `FileDropTextView`; `lastIngestNotice` seam; `isFileURL` in the ingest gate | +| `Museion/OutlineRowTextView.swift` | `RowTextView` rides `FileDropTextView` (no route → bounce) | +| `Museion/PostStore.swift` | `IngestError.missing`; flat sink guards | +| `Museion/PostEditorView.swift` | `ProseTextView.routeDrop` param + `tv.onFileDrop` wiring in make/update; both call sites; bridge doc | +| `Museion/WorkspaceView.swift` | Window destination reduced to the router + `selection = .posts` | +| `MuseionTests/ImageIngestTests.swift` | `DragInfoStub` + 9 pins (drag overrides, probe, rows, refusals, router) | +| `MuseionTests/ProseRekeyTests.swift` | `routeDrop:` at the direct `ProseTextView` construction | +| `Museion/AGENTS.md`, `MuseionTests/AGENTS.md`, `AGENTS.md`, `CHANGELOG.md`, `docs/devlog/INDEX.md` | DOX pass + learning + `[Unreleased]` Fixed entry | + +## Verification + +- Full rail **729/729** (720 + 9 pins), xcresult-authoritative counts; swiftformat 0/153; swiftlint 0 violations. Re-run at finish-up on the exact committed bytes (run `20261203T153446Z`, pid 5687): 729/729 again. +- Flip cycle: 8 guards flipped in one batched edit (all independent paths) → exactly those 8 pins failed by name, 13 pre-existing green; the Cold Turkey pin flipped alone → 1 failed / 19 green. Restores byte-compared against `cp` backups (the tree is uncommitted — `git checkout` would have eaten the session). +- One real Finder drag on 27.2.1 (Debug build): `assets/…png` landed, `![alt](…)` at the drop point. + +## Open Items & Next Steps + +- [ ] Ticket + commit left to Alexander (forge writes are his call); the CHANGELOG entry is marked "unticketed fix" until then. +- [ ] The three pasted-path lines from the probe drag (15:49) may still sit in `ep-1-why-i-built…`/post.md — the real drag on the fixed build landed cleanly at line 43; the earlier paste is the author's to delete. +- [ ] Deferred audit items: magic-byte sniff + size cap in `ingestImage` (pre-existing #34 posture); pre-flight all sources before the first copy (non-atomic multi-drop, pre-existing #141 ceiling). +- [ ] Browser image drags (https URL) refuse loudly but don't ingest — downloading into assets/ would be new scope. +- [ ] Raw image-data drags (Photos/Preview) bounce silently — nothing to route. +- [ ] Re-dogfood the drop after the next macOS point release: drag routing is an OS-version claim. + +--- + +*Log written by write-log skill* diff --git a/docs/devlog/INDEX.md b/docs/devlog/INDEX.md index d70c8b0..72d5ab9 100644 --- a/docs/devlog/INDEX.md +++ b/docs/devlog/INDEX.md @@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa | Date | Type | File | Summary | |------|------|------|---------| +| 2026-12-03 | generic | [20261203-image-drop-27-2-drag-routing-pastes-path_log.md](20261203-image-drop-27-2-drag-routing-pastes-path_log.md) | macOS 27.2 routes drags to the deepest view: NSTextView pasted the file path; the editor now owns drops through one router (rail 729/729) | | 2026-12-03 | milestone | [20261203-release-011-apex-refresh-is-step-one_log.md](20261203-release-011-apex-refresh-is-step-one_log.md) | Release 0.1.1: apex 1.1.59 refreshed FIRST (full recipe now in the release skill), bump + tag 4a056f9, rail 720/720, DMG notarized; push on go | | 2026-12-01 | milestone | [20261201-release-010-readme-notes-packaging_log.md](20261201-release-010-readme-notes-packaging_log.md) | Release 0.1.0: version bump + tag, README feature/usage rewrite, distilled release notes, release.sh (Developer ID DMG, notarize); rail 717/717; Developer ID cert pending | | 2026-11-30 | fix | [20261130-external-watch-compares-unnormalized-text_log.md](20261130-external-watch-compares-unnormalized-text_log.md) | Unticketed fix (brief-32, argus cycle-6): the external guest's watch reads through the ONE shared external normalizer — the false #67 conflict on unchanged BOM/CRLF files (re-arming after sibling events and alert answers, blocking departures/quit) is gone; real foreign writes still raise; RED-first 3 pins over the real watch closure; rail 720/720 |