#10889: fix: pass fileName through WhatsApp document send path
channel: whatsapp-web
stale
Cluster:
WhatsApp Document Handling Fixes
Fixes #10862
## Problem
When sending documents via the tool/send path, `fileName` is hardcoded as `"file"` in `send-api.ts:43`. All WhatsApp document attachments show up as "file" regardless of actual filename.
The auto-reply path (`deliver-reply.ts:138`) already handles this correctly — the tool-invoked path just never wired it through.
## Changes
| File | Change |
|------|--------|
| `src/web/active-listener.ts` | Add `fileName?: string` to `ActiveWebSendOptions` |
| `src/web/inbound/send-api.ts` | Use `sendOptions?.fileName \|\| "file"` instead of hardcoded `"file"` |
| `src/web/outbound.ts` | Accept `fileName` in options, capture from `loadWebMedia()` result, pass through to `sendOptions` |
| `src/web/outbound.test.ts` | Update document send test to expect `fileName` in `sendOptions` |
## How it works
`loadWebMedia()` already returns `fileName` — it was just being discarded in `outbound.ts`. This PR threads it through the full chain:
```
loadWebMedia() → outbound.ts → ActiveWebSendOptions → send-api.ts → Baileys payload
```
`options.fileName` is initialized before the `mediaUrl` block so callers can explicitly set a filename even without media — addressing the scope issue from the previous review.
4 files, 11 lines changed.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Threads `fileName` through the WhatsApp Web outbound send path so document attachments don’t show up as the generic "file".
- Extends `ActiveWebSendOptions` and `sendMessageWhatsApp` options to carry an optional `fileName`, defaulting to the media-derived name when present.
- Updates the web send API to set Baileys document `fileName` from `sendOptions.fileName` (fallbacking to "file").
- Adjusts the outbound unit test to assert `fileName` is passed in the send options for document sends.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Changes are small and localized, thread an optional field through an existing call chain, and include an updated unit test assertion covering the new behavior. No behavioral changes for non-document media types beyond passing an extra optional option object when a filename is present.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#6566: fix: thread fileName through WhatsApp document send path
by giannisanni · 2026-02-01
94.2%
#9606: fix: pass fileName to WhatsApp document messages
by AytuncYildizli · 2026-02-05
92.6%
#7458: fix: pass filename through to WhatsApp document sends (#7446)
by gavinbmoore · 2026-02-02
92.3%
#15650: fix(whatsapp): pass fileName to document sends instead of hardcodin...
by whoknowsmann · 2026-02-13
91.7%
#21881: fix(whatsapp): pass user-provided fileName through document send pipe…
by saakshigupta2002 · 2026-02-20
90.2%
#16785: fix(whatsapp): preserve document filenames in outbound Baileys mode
by SahilSahu731 · 2026-02-15
89.5%
#16817: fix(whatsapp): infer extension-aware fallback filename for Baileys ...
by VintLin · 2026-02-15
83.8%
#23579: feat(whatsapp): add sender attribution to inbound message logs
by svan058 · 2026-02-22
76.1%
#8705: feat(whatsapp): add viewOnce support for ephemeral media
by ndohuu · 2026-02-04
75.7%
#8224: feat(whatsapp): extract @mentions into dedicated module
by zurizuriaria · 2026-02-03
74.3%