Skip to content

fix: route dropped files by type (photo/video/document, not sticker) — v0.4.2#8

Merged
karem505 merged 1 commit into
masterfrom
fix/drag-drop-file-routing
Jun 17, 2026
Merged

fix: route dropped files by type (photo/video/document, not sticker) — v0.4.2#8
karem505 merged 1 commit into
masterfrom
fix/drag-drop-file-routing

Conversation

@karem505

Copy link
Copy Markdown
Owner

Problem (reported on v0.4.1)

Drag-and-drop attached every file wrongly:

  • Images → stickers
  • Video → "not supported"
  • ZIP/documents → not sent

Root cause

v0.4.1 injected into the first input[type=file] found. But WhatsApp Web keeps a sticker-creator input (image-only accept) permanently mounted, while the real Photos & Videos input (accept includes video) and Document input (accept="*") are mounted only when the attach (+) menu is opened. So every drop landed on the sticker input — which turns images into stickers and rejects video/documents.

Fix — route by type (bridge.js)

  1. Classify each file: image/* or native video (mp4/3gpp/quicktime) → media; everything else (webm/mkv/avi, zip, pdf, docs) → document.
  2. Open the attach menu to mount the lazily-rendered inputs.
  3. Select the correct input by accept (media = accept contains a video type; document = accept="*" / no image+video) — never the sticker input.
  4. Set .files + fire change (React's onChange fires for synthetic bubbling events).

Verification

  • Verified end-to-end on live WhatsApp Web: image → photo preview, .mp4 → video preview, README.md/zip → document send dialog. (Screenshot-confirmed real sends.)
  • ✅ Routing logic checked against a mock WhatsApp DOM in real webkit2gtk 2.52 (photo/mp4→media, webm/zip→document, sticker input never hit).
  • cargo build --locked + cargo test --locked → 51/51; node --check on bridge.js; boots clean. CI covers Windows + macOS.

Known minor cosmetic: the attach menu briefly flashes open during mount (the inputs only exist while it's open).

Releases as v0.4.2.

🤖 Generated with Claude Code

…s stickers)

v0.4.1 injected dropped files into the first input[type=file] it found.
But WhatsApp Web keeps a sticker-creator input (image-only accept)
permanently mounted, while the real 'Photos & videos' input (accept
includes video) and 'Document' input (accept='*') are mounted ONLY when
the attach (+) menu is opened. So every drop hit the sticker input:
images became stickers, video showed 'not supported', and zips/docs were
silently dropped.

Fix: route by file type. Classify each file (image or mp4/3gpp/quicktime
-> media; everything else incl. webm/mkv/zip/pdf -> document), open the
attach menu to mount the correct input, then select it by accept (media =
accept contains a video type; document = accept '*' / no image+video) and
set .files + fire change. The sticker input is never targeted.

Verified end-to-end on live WhatsApp Web (image->photo, mp4->video,
README.md/zip->document). Routing logic also checked against a mock DOM
in real webkit2gtk 2.52. Known minor cosmetic: the attach menu briefly
flashes open during mount.

Release v0.4.2.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@karem505 karem505 merged commit 37f08eb into master Jun 17, 2026
6 checks passed
@karem505 karem505 deleted the fix/drag-drop-file-routing branch June 17, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant