Skip to content

fix(platform): deliver bulk conversation replies via integration (#2047) - #2234

Merged
yannickmonney merged 2 commits into
mainfrom
tale/xs76g3c6x7f2py1xtbqcdg4shx89ecsa
Jun 29, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
tale/xs76g3c6x7f2py1xtbqcdg4shx89ecsa

Conversation

@larryro

@larryro larryro commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the two defects in the Conversations inbox bulk Send messages action reported in #2047:

  1. Hardcoded untranslated placeholder — handleSendMessages inserted a bare 'Message sent' literal (no i18n key) for every selected conversation regardless of user intent.
  2. Never delivered — it used the plain DB-insert path (addMessageToConversation), which only writes a conversationMessages row and emits an internal event; nothing was ever dispatched to the customer, yet the success toast implied delivery.

Changes

  • BulkSendDialog now 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.handleSendMessages now accepts the composed body and routes each selected conversation through sendMessageViaIntegration, mirroring the single-conversation reply path in conversation-panel.tsx: it resolves the conversation's customer.email, integrationName, and a Re:-prefixed subject. Conversations without a usable customer email are counted as failures (surfaced in the existing success/failed toast) instead of being silently dropped.
  • Removed the now-unused useAddMessage hook.
  • Added i18n keys conversations.bulkSend.messageLabel / messagePlaceholder to en, de, and fr.

Verification

  • bunx tsc --noEmit — clean
  • bunx oxlint --type-aware (changed files) — clean
  • bunx oxfmt --check — clean
  • bunx knip — clean (no unused exports)
  • i18n parity/usage test (lib/i18n/messages.test.ts) — 23 passed
  • Conversations UI tests (vitest.ui.config.ts app/features/conversations) — 32 passed

Closes #2047

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
@larryro

larryro commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

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:

  • The hardcoded untranslated 'Message sent' literal is gone; the body now comes from a real Textarea composer in BulkSendDialog, gated so Send is disabled until the trimmed body is non-empty (bulk-send-dialog.tsx:28-29,59) and re-guarded in the hook (use-bulk-actions.ts:80-81).
  • handleSendMessages now routes each selected conversation through sendMessageViaIntegration (use-bulk-actions.ts:106-119) instead of the plain addMessageToConversation DB insert, mirroring the single-reply path. The dead useAddMessage hook is removed (no remaining references; Knip CI green).
  • Conversations with no usable customer email (empty or the [email protected] sentinel) are rejected and counted as failures via Promise.allSettled rather than silently dropped (use-bulk-actions.ts:98-103,123-128).
  • i18n keys bulkSend.messageLabel / messagePlaceholder added to en/de/fr; de-CH is a deliberately sparse override and correctly falls back to de.

I verified correctness across every branch (empty body, missing email, 'all' selection, args↔backend validator, plain-text delivery via body: html||text||content → contentType: 'Text'), boundaries/security (org ownership enforced per-conversation in the helper and via mutationWithRLS), and the honesty of the success toast (variant flips to destructive when successCount===0). No correctness, security, or robustness defect was found in the changed logic.

CI

All 46 required checks pass; 5 are conditional skipping (fork-PR/container jobs), none failed or pending. CI is green.

Tests — I ran them

  • bunx vitest run --config vitest.ui.config.ts app/features/conversations → 32 passed
  • bunx vitest run --config vitest.config.ts lib/i18n/messages.test.ts → 23 passed

Both green — but neither exercises the changed code. A repo-wide search (unit, integration, and Playwright/e2e) finds zero tests referencing BulkSendDialog, handleSendMessages, useSendMessageViaIntegration, or the bulk send action. The green result is misleading: it comes entirely from unrelated tests.

BLOCKING

  1. No test covers the new bulk-send behavior (app/features/conversations/hooks/use-bulk-actions.ts / components/bulk-send-dialog.tsx). The PR replaced a trivial placeholder path with real branching logic — composer gating, integration routing, the missing-email → failure-count branch, and the success/fail tally — and added no test for any of it, despite this folder's established convention of unit-testing hooks and components (hooks/mutation-hooks.test.ts, six component *.test.tsx). Add tests that assert: (a) BulkSendDialog keeps Send disabled until the body is non-empty and calls onConfirm with the trimmed body; (b) handleSendMessages calls sendMessageViaIntegration once per selected conversation with the resolved to/subject/text; (c) a conversation with missing/[email protected] email is counted in failedCount and not dispatched; (d) the success/fail tally and toast variant.

Non-blocking (recommendations, not required)

  • Toast title on total failure (use-bulk-actions.ts:130-137): title stays bulk.messagesSent ("Messages sent") even when successCount===0. The destructive variant + accurate description mitigate it, and it matches the existing pattern for the other bulk toasts, but consider a failure-specific title.
  • Sentinel duplication (use-bulk-actions.ts:19): UNKNOWN_CUSTOMER_EMAIL is extracted here while the sibling single-reply path (conversation-panel.tsx:253) and transform_conversation.ts still use the bare '[email protected]' literal. Consider one shared constant for all sites.
  • Uncapped concurrent real sends: Promise.allSettled now fans out N real outbound emails (was cheap DB inserts). For large/'all' selections this can hit integration rate limits with no batching/concurrency cap. Pre-existing fan-out pattern, but the per-item cost is materially higher now.
  • 'all' selection scope: select-all dispatches only to the currently loaded/filtered page. This is pre-existing, uniform behavior shared by every bulk action (resolve/archive/spam all use the same getSelected* helpers), so it is not a regression in this PR — but it is higher-stakes for an irreversible email action and worth a product follow-up.

NOT READY — CHANGES REQUIRED:

  1. Add tests covering the new bulk Send-messages behavior in app/features/conversations/hooks/use-bulk-actions.ts and components/bulk-send-dialog.tsx — specifically the composer gating (Send disabled until non-empty body), routing through sendMessageViaIntegration per selected conversation, the missing/[email protected] email → failedCount branch, and the success/fail tally — then confirm they pass.

@larryro larryro left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. Only skipping entries are fork-PR/Trivy jobs (expected).
  • Tests run locally (bun 1.3.14, bun install at 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)

  1. Hardcoded placeholder gone — the bare 'Message sent' literal and the useAddMessage/addMessageToConversation DB-only path are removed. BulkSendDialog now has a real Textarea composer; Send is disabled until the trimmed body is non-empty, and handleSendMessages re-guards !body.
  2. 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]'), same subject || defaultSubject + replySubjectPrefix, same integrationName ?? '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/text but no html; backend uses body: html||text||content with contentType: html ? 'HTML' : 'Text', so the Textarea body is delivered as Text. Correct for a plain composer.
  • Promise.reject inside the .map is collected by Promise.allSettled (not a synchronous throw); success/failed counts and toast variant (successCount>0 ? default : destructive) are right.
  • conversation.customer.email access is safe: customer is a required validator field and matches the shipped single-reply pattern.
  • Boundary/security: organizationId is re-validated server-side (mutationWithRLS + org-mismatch guard); plain-text content carries no HTML-injection risk.
  • i18n keys bulkSend.messageLabel/messagePlaceholder added 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 selectedCount and the shared selection helper). Intended, not a bug.
  • Minor: UNKNOWN_CUSTOMER_EMAIL is a named constant here but a bare literal in conversation-panel.tsx; could be shared. Cosmetic.

READY TO MERGE.

@yannickmonney
yannickmonney merged commit 3e96156 into main Jun 29, 2026
51 checks passed
@yannickmonney
yannickmonney deleted the tale/xs76g3c6x7f2py1xtbqcdg4shx89ecsa branch June 29, 2026 17:21
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.

Bug: Conversations bulk "Send messages" inserts a hardcoded untranslated placeholder and never delivers via the integration

2 participants