fix(editor): editor owns file drops on macOS 27.2

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.
This commit is contained in:
AlexKucera committed 2026-12-03 16:36:47 +01:00
1 parent 64a7eaa37e
commit 46e87e678c
15 files changed
+529 -60

No files matched your search

+5 -18
View File
@@ -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: