Dropping an image file on the prose editor pasted the file path instead of ingesting it (#141 follow-up, unticketed; dogfood on macOS 27.2.1). #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, so its stock performDragOperation pasted the path and the window destination never fired — the same for a markdown file dropped on the editor. 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; the outline rows bounce; text-only drags keep the stock drop; the pasteboard probe is memoized per changeCount. A web URL refuses with the type strip, a vanished file refuses as missing. +9 tests (a real NSDraggingInfo mock drives the overrides; the router's guest/lock/ingest branches pinned), all flip-verified. Finish-audit: three reviewers; the text-drag regression and the outline rows' identical exposure fixed, two pre-existing ceilings deferred in the devlog. Rail 729/729, swiftformat 0/153, swiftlint 0.
15 KiB
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  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-urlonly; the user's post on disk held threerefs and noassets/(soingestImagehad never run).softwareupdate --historydated the OS jump: 27.0.1 → 27.2.1 on 2026-11-16, two weeks after #141's verification. Then ONE instrumented Debug build (temporaryLogger(subsystem: "com.babylondreams.Museion", category: "dropprobe")lines in the SwiftUI closure +NSDraggingDestination/readSelection/pasteoverrides on the text view, read throughlog 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, NOingestDrop entry. - lldb on the live app (
expr -l Swift -- let $ws = NSApp.windows …) showed theProseListTextViewregistered for ~19 drag types (NSFilenames, Apple URL, TIFF, PNG, RTF, RTFD, file-promise …) — NSTextView registers itself once live; a bareNSTextView(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 perchangeCount; theNSDraggingDestinationoverrides route URL-bearing drags (neversuper— the stock path paste lives there), hand text-only drags to the stock drop, bounce the rest.ProseListTextViewand the outliner'sRowTextViewride it (rows mount no route → bounce).MuseionApp.swift—AppGateState.routeFileDrop(_:): the ONE file-drop router (Cold Turkey guard → pure-markdown set →posts.openExternal→ elseproseDrop.textView?.ingestDrop).proseDropis documented as the window destination's handle.ProseListTextView.swift—lastIngestNoticetest seam (the refusal text the pins read);ingestDrop's publishable gate requiresisFileURL(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—ProseTextViewgains a non-optionalrouteDrop: @escaping ([URL]) -> BoolbesidedropBridge;makeNSView/updateNSViewsettv.onFileDrop = routeDrop. BothPostEditorViewcall sites pass{ gate.routeFileDrop($0) };ProseRekeyTests' direct construction passes{ _ in false }.WorkspaceView.swift— the window.dropDestinationis 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'sNSDraggingInfomock (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), rootAGENTS.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 <private> |
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
cpbackups (the tree is uncommitted —git checkoutwould have eaten the session). - One real Finder drag on 27.2.1 (Debug build):
assets/…pnglanded,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