:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(signals): skip inbox notification when implementation task opens no PR (#62377)
Joshua Snyder66563e07e9d4
diff --git a/products/signals/backend/management/AGENTS.md b/products/signals/backend/management/AGENTS.mdindex 9900ecd4230d..5b738e5cedfb 100644--- a/products/signals/backend/management/AGENTS.md+++ b/products/signals/backend/management/AGENTS.md@@ -41,7 +41,8 @@ python manage.py list_signal_reports --team-id 1 --signals --json7. On reaching `ready`, the summary workflow starts `signal-report-inbox-notification` to post the Slackinbox notification. If the report auto-started an implementation task, that workflow waits for the PR toopen (bounded by `SIGNALS_INBOX_PR_NOTIFICATION_TIMEOUT_SECONDS`) so the card can show a "Review PR"- button; reports with no auto-start task notify immediately.+ button; if that task never opens a PR (fails, is cancelled, or the wait times out) no notification is+ sent. Reports with no auto-start task notify immediately.8. `ready` reports accumulate new signals silently. After enough new signals (`signal_count >= signals_at_run`),the report is re-promoted and the summary workflow runs again — reusing the previous repo selection andlightly validating previous findings instead of re-researching from scratch.diff --git a/products/signals/backend/temporal/inbox_notification.py b/products/signals/backend/temporal/inbox_notification.pyindex e06c360e6053..3b9a083a949b 100644--- a/products/signals/backend/temporal/inbox_notification.py+++ b/products/signals/backend/temporal/inbox_notification.py@@ -1,8 +1,10 @@-"""Decides when to send a report's inbox Slack notification.+"""Decides when (and whether) to send a report's inbox Slack notification.A report that auto-starts an implementation task waits for the PR to open (so the card can-carry a "Review PR" button), bounded by a timeout. A report with no auto-start task notifies-immediately. Posting itself stays in `dispatch_inbox_item_notifications`; this governs timing.+carry a "Review PR" button), bounded by a timeout. If that task never opens a PR (it fails,+is cancelled, or the wait times out), no notification is sent — there's nothing actionable to+link. A report with no auto-start task notifies immediately. Posting itself stays in+`dispatch_inbox_item_notifications`; this governs timing and suppression."""from __future__ import annotations@@ -128,6 +130,16 @@ class SignalReportInboxNotificationWorkflow:if state.pr_available or state.task_terminal:break+ # An implementation task that never opened a PR (failed, cancelled, or timed out) has+ # nothing actionable to link, so suppress its notification. `workflow.patched` keeps+ # in-flight workflows from before this change on the previous always-notify behavior.+ if workflow.patched("signals-inbox-skip-no-pr") and state.has_implementation_task and not state.pr_available:+ workflow.logger.info(+ "inbox notification skipped: implementation task produced no PR",+ extra={"report_id": inputs.report_id, "team_id": inputs.team_id},+ )+ return 0+return await workflow.execute_activity(send_report_inbox_notifications_activity,inputs,diff --git a/products/signals/backend/test/test_inbox_notification_workflow.py b/products/signals/backend/test/test_inbox_notification_workflow.pyindex 550215b3fe9d..81288fe4c5fc 100644--- a/products/signals/backend/test/test_inbox_notification_workflow.py+++ b/products/signals/backend/test/test_inbox_notification_workflow.py@@ -154,21 +154,20 @@ async def test_workflow_waits_then_notifies_when_pr_opens():@pytest.mark.asyncio-@override_settings(SIGNALS_INBOX_PR_NOTIFICATION_TIMEOUT_SECONDS=10, SIGNALS_INBOX_PR_NOTIFICATION_POLL_SECONDS=1)-async def test_workflow_stops_waiting_when_task_terminal():- recorder = _Recorder([WAIT, TERMINAL])- sent = await _run_workflow(recorder)- assert sent == 1- assert recorder.state_calls == 2- assert recorder.dispatch_calls == 1---@override_settings(SIGNALS_INBOX_PR_NOTIFICATION_TIMEOUT_SECONDS=3, SIGNALS_INBOX_PR_NOTIFICATION_POLL_SECONDS=1)-async def test_workflow_notifies_after_timeout_when_pr_never_opens():- recorder = _Recorder([WAIT]) # always WAIT- sent = await _run_workflow(recorder)- assert sent == 1- # initial fetch + one fetch per poll until elapsed reaches the timeout- assert recorder.state_calls >= 2- assert recorder.dispatch_calls == 1+ "states,timeout_seconds",+ [+ ([WAIT, TERMINAL], 10), # task reaches a terminal state without ever opening a PR+ ([WAIT], 3), # PR never opens, so the wait runs out the timeout+ ],+)+async def test_workflow_skips_when_no_pr_is_produced(states, timeout_seconds):+ recorder = _Recorder(states)+ with override_settings(+ SIGNALS_INBOX_PR_NOTIFICATION_TIMEOUT_SECONDS=timeout_seconds,+ SIGNALS_INBOX_PR_NOTIFICATION_POLL_SECONDS=1,+ ):+ sent = await _run_workflow(recorder)+ assert sent == 0+ assert recorder.state_calls >= 2 # initial fetch + at least one poll before giving up+ assert recorder.dispatch_calls == 0