Repository navigation
fix(platform): deliver bulk conversation replies via integration (#2047) - #2234
Conversation
Bulk "Send messages" inserted a hardcoded, untranslated `'Message sent'` literal via the plain DB-insert path (`addMessageToConversation`), so each selected conversation got an identical placeholder row that was never delivered to the customer while the toast falsely reported success. - BulkSendDialog now collects a real message body (Textarea); Send is disabled until non-empty. - handleSendMessages routes each selected conversation through `sendMessageViaIntegration`, mirroring the single-reply path: resolves the customer email, integration name, and `Re:` subject. Conversations with no usable email are counted as failures instead of being silently dropped. - Adds i18n keys (en/de/fr) for the composer label/placeholder and removes the now-unused `useAddMessage` hook. Closes #2047
Desk Review — PR #2234 (fixes #2047): bulk "Send messages"Verdict: NOT READY — CHANGES REQUIRED (one blocking item: no tests cover the new behavior). What the fix does (and does well)The implementation correctly resolves both defects in #2047:
I verified correctness across every branch (empty body, missing email, CIAll 46 required checks pass; 5 are conditional Tests — I ran them
Both green — but neither exercises the changed code. A repo-wide search (unit, integration, and Playwright/e2e) finds zero tests referencing BLOCKING
Non-blocking (recommendations, not required)
NOT READY — CHANGES REQUIRED:
|
larryro
left a comment
There was a problem hiding this comment.
Desk Review — PR #2234 (fixes #2047)
Verdict: READY TO MERGE.
Reviewed the full implementation on branch tale/xs76g3c6x7f2py1xtbqcdg4shx89ecsa (two-round method, 6 parallel review agents + confirmation pass), not just the diff's happy line.
CI & tests
- CI: green — all required checks pass (
gh pr checks): Build platform, Unit, UI, Type check, Lint, Knip, Format, Playwright (all shards), Smoke test, Scan platform, etc. Onlyskippingentries are fork-PR/Trivy jobs (expected). - Tests run locally (bun 1.3.14,
bun installat repo root):bunx vitest --run --config vitest.ui.config.ts app/features/conversations→ 44 passed (9 files)bunx vitest --run lib/i18n/messages.test.ts→ 23 passed (i18n parity en/de/fr)
What the fix does (both defects resolved)
- Hardcoded placeholder gone — the bare
'Message sent'literal and theuseAddMessage/addMessageToConversationDB-only path are removed.BulkSendDialognow has a realTextareacomposer; Send is disabled until the trimmed body is non-empty, andhandleSendMessagesre-guards!body. - Real delivery — each selected conversation is routed through
sendMessageViaIntegration, faithfully mirroring the single-conversation reply path (conversation-panel.tsx): same email validation (!email || === '[email protected]'), samesubject || defaultSubject+replySubjectPrefix, sameintegrationName ?? 'outlook'. Conversations without a usable email become per-item failures (counted in the success/failed toast) rather than being silently dropped.
Verified correct
- Plain-text delivery: bulk passes
content/textbut nohtml; backend usesbody: html||text||contentwithcontentType: html ? 'HTML' : 'Text', so the Textarea body is delivered as Text. Correct for a plain composer. Promise.rejectinside the.mapis collected byPromise.allSettled(not a synchronous throw); success/failed counts and toast variant (successCount>0 ? default : destructive) are right.conversation.customer.emailaccess is safe:customeris a required validator field and matches the shipped single-reply pattern.- Boundary/security:
organizationIdis re-validated server-side (mutationWithRLS+ org-mismatch guard); plain-text content carries no HTML-injection risk. - i18n keys
bulkSend.messageLabel/messagePlaceholderadded to en/de/fr; Textarea is accessible (label/htmlFor).
Non-blocking observations (optional follow-ups, do not block merge)
- Unbounded concurrent fan-out: a large "all" selection dispatches one mutation per conversation in parallel (each schedules an action + DB insert + audit log + outbound email). This is the pre-existing pattern (the old code fanned out the same way), so it's not a regression — but unlike the other bulk actions (single batched mutation), bulk send could pressure integration rate limits at high volume. Worth a future batching/concurrency cap.
- "all" selection sends only to currently loaded/filtered conversations (consistent with
selectedCountand the shared selection helper). Intended, not a bug. - Minor:
UNKNOWN_CUSTOMER_EMAILis a named constant here but a bare literal inconversation-panel.tsx; could be shared. Cosmetic.
READY TO MERGE.
Summary
Fixes the two defects in the Conversations inbox bulk Send messages action reported in #2047:
handleSendMessagesinserted a bare'Message sent'literal (no i18n key) for every selected conversation regardless of user intent.addMessageToConversation), which only writes aconversationMessagesrow and emits an internal event; nothing was ever dispatched to the customer, yet the success toast implied delivery.Changes
BulkSendDialognow contains a real message-body composer (Textarea). The Send button stays disabled until the body is non-empty, so the action can no longer send empty/placeholder content.useBulkActions.handleSendMessagesnow accepts the composed body and routes each selected conversation throughsendMessageViaIntegration, mirroring the single-conversation reply path inconversation-panel.tsx: it resolves the conversation'scustomer.email,integrationName, and aRe:-prefixed subject. Conversations without a usable customer email are counted as failures (surfaced in the existing success/failed toast) instead of being silently dropped.useAddMessagehook.conversations.bulkSend.messageLabel/messagePlaceholdertoen,de, andfr.Verification
bunx tsc --noEmit— cleanbunx oxlint --type-aware(changed files) — cleanbunx oxfmt --check— cleanbunx knip— clean (no unused exports)lib/i18n/messages.test.ts) — 23 passedvitest.ui.config.ts app/features/conversations) — 32 passedCloses #2047