feat(newsletters): add superuser audience targeting - #6069
feat(newsletters): add superuser audience targeting#6069BillLeoutsakosvl346 wants to merge 5 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryHigh Risk Overview New Resend push runs as Account settings navigation fixes Mothership routing (no longer the default fallback for unknown sections). Reviewed by Cursor Bugbot for commit 493375b. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummarySuperuser newsletter audience targeting with immutable recipient snapshots, consent-filtered CSV export, and Resend segment sync via resumable background jobs.
Confidence Score: 5/5Prior Greptile findings are addressed at HEAD; the PR appears safe to merge from those resume, pagination, and settings-renderer issues. Suppression pagination, Trigger.dev resume recovery (including completed-but-still-pushing), and account-settings fail-closed behavior are present with tests; no remaining blocking failure from the prior threads.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/newsletters/push-resend.ts | Resume treats durable run status as source of truth; completed/failed/missing/active Trigger.dev jobs are fenced and restarted with new attempt keys. |
| apps/sim/lib/newsletters/resend.ts | Suppression and contact exclusion lists paginate with cursors, validation, and safety caps. |
| apps/sim/components/settings/account-settings-renderer.tsx | Explicit newsletters branch; unknown account sections render null. |
| apps/sim/lib/newsletters/runs.ts | Attempt claiming, job/segment fencing, and pushed/failed transitions back resume recovery. |
Sequence Diagram
sequenceDiagram
participant Admin as Superuser UI
participant API as Newsletter APIs
participant Runs as runs.ts
participant Queue as Job queue
participant Worker as runNewsletterResendSync
participant Resend as Resend API
Admin->>API: finalize run
API->>Runs: snapshot recipients
Admin->>API: push / resume
API->>Runs: claimNewsletterRunResendAttempt
alt stored job terminal or active (non-DB)
API->>Queue: getJob / cancelJob
API->>Runs: mark failed attempt + re-claim
end
API->>Queue: enqueue newsletter-resend-sync
API->>Runs: setNewsletterRunResendJob
Queue->>Worker: payload + attempt
Worker->>Resend: segment, properties, contacts
Worker->>Runs: mark pushed or failed
Reviews (7): Last reviewed commit: "fix(newsletters): fence resend recovery ..." | Re-trigger Greptile
59bdf0b to
4fbd67c
Compare
|
@cursor review |
4fbd67c to
849323e
Compare
|
@cursor review |
849323e to
4e522cd
Compare
|
@cursor review |
|
@cursor review |
f8c79bf to
c56913a
Compare
|
@cursor review |
c56913a to
493375b
Compare
| > | ||
| {finalizePending ? 'Finalizing...' : 'Finalize'} | ||
| </Chip> | ||
| )} |
There was a problem hiding this comment.
Stuck finalizing runs unreclaimable
Medium Severity
canFinalize only allows draft, so a run left in finalizing after a crashed or timed-out finalize never shows a Finalize action. The API can reclaim stale finalizing rows, but the UI never offers that path, leaving operators unable to recover without a manual API call.
Reviewed by Cursor Bugbot for commit 493375b. Configure here.
| AND cc.deleted_at IS NULL | ||
| AND cm.deleted_at IS NULL | ||
| AND cm.role = 'user' | ||
| AND lower(cm.content::text) LIKE ${pattern} |
There was a problem hiding this comment.
Chat targeting scans full JSON
Medium Severity
chat_mentions matching runs LIKE over cm.content::text, but copilot_messages.content stores the full PersistedMessage JSON. Users can enter the audience via attachment names, context blockType values, or other metadata containing the term, not only message text, so Instagram chat targeting can over-include recipients.
Reviewed by Cursor Bugbot for commit 493375b. Configure here.
|
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 493375b. Configure here.
| { cause: error } | ||
| ) | ||
| } | ||
| return { run: updatedRun, jobId: updatedRun.resendSyncJobId ?? jobId } |
There was a problem hiding this comment.
Resume can attach a finished job
Medium Severity
When shouldEnqueue is true because tracking was never persisted, enqueue reuses the attempt idempotency key. If that provider job already finished, Trigger/DB return the terminal job without running again, then setNewsletterRunResendJob stores it and the API succeeds while the run stays pushing with no worker. Recovery needs another resume after reconciliation sees the completed/failed job.
Reviewed by Cursor Bugbot for commit 493375b. Configure here.


Summary
Type of Change
Testing
bun run type-checkbun run check:api-validation:strictbun run check:migrations origin/stagingChecklist