eleven / messenger Public

mac: let the native drop path win over chat.js web uploader (#83)

Newer chat.js added its own dragover/drop uploader on #thread-view; its dragover preventDefault made WebKit claim the drop, bypassing the native DropWebView — but macOS WKWebView gives the page no Finder-drop files, so nothing uploaded (broke on instances serving the new chat.js, e.g. run.garden). The injected script now swallows the page's drag events (capture phase) so the native drop path handles the file. Trade-off: no chat.js drop-overlay highlight on the Mac.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Paul Campbell 77ebcea17a4a93bfc7eb3343dcc9031a6b49f447 parent 76189ae
1 file changed, +9 −0
  • ios/LChatMac/ChatFeedWebView.swift +9 −0
diff --git a/ios/LChatMac/ChatFeedWebView.swift b/ios/LChatMac/ChatFeedWebView.swift
index e879056..6bc3d0a 100644
--- a/ios/LChatMac/ChatFeedWebView.swift
+++ b/ios/LChatMac/ChatFeedWebView.swift
@@ -123,6 +123,15 @@ struct ChatFeedWebView: NSViewRepresentable {
input.dispatchEvent(new Event('change', { bubbles: true }));
};
+ // chat.js has its own web drag-drop uploader (dragover/drop on #thread-view),
+ // but macOS WKWebView doesn't hand Finder-drop files to the page, and the page's
+ // dragover preventDefault stops our native DropWebView from getting the drop.
+ // Swallow the page's drag events (capture phase, no preventDefault) so the native
+ // drop path — DropWebView → __lchatAddFiles → the file input — handles it instead.
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(function (t) {
+ document.addEventListener(t, function (e) { e.stopImmediatePropagation(); }, true);
+ });
+
// Report the web feed's appearance CHOICE to native so the app chrome (rail,
// palette, title bar) matches. chat.js sets color-scheme on <html> to 'light',
// 'dark', or 'light dark' (follow OS). Crucially we report the mode, never a