: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): seed pending-input inbox reports through a valid transition (#127595)
Chris Volzer11f64108ac84
diff --git a/products/signals/backend/management/commands/seed_inbox_data.py b/products/signals/backend/management/commands/seed_inbox_data.pyindex 7df473d3b7c0..402742d35314 100644--- a/products/signals/backend/management/commands/seed_inbox_data.py+++ b/products/signals/backend/management/commands/seed_inbox_data.py@@ -54,9 +54,9 @@ _DEFAULT_REPOSITORY = "posthog/posthog"# states reachable from in_progress without extra side effects; READY dominates since it's the# actionable inbox state users actually triage._FINAL_STATES = [+ SignalReport.Status.PENDING_INPUT,SignalReport.Status.READY,SignalReport.Status.READY,- SignalReport.Status.PENDING_INPUT,SignalReport.Status.READY,SignalReport.Status.RESOLVED,]@@ -131,7 +131,7 @@ class Command(BaseCommand):self._add_extra_log_artefacts(team.id, str(report.id), repository, index)self._add_suggested_reviewers(team.id, str(report.id), repository, index, user_uuid)- if options["with_runs"] and repository is not None:+ if options["with_runs"] and repository is not None and report.status != SignalReport.Status.PENDING_INPUT:self._seed_task_run(team, user_id, report, repository, index)created += 1@@ -231,6 +231,17 @@ class Command(BaseCommand):) -> None:with transaction.atomic():report.refresh_from_db()+ if final_status == SignalReport.Status.PENDING_INPUT:+ # Only in_progress leads to pending_input, and that step carries the question the user must answer.+ report.save(+ update_fields=report.transition_to(+ final_status,+ title=result.title,+ summary=result.summary,+ error="Choose the success metric for this change before an agent implements it.",+ )+ )+ returnreport.save(update_fields=report.transition_to(SignalReport.Status.READY, title=result.title, summary=result.summarydiff --git a/products/signals/backend/test/test_seed_inbox_data_command.py b/products/signals/backend/test/test_seed_inbox_data_command.pynew file mode 100644index 000000000000..81af345734c7--- /dev/null+++ b/products/signals/backend/test/test_seed_inbox_data_command.py@@ -0,0 +1,29 @@+from io import StringIO++from posthog.test.base import BaseTest+from unittest.mock import patch++from django.core.management import call_command+from django.test import override_settings++from products.signals.backend.management.commands import seed_inbox_data+from products.signals.backend.models import SignalReport+++class TestSeedInboxDataCommand(BaseTest):+ @override_settings(DEBUG=True)+ def test_default_seed_leaves_reports_needing_input_without_an_implementation_run(self) -> None:+ with (+ patch.object(seed_inbox_data, "_persist_agentic_report_artefacts"),+ patch.object(seed_inbox_data.tasks_facade, "create_and_run_task") as create_task,+ ):+ create_task.return_value.latest_run = None+ call_command("seed_inbox_data", team_id=self.team.id, stdout=StringIO())++ reports = SignalReport.objects.filter(team=self.team)+ pending = reports.get(status=SignalReport.Status.PENDING_INPUT)+ assert pending.title and pending.summary and pending.error+ assert reports.filter(status=SignalReport.Status.READY).exists()+ assert {call.kwargs["signal_report_id"] for call in create_task.call_args_list} == {+ str(report_id) for report_id in reports.exclude(pk=pending.pk).values_list("pk", flat=True)+ }