Skip to content

: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.

feat(signals): expose dismissal_reason and note on report list serializer (#64267)

Andrew Maguire83cc57032765
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.py
index 30686d5ac870..48f6db52c89e 100644
--- a/products/signals/backend/serializers.py
+++ b/products/signals/backend/serializers.py
@@ -276,6 +276,12 @@ class SignalReportSerializer(serializers.ModelSerializer):
already_addressed = serializers.SerializerMethodField(
help_text="Whether the issue appears already fixed, from the actionability judgment artefact.",
)
+ dismissal_reason = serializers.SerializerMethodField(
+ help_text="Reason code from the latest dismissal artefact, set when the report was suppressed (when present).",
+ )
+ dismissal_note = serializers.SerializerMethodField(
+ help_text="Free-form note captured alongside the dismissal reason (when present).",
+ )
is_suggested_reviewer = serializers.BooleanField(read_only=True, default=False)
source_products = serializers.SerializerMethodField(
help_text="Distinct source products contributing signals to this report (from ClickHouse).",
@@ -300,6 +306,8 @@ class SignalReportSerializer(serializers.ModelSerializer):
"priority",
"actionability",
"already_addressed",
+ "dismissal_reason",
+ "dismissal_note",
"is_suggested_reviewer",
"source_products",
"implementation_pr_url",
@@ -359,6 +367,35 @@ class SignalReportSerializer(serializers.ModelSerializer):
value = data.get("already_addressed")
return value if isinstance(value, bool) else None
+ def _get_dismissal_artefact_data(self, obj: SignalReport) -> dict | None:
+ prefetched = getattr(obj, "prefetched_dismissal_artefacts", None)
+ if prefetched is not None:
+ art = prefetched[0] if prefetched else None
+ else:
+ art = obj.artefacts.filter(type=SignalReportArtefact.ArtefactType.DISMISSAL).order_by("-created_at").first()
+ if art is None:
+ return None
+ try:
+ data = json.loads(art.content)
+ except (json.JSONDecodeError, TypeError, ValueError):
+ return None
+ return data if isinstance(data, dict) else None
+
+ def get_dismissal_reason(self, obj: SignalReport) -> str | None:
+ data = self._get_dismissal_artefact_data(obj)
+ if data is None:
+ return None
+ # Reason codes are owned by the client; pass through whatever was stored.
+ value = data.get("reason")
+ return value if isinstance(value, str) and value else None
+
+ def get_dismissal_note(self, obj: SignalReport) -> str | None:
+ data = self._get_dismissal_artefact_data(obj)
+ if data is None:
+ return None
+ value = data.get("note")
+ return value if isinstance(value, str) and value else None
+
def get_source_products(self, obj: SignalReport) -> list[str]:
source_products_map: dict[str, list[str]] | None = self.context.get("source_products_map")
if source_products_map is not None:
diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.py
index e2f8a97cc69a..406ce7762979 100644
--- a/products/signals/backend/test/test_signal_report_api.py
+++ b/products/signals/backend/test/test_signal_report_api.py
@@ -804,6 +804,69 @@ class TestSignalReportListAPI(APIBaseTest):
row = next(r for r in response.json()["results"] if r["id"] == str(report.id))
assert row["actionability"] is None
+ # --- dismissal reason ---
+
+ def _dismissal_artefact(
+ self,
+ report: SignalReport,
+ *,
+ reason: str | None,
+ note: str = "",
+ created_at=None,
+ ) -> SignalReportArtefact:
+ payload: dict = {"note": note, "user_id": None, "user_uuid": None}
+ if reason is not None:
+ payload["reason"] = reason
+ art = SignalReportArtefact(
+ team=self.team,
+ report=report,
+ type=SignalReportArtefact.ArtefactType.DISMISSAL,
+ content=json.dumps(payload),
+ )
+ art.save()
+ if created_at is not None:
+ SignalReportArtefact.objects.filter(pk=art.pk).update(created_at=created_at)
+ art.refresh_from_db()
+ return art
+
+ @parameterized.expand(
+ [
+ # Known reason code with a note: both are surfaced verbatim.
+ ("known_reason_with_note", "wontfix_intentional", "by design", "wontfix_intentional", "by design"),
+ # Reason codes are client-owned, so an unrecognised code passes through;
+ # an empty note collapses to null.
+ ("unknown_reason_passes_through", "some_brand_new_code", "", "some_brand_new_code", None),
+ ]
+ )
+ def test_list_surfaces_dismissal_reason_and_note(self, _name, reason, note, expected_reason, expected_note):
+ report = self._create_report(status=SignalReport.Status.SUPPRESSED)
+ self._dismissal_artefact(report, reason=reason, note=note)
+
+ response = self.client.get(self._list_url(status="suppressed"))
+ assert response.status_code == status.HTTP_200_OK
+ row = next(r for r in response.json()["results"] if r["id"] == str(report.id))
+ assert row["dismissal_reason"] == expected_reason
+ assert row["dismissal_note"] == expected_note
+
+ def test_list_dismissal_reason_null_without_artefact(self):
+ report = self._create_report(status=SignalReport.Status.SUPPRESSED)
+
+ response = self.client.get(self._list_url(status="suppressed"))
+ assert response.status_code == status.HTTP_200_OK
+ row = next(r for r in response.json()["results"] if r["id"] == str(report.id))
+ assert row["dismissal_reason"] is None
+ assert row["dismissal_note"] is None
+
+ def test_list_uses_latest_dismissal_artefact_by_created_at(self):
+ report = self._create_report(status=SignalReport.Status.SUPPRESSED)
+ self._dismissal_artefact(report, reason="report_unclear", created_at=timezone.now() - timedelta(days=1))
+ self._dismissal_artefact(report, reason="analysis_wrong")
+
+ response = self.client.get(self._list_url(status="suppressed"))
+ assert response.status_code == status.HTTP_200_OK
+ row = next(r for r in response.json()["results"] if r["id"] == str(report.id))
+ assert row["dismissal_reason"] == "analysis_wrong"
+
class TestSignalReportSuppressionAPI(APIBaseTest):
def _state_url(self, report_id: str) -> str:
@@ -875,6 +938,11 @@ class TestSignalReportSuppressionAPI(APIBaseTest):
report.refresh_from_db()
assert report.status == expected_final_status
+ # The response serializes the report after the dismissal artefact is written, so it must
+ # reflect the just-saved reason/note — not a stale prefetch evaluated before the write.
+ assert response.json()["dismissal_reason"] == expected_reason
+ assert response.json()["dismissal_note"] == expected_note
+
artefacts = list(
SignalReportArtefact.objects.filter(report=report, type=SignalReportArtefact.ArtefactType.DISMISSAL)
)
diff --git a/products/signals/backend/views.py b/products/signals/backend/views.py
index 99c68cb400d2..6e842c90104c 100644
--- a/products/signals/backend/views.py
+++ b/products/signals/backend/views.py
@@ -652,6 +652,13 @@ class SignalReportViewSet(
).order_by("-created_at"),
to_attr="prefetched_actionability_artefacts",
),
+ Prefetch(
+ "artefacts",
+ queryset=SignalReportArtefact.objects.filter(type=SignalReportArtefact.ArtefactType.DISMISSAL).order_by(
+ "-created_at"
+ ),
+ to_attr="prefetched_dismissal_artefacts",
+ ),
)
def _annotate_is_suggested_reviewer(self, queryset):
@@ -1016,6 +1023,11 @@ class SignalReportViewSet(
type=SignalReportArtefact.ArtefactType.DISMISSAL,
content=json.dumps(artefact_content),
)
+ # get_object() evaluated the dismissal prefetch before this artefact
+ # existed; drop the stale cache so the response serializer re-reads the
+ # just-written reason/note instead of the previous (or empty) dismissal.
+ if hasattr(report, "prefetched_dismissal_artefacts"):
+ del report.prefetched_dismissal_artefacts
return Response(SignalReportSerializer(report, context=self._enriched_report_context(report)).data)
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index b7b3a0b90f19..e4700b347b5a 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -89,6 +89,16 @@ export interface SignalReportApi {
* @nullable
*/
readonly already_addressed: boolean | null
+ /**
+ * Reason code from the latest dismissal artefact, set when the report was suppressed (when present).
+ * @nullable
+ */
+ readonly dismissal_reason: string | null
+ /**
+ * Free-form note captured alongside the dismissal reason (when present).
+ * @nullable
+ */
+ readonly dismissal_note: string | null
readonly is_suggested_reviewer: boolean
/** Distinct source products contributing signals to this report (from ClickHouse). */
readonly source_products: readonly string[]
diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yaml
index be6bff202441..ea2887c6f8ac 100644
--- a/products/signals/mcp/tools.yaml
+++ b/products/signals/mcp/tools.yaml
@@ -46,6 +46,8 @@ tools:
- priority
- actionability
- already_addressed
+ - dismissal_reason
+ - dismissal_note
- signal_count
- total_weight
- source_products
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 6ebfb5ee35c6..466b3e856cde 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -30144,6 +30144,16 @@ export namespace Schemas {
* @nullable
*/
readonly already_addressed: boolean | null;
+ /**
+ * Reason code from the latest dismissal artefact, set when the report was suppressed (when present).
+ * @nullable
+ */
+ readonly dismissal_reason: string | null;
+ /**
+ * Free-form note captured alongside the dismissal reason (when present).
+ * @nullable
+ */
+ readonly dismissal_note: string | null;
readonly is_suggested_reviewer: boolean;
/** Distinct source products contributing signals to this report (from ClickHouse). */
readonly source_products: readonly string[];
diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.ts
index d89db336089d..34f1143b1f65 100644
--- a/services/mcp/src/tools/generated/signals.ts
+++ b/services/mcp/src/tools/generated/signals.ts
@@ -67,6 +67,8 @@ const inboxReportsList = (): ToolBase<
'priority',
'actionability',
'already_addressed',
+ 'dismissal_reason',
+ 'dismissal_note',
'signal_count',
'total_weight',
'source_products',