: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
feat(signals): add a section counts endpoint for the inbox (#124391)
Dylan Martinc2db5af7e5a2
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.pyindex dfe11ebf1302..c9be5fc51e28 100644--- a/products/signals/backend/serializers.py+++ b/products/signals/backend/serializers.py@@ -2254,32 +2254,19 @@ class SignalReportListSerializer(SignalReportSerializer):return inbox_merge_key(score, getattr(obj, "priority_sort_rank", None))-class SignalReportListQuerySerializer(serializers.Serializer):- count_only = serializers.BooleanField(- required=False,- default=False,- help_text=(- "Return the filtered total with an empty results page. Skips report ordering, "- "serialization, and decorative metadata lookups. Defaults to false."- ),- )- include_source_metadata = serializers.BooleanField(- required=False,- default=True,- help_text=(- "Fill `source_products` and `scout_name` on each row. These come from ClickHouse, so pass "- "false to skip that lookup and get the page from Postgres only: rows then carry an empty "- "`source_products` and a null `scout_name`. Load them after with `source_metadata`. "- "Defaults to true."- ),- )+class SignalReportSectionCountsSerializer(serializers.Serializer):+ pull_requests = serializers.IntegerField(help_text="Ready reports with an implementation pull request.")+ reports = serializers.IntegerField(help_text="Ready reports without an implementation pull request.")+++class SignalReportFilterQuerySerializer(serializers.Serializer):exclude = RepeatedOrCommaSeparatedListField(child=serializers.UUIDField(),required=False,default=list,max_length=100,help_text=(- "Report ids to leave out of `results` and `count`, for example the reports a client already "+ "Report ids to leave out of the results and counts, for example the reports a client already ""shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100."),)@@ -2294,6 +2281,27 @@ class SignalReportListQuerySerializer(serializers.Serializer):)+class SignalReportListQuerySerializer(SignalReportFilterQuerySerializer):+ count_only = serializers.BooleanField(+ required=False,+ default=False,+ help_text=(+ "Return the filtered total with an empty results page. Skips report ordering, "+ "serialization, and decorative metadata lookups. Defaults to false."+ ),+ )+ include_source_metadata = serializers.BooleanField(+ required=False,+ default=True,+ help_text=(+ "Fill `source_products` and `scout_name` on each row. These come from ClickHouse, so pass "+ "false to skip that lookup and get the page from Postgres only: rows then carry an empty "+ "`source_products` and a null `scout_name`. Load them after with `source_metadata`. "+ "Defaults to true."+ ),+ )++# One list page, with room for a next page's ids that have not loaded yet.MAX_SOURCE_METADATA_REPORTS = 100diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex 7addb0e0d80b..160a792a6390 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -7,7 +7,7 @@ from urllib.parse import urlencodeimport pytestfrom posthog.test.base import APIBaseTest-from unittest.mock import patch+from unittest.mock import MagicMock, patchfrom django.apps import appsfrom django.core.cache import cache@@ -2688,6 +2688,50 @@ class TestSignalReportListAPI(APIBaseTest):assert response.status_code == status.HTTP_200_OKassert response.json()["count"] == 4+ @parameterized.expand([("live_filters", False), ("cached_columns", True)])+ def test_section_counts_match_the_count_only_list_requests(self, _name: str, cached: bool) -> None:+ with_pr = self._create_report(title="Ready with a PR")+ self._create_assignment(with_pr, pr_url="https://github.com/org/repo/pull/42")+ self._create_report(title="Ready without a PR")+ excluded = self._create_report(title="Excluded")+ merged = self._create_report(title="Merged", status=SignalReport.Status.RESOLVED)+ self._create_assignment(merged, pr_url="https://github.com/org/repo/pull/43")+ self._create_report(title="Needs input", status=SignalReport.Status.PENDING_INPUT)++ with patch("products.signals.backend.views.organization_inbox_cached_filters_enabled", return_value=cached):+ response = self.client.get(f"{self._list_url()}section_counts/?exclude={excluded.id}")+ list_counts = {+ name: self.client.get(+ self._list_url(status="ready", has_implementation_pr=has_pr, exclude=excluded.id, count_only="true")+ ).json()["count"]+ for name, has_pr in (("pull_requests", "true"), ("reports", "false"))+ }++ assert response.status_code == status.HTTP_200_OK+ assert response.json() == list_counts == {"pull_requests": 1, "reports": 1}++ def test_section_counts_accept_a_personal_api_key_with_task_read(self) -> None:+ key_value = self.create_personal_api_key_with_scopes(["task:read"])+ self.client.logout()+ self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {key_value}")++ response = self.client.get(f"{self._list_url()}section_counts/")++ assert response.status_code == status.HTTP_200_OK++ def test_section_counts_refuse_a_private_scout_trial(self) -> None:+ self._create_report()+ with patch("products.signals.backend.views.trial_store_for_request", return_value=MagicMock()):+ response = self.client.get(f"{self._list_url()}section_counts/")++ assert response.status_code == status.HTTP_403_FORBIDDEN++ def test_section_counts_reject_a_condition_a_section_sets(self) -> None:+ response = self.client.get(f"{self._list_url()}section_counts/?status=ready")++ assert response.status_code == status.HTTP_400_BAD_REQUEST+ assert response.json()["attr"] == "status"+def test_priority_preference_uses_personal_threshold_then_project_threshold(self):reports_by_priority: dict[str, SignalReport] = {}for priority in ("P0", "P1", "P2"):diff --git a/products/signals/backend/views.py b/products/signals/backend/views.pyindex 8d062bf9e0e3..671d3419e2d9 100644--- a/products/signals/backend/views.py+++ b/products/signals/backend/views.py@@ -261,6 +261,7 @@ from products.signals.backend.serializers import (SignalReportCheckReplacementSerializer,SignalReportCheckSerializer,SignalReportClaimSerializer,+ SignalReportFilterQuerySerializer,SignalReportLeaveReviewersSerializer,SignalReportListQuerySerializer,SignalReportListSerializer,@@ -268,6 +269,7 @@ from products.signals.backend.serializers import (SignalReportMetricRefreshResponseSerializer,SignalReportPriorityUpdateSerializer,SignalReportRefundSerializer,+ SignalReportSectionCountsSerializer,SignalReportSerializer,SignalReportSourceMetadataRequestSerializer,SignalReportSourceMetadataResponseSerializer,@@ -1238,6 +1240,294 @@ class SignalReportListPagination(LimitOffsetPagination):return paginated+_SUGGESTED_REVIEWERS_PARAMETER = OpenApiParameter(+ name="suggested_reviewers",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated list of PostHog user UUIDs. Reports are kept if their suggested reviewers "+ "include any of the given users."+ ),+)+_PRIORITY_PARAMETER = OpenApiParameter(+ name="priority",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. "+ "Reports without a priority assignment are excluded when this filter is set."+ ),+)+_REPORT_LIST_PARAMETERS = [+ OpenApiParameter(+ name="status",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated list of statuses to include. "+ "Valid values: potential, candidate, in_progress, pending_input, ready, resolved, failed, suppressed. "+ "Defaults to all statuses except suppressed."+ ),+ ),+ OpenApiParameter(+ name="include_all_statuses",+ type=OpenApiTypes.BOOL,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "When true, the list includes reports in every status with no default exclusions applied — "+ "currently that adds suppressed (dismissed) reports, which are otherwise hidden. Use it to "+ "see the full inbox state (e.g. deduplicating before creating a report) and read each row's "+ "status (plus dismissal_reason/dismissal_note on dismissed rows) before acting. Deleted "+ "reports are terminal and never returned. Defaults to false, which keeps the existing "+ "default exclusions. Ignored when an explicit 'status' filter is set — that filter alone "+ "decides which statuses are returned."+ ),+ ),+ OpenApiParameter(+ name="unread",+ type=OpenApiTypes.BOOL,+ location=OpenApiParameter.QUERY,+ required=False,+ description="Filter by the current user's report read state.",+ ),+ OpenApiParameter(+ name="search",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description="Case-insensitive substring match against report title and summary.",+ ),+ OpenApiParameter(+ name="channel_id",+ type=OpenApiTypes.UUID,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Narrow to reports assigned to one space (channel). Absent or empty means all "+ "reports regardless of assignment."+ ),+ ),+ OpenApiParameter(+ name="source_product",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated list of source products to include. Reports are kept if at least one of "+ "their contributing signals comes from one of these products (e.g. error_tracking, session_replay)."+ ),+ ),+ OpenApiParameter(+ name="source_id",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated list of source record ids. Reports are kept if at least one of their "+ "contributing signals came from one of these records — e.g. pass a support ticket's UUID to "+ "see what the inbox already found for that ticket. Requires exactly one source_product, "+ "since a source id is only unique within its product."+ ),+ ),+ OpenApiParameter(+ name="scout",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated list of scout skill_name slugs (e.g. signals-scout-error-tracking). "+ "Reports are kept if at least one of their contributing signals was authored by one of "+ "these scouts. Combines with source_product as an AND."+ ),+ ),+ OpenApiParameter(+ name="scout_prefix",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Scout skill_name prefix (e.g. signals-scout-customer-analytics). Reports are kept if at "+ "least one of their contributing signals was authored by a scout whose skill_name starts "+ "with this prefix — new scouts in the family match without callers listing every name. "+ "Combines with the other filters as an AND."+ ),+ ),+ _SUGGESTED_REVIEWERS_PARAMETER,+ OpenApiParameter(+ name="actionability",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated actionability judgments to include. Valid values: immediately_actionable, "+ "requires_human_input, not_actionable. Reports without a judgment are excluded."+ ),+ ),+ OpenApiParameter(+ name="already_addressed",+ type=OpenApiTypes.BOOL,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Filter by whether the latest actionability judgment says the issue is already being handled. "+ "False also includes older reports where that judgment did not record a value."+ ),+ ),+ OpenApiParameter(+ name="view",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Apply an inbox view: actionable, for_you, needs_input, needs_decision, monitoring, resolved, "+ "dismissed, held_back, not_actionable, or all. Each view applies the corresponding status, "+ "actionability, and implementation-PR filters. for_you holds the open, actionable reports that "+ "wait for the requesting user's input, that they claimed, or that name them as a suggested "+ "reviewer. needs_decision also includes failed reports without a judgment. "+ "dismissed and held_back split the suppressed reports: dismissed holds the ones a person or agent "+ "dismissed, merged, or whose pull request closed without merging; held_back holds the ones the "+ "safety or actionability judge suppressed before anyone saw them. Each row's suppression_source "+ "says which."+ ),+ ),+ OpenApiParameter(+ name="scope",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=("Reviewer scope: for_me, entire_project, or teammate. Pass teammate_uuid with teammate."),+ ),+ OpenApiParameter(+ name="teammate_uuid",+ type=OpenApiTypes.UUID,+ location=OpenApiParameter.QUERY,+ required=False,+ description="PostHog user UUID used when scope=teammate.",+ ),+ _PRIORITY_PARAMETER,+ OpenApiParameter(+ name="use_priority_preference",+ type=OpenApiTypes.BOOL,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "When true and priority is omitted, include priorities at or above the requesting user's "+ "personal PR-generation threshold, falling back to the project threshold."+ ),+ ),+ OpenApiParameter(+ name="sort",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Inbox sort preset: priority, recommended, last_updated, newest, or oldest. Ignored when "+ "ordering is supplied. recommended resolves per user to a ranker: the priority order, or "+ "the open, action or fix outcome of the served ranking model with unscored and stale reports "+ "in priority order after the scored ones. The response's ranker field names the one used."+ ),+ ),+ OpenApiParameter(+ name="ordering",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' "+ "for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, "+ f"priority, created_at, updated_at, id, {', '.join(PUBLIC_RANKING_ORDERING_HEADS)}. "+ "Defaults to '-is_suggested_reviewer,status,-updated_at'. Each ranking_<outcome> field sorts by "+ "the served ranking model's probability for that public outcome, with unscored reports last in "+ "either direction. Read inbox-ranking-outcomes-list for what each outcome means. The ranking "+ "fields need staff or the inbox model sort rollout: other users get a 400."+ ),+ ),+ OpenApiParameter(+ name="ranking_min_lift",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated <outcome>:<lift> pairs, e.g. fix:2,open:1.5. Keeps reports whose served "+ "ranking lift is at least the value for every named outcome. Outcomes: open, action, fix. Read "+ "inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. "+ "Needs staff or the inbox model sort rollout: other users get a 400."+ ),+ ),+ OpenApiParameter(+ name="ranking_min_probability",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Comma-separated <outcome>:<probability> pairs, e.g. fix:0.3. Keeps reports whose served "+ "ranking probability is at least the value for every named outcome. Outcomes: open, action, "+ "fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports "+ "never match. "+ "Needs staff or the inbox model sort rollout: other users get a 400."+ ),+ ),+ OpenApiParameter(+ name="created_after",+ type=OpenApiTypes.DATETIME,+ location=OpenApiParameter.QUERY,+ required=False,+ description="ISO 8601 datetime. Keeps reports created at or after this time.",+ ),+ OpenApiParameter(+ name="task_id",+ type=OpenApiTypes.UUID,+ location=OpenApiParameter.QUERY,+ required=False,+ description="Only reports associated with this task (via the report's task associations).",+ ),+ OpenApiParameter(+ name="has_implementation_pr",+ type=OpenApiTypes.BOOL,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Filter reports by whether an implementation pull request is attached. "+ "'true' keeps only reports with a PR; 'false' keeps only those without. "+ "Pair with count_only=true to return only the filtered total."+ ),+ ),+ OpenApiParameter(+ name="unclaimed",+ type=OpenApiTypes.BOOL,+ location=OpenApiParameter.QUERY,+ required=False,+ description=(+ "Filter by whether the report has no owner and no draft, open, or unknown PR. "+ "Resolved reports are never unclaimed."+ ),+ ),+ OpenApiParameter(+ name="assignee",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ enum=["me", "mine"],+ description=(+ "'me' returns reports claimed by exactly the requesting actor: the user, the internal task, or "+ "the MCP agent. 'mine' returns every report the requesting user answers for: their own claims, "+ "claims by MCP agents acting for them, and claims by internal tasks they started."+ ),+ ),+]+# Section counts set the status and the implementation PR condition themselves, so they reject these.+_SECTION_DEFINING_PARAMETERS = frozenset({"status", "has_implementation_pr", "include_all_statuses", "view"})+_SECTION_COUNTS_PARAMETERS = [+ parameter+ for parameter in _REPORT_LIST_PARAMETERS+ if parameter.name not in _SECTION_DEFINING_PARAMETERS | {"sort", "ordering"}+]++@extend_schema_view(destroy=extend_schema(summary="Delete a signal report",@@ -1331,6 +1621,39 @@ class SignalReportViewSet(RankingOutcomesResponseSerializer({"status": status_value.value, "model": model, "outcomes": outcomes}).data)+ @validated_request(+ query_serializer=SignalReportFilterQuerySerializer,+ responses={200: SignalReportSectionCountsSerializer},+ parameters=_SECTION_COUNTS_PARAMETERS,+ description=(+ "Count the ready reports with and without an implementation pull request, in one query. "+ "Accepts the list's filters, so each count matches a `count_only` list request with "+ "`status=ready` and the matching `has_implementation_pr`. Rejects `status`, "+ "`has_implementation_pr`, `include_all_statuses` and `view`, because the counts set those."+ ),+ )+ @action(detail=False, methods=["get"], required_scopes=["task:read"], pagination_class=None)+ @tracer.start_as_current_span("signals.reports.section_counts")+ def section_counts(self, request: ValidatedRequest, *args: Any, **kwargs: Any) -> Response:+ if trial_store_for_request(request, self.team_id) is not None:+ raise exceptions.PermissionDenied("Private scout trials cannot read inbox section counts.")+ rejected = sorted(name for name in _SECTION_DEFINING_PARAMETERS if name in request.query_params)+ if rejected:+ raise serializers.ValidationError(+ dict.fromkeys(rejected, "Section counts set this condition, so they do not accept it.")+ )+ trace.get_current_span().set_attribute("signals.reports.list.cached_filters", self._inbox_cached_filters)+ queryset = self.filter_queryset(self.get_queryset()).filter(status=SignalReport.Status.READY)+ excluded = request.validated_query_data["exclude"]+ if excluded:+ queryset = queryset.exclude(id__in=excluded)+ has_pr = self._implementation_pr_report_filter()+ counts = queryset.order_by().aggregate(+ pull_requests=Count("id", filter=has_pr),+ reports=Count("id", filter=~has_pr),+ )+ return Response(SignalReportSectionCountsSerializer(counts).data)+@extend_schema(request=ReportReadStateRequestSerializer, responses=ReportReadStateResponseSerializer)@action(detail=False, methods=["post"], required_scopes=["task:read"])def read_state(self, request, **kwargs):@@ -1420,9 +1743,10 @@ class SignalReportViewSet(qs = self._apply_signal_report_priority_filter(qs)if self.action == "list":qs = self._annotate_signal_report_ranking(qs)+ if self.action in {"list", "section_counts"}:qs = self._apply_signal_report_ranking_filters(qs)qs = self._prefetch_signal_report_priority_artefacts(qs)- if self.action != "bulk_state":+ if self.action not in {"bulk_state", "section_counts"}:# `bulk_state` answers with one outcome per id, never a serialized report, and the list# ordering that reads this value does not apply to it either.qs = self._annotate_is_suggested_reviewer(qs)@@ -1488,7 +1812,7 @@ class SignalReportViewSet(}# Actions that work on many reports at once, so per-row annotations are wasted work there.- _MULTI_REPORT_ACTIONS = frozenset({"list", "bulk_state"})+ _MULTI_REPORT_ACTIONS = frozenset({"list", "bulk_state", "section_counts"})# Actions allowed to resolve a suppressed report by ID even without an explicit# `status` filter. These are the read/reopen paths the inbox's Dismissed tab needs:@@ -1607,7 +1931,7 @@ class SignalReportViewSet(def _apply_signal_report_listed_filter(self, queryset):# List-only: a report a scout kept out of the inbox stays reachable by id and by its other actions.- if self.action != "list" or self._bool_query_param("include_unlisted") is True:+ if self.action not in {"list", "section_counts"} or self._bool_query_param("include_unlisted") is True:return querysetreturn queryset.filter(inbox_hidden_report_filter(self.team_id))@@ -2506,283 +2830,7 @@ class SignalReportViewSet(@validated_request(query_serializer=SignalReportListQuerySerializer,responses={200: SignalReportListSerializer},- parameters=[- OpenApiParameter(- name="status",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated list of statuses to include. "- "Valid values: potential, candidate, in_progress, pending_input, ready, resolved, failed, suppressed. "- "Defaults to all statuses except suppressed."- ),- ),- OpenApiParameter(- name="include_all_statuses",- type=OpenApiTypes.BOOL,- location=OpenApiParameter.QUERY,- required=False,- description=(- "When true, the list includes reports in every status with no default exclusions applied — "- "currently that adds suppressed (dismissed) reports, which are otherwise hidden. Use it to "- "see the full inbox state (e.g. deduplicating before creating a report) and read each row's "- "status (plus dismissal_reason/dismissal_note on dismissed rows) before acting. Deleted "- "reports are terminal and never returned. Defaults to false, which keeps the existing "- "default exclusions. Ignored when an explicit 'status' filter is set — that filter alone "- "decides which statuses are returned."- ),- ),- OpenApiParameter(- name="unread",- type=OpenApiTypes.BOOL,- location=OpenApiParameter.QUERY,- required=False,- description="Filter by the current user's report read state.",- ),- OpenApiParameter(- name="search",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description="Case-insensitive substring match against report title and summary.",- ),- OpenApiParameter(- name="channel_id",- type=OpenApiTypes.UUID,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Narrow to reports assigned to one space (channel). Absent or empty means all "- "reports regardless of assignment."- ),- ),- OpenApiParameter(- name="source_product",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated list of source products to include. Reports are kept if at least one of "- "their contributing signals comes from one of these products (e.g. error_tracking, session_replay)."- ),- ),- OpenApiParameter(- name="source_id",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated list of source record ids. Reports are kept if at least one of their "- "contributing signals came from one of these records — e.g. pass a support ticket's UUID to "- "see what the inbox already found for that ticket. Requires exactly one source_product, "- "since a source id is only unique within its product."- ),- ),- OpenApiParameter(- name="scout",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated list of scout skill_name slugs (e.g. signals-scout-error-tracking). "- "Reports are kept if at least one of their contributing signals was authored by one of "- "these scouts. Combines with source_product as an AND."- ),- ),- OpenApiParameter(- name="scout_prefix",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Scout skill_name prefix (e.g. signals-scout-customer-analytics). Reports are kept if at "- "least one of their contributing signals was authored by a scout whose skill_name starts "- "with this prefix — new scouts in the family match without callers listing every name. "- "Combines with the other filters as an AND."- ),- ),- OpenApiParameter(- name="suggested_reviewers",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated list of PostHog user UUIDs. Reports are kept if their suggested reviewers "- "include any of the given users."- ),- ),- OpenApiParameter(- name="actionability",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated actionability judgments to include. Valid values: immediately_actionable, "- "requires_human_input, not_actionable. Reports without a judgment are excluded."- ),- ),- OpenApiParameter(- name="already_addressed",- type=OpenApiTypes.BOOL,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Filter by whether the latest actionability judgment says the issue is already being handled. "- "False also includes older reports where that judgment did not record a value."- ),- ),- OpenApiParameter(- name="view",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Apply an inbox view: actionable, for_you, needs_input, needs_decision, monitoring, resolved, "- "dismissed, held_back, not_actionable, or all. Each view applies the corresponding status, "- "actionability, and implementation-PR filters. for_you holds the open, actionable reports that "- "wait for the requesting user's input, that they claimed, or that name them as a suggested "- "reviewer. needs_decision also includes failed reports without a judgment. "- "dismissed and held_back split the suppressed reports: dismissed holds the ones a person or agent "- "dismissed, merged, or whose pull request closed without merging; held_back holds the ones the "- "safety or actionability judge suppressed before anyone saw them. Each row's suppression_source "- "says which."- ),- ),- OpenApiParameter(- name="scope",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=("Reviewer scope: for_me, entire_project, or teammate. Pass teammate_uuid with teammate."),- ),- OpenApiParameter(- name="teammate_uuid",- type=OpenApiTypes.UUID,- location=OpenApiParameter.QUERY,- required=False,- description="PostHog user UUID used when scope=teammate.",- ),- OpenApiParameter(- name="priority",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. "- "Reports without a priority assignment are excluded when this filter is set."- ),- ),- OpenApiParameter(- name="use_priority_preference",- type=OpenApiTypes.BOOL,- location=OpenApiParameter.QUERY,- required=False,- description=(- "When true and priority is omitted, include priorities at or above the requesting user's "- "personal PR-generation threshold, falling back to the project threshold."- ),- ),- OpenApiParameter(- name="sort",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Inbox sort preset: priority, recommended, last_updated, newest, or oldest. Ignored when "- "ordering is supplied. recommended resolves per user to a ranker: the priority order, or "- "the open, action or fix outcome of the served ranking model with unscored and stale reports "- "in priority order after the scored ones. The response's ranker field names the one used."- ),- ),- OpenApiParameter(- name="ordering",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' "- "for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, "- f"priority, created_at, updated_at, id, {', '.join(PUBLIC_RANKING_ORDERING_HEADS)}. "- "Defaults to '-is_suggested_reviewer,status,-updated_at'. Each ranking_<outcome> field sorts by "- "the served ranking model's probability for that public outcome, with unscored reports last in "- "either direction. Read inbox-ranking-outcomes-list for what each outcome means. The ranking "- "fields need staff or the inbox model sort rollout: other users get a 400."- ),- ),- OpenApiParameter(- name="ranking_min_lift",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated <outcome>:<lift> pairs, e.g. fix:2,open:1.5. Keeps reports whose served "- "ranking lift is at least the value for every named outcome. Outcomes: open, action, fix. Read "- "inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. "- "Needs staff or the inbox model sort rollout: other users get a 400."- ),- ),- OpenApiParameter(- name="ranking_min_probability",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Comma-separated <outcome>:<probability> pairs, e.g. fix:0.3. Keeps reports whose served "- "ranking probability is at least the value for every named outcome. Outcomes: open, action, "- "fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports "- "never match. "- "Needs staff or the inbox model sort rollout: other users get a 400."- ),- ),- OpenApiParameter(- name="created_after",- type=OpenApiTypes.DATETIME,- location=OpenApiParameter.QUERY,- required=False,- description="ISO 8601 datetime. Keeps reports created at or after this time.",- ),- OpenApiParameter(- name="task_id",- type=OpenApiTypes.UUID,- location=OpenApiParameter.QUERY,- required=False,- description="Only reports associated with this task (via the report's task associations).",- ),- OpenApiParameter(- name="has_implementation_pr",- type=OpenApiTypes.BOOL,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Filter reports by whether an implementation pull request is attached. "- "'true' keeps only reports with a PR; 'false' keeps only those without. "- "Pair with count_only=true to return only the filtered total."- ),- ),- OpenApiParameter(- name="unclaimed",- type=OpenApiTypes.BOOL,- location=OpenApiParameter.QUERY,- required=False,- description=(- "Filter by whether the report has no owner and no draft, open, or unknown PR. "- "Resolved reports are never unclaimed."- ),- ),- OpenApiParameter(- name="assignee",- type=OpenApiTypes.STR,- location=OpenApiParameter.QUERY,- required=False,- enum=["me", "mine"],- description=(- "'me' returns reports claimed by exactly the requesting actor: the user, the internal task, or "- "the MCP agent. 'mine' returns every report the requesting user answers for: their own claims, "- "claims by MCP agents acting for them, and claims by internal tasks they started."- ),- ),- ],+ parameters=_REPORT_LIST_PARAMETERS,)@tracer.start_as_current_span("signals.reports.list")def list(self, request: ValidatedRequest, *args, **kwargs):diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 4c95b38d95a6..94306d4c082d 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -5995,6 +5995,13 @@ export interface SignalReportRefundSummaryResponseApi {quota_limited: boolean}+export interface SignalReportSectionCountsApi {+ /** Ready reports with an implementation pull request. */+ pull_requests: number+ /** Ready reports without an implementation pull request. */+ reports: number+}+export interface SignalReportSourceMetadataRequestApi {/*** Reports to describe. At most 100 ids per call.@@ -10555,7 +10562,7 @@ export type SignalsReportsListParams = {*/created_after?: string/**- * Report ids to leave out of `results` and `count`, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.+ * Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.* @maxItems 100*/exclude?: string[]@@ -10762,6 +10769,106 @@ export type SignalsReportsPrCiStatusesParams = {report_ids: string}+export type SignalsReportsSectionCountsRetrieveParams = {+ /**+ * Comma-separated actionability judgments to include. Valid values: immediately_actionable, requires_human_input, not_actionable. Reports without a judgment are excluded.+ */+ actionability?: string+ /**+ * Filter by whether the latest actionability judgment says the issue is already being handled. False also includes older reports where that judgment did not record a value.+ */+ already_addressed?: boolean+ /**+ * 'me' returns reports claimed by exactly the requesting actor: the user, the internal task, or the MCP agent. 'mine' returns every report the requesting user answers for: their own claims, claims by MCP agents acting for them, and claims by internal tasks they started.+ */+ assignee?: SignalsReportsSectionCountsRetrieveAssignee+ /**+ * Narrow to reports assigned to one space (channel). Absent or empty means all reports regardless of assignment.+ */+ channel_id?: string+ /**+ * ISO 8601 datetime. Keeps reports created at or after this time.+ */+ created_after?: string+ /**+ * Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.+ * @maxItems 100+ */+ exclude?: string[]+ /**+ * Include reports kept out of the shared inbox. A report is kept out when the scout that authored it turned off its `inbox` output destination. Defaults to false. Fetching a report by id always works, whatever this value is.+ */+ include_unlisted?: boolean+ /**+ * Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. Reports without a priority assignment are excluded when this filter is set.+ */+ priority?: string+ /**+ * Comma-separated <outcome>:<lift> pairs, e.g. fix:2,open:1.5. Keeps reports whose served ranking lift is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.+ */+ ranking_min_lift?: string+ /**+ * Comma-separated <outcome>:<probability> pairs, e.g. fix:0.3. Keeps reports whose served ranking probability is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.+ */+ ranking_min_probability?: string+ /**+ * Reviewer scope: for_me, entire_project, or teammate. Pass teammate_uuid with teammate.+ */+ scope?: string+ /**+ * Comma-separated list of scout skill_name slugs (e.g. signals-scout-error-tracking). Reports are kept if at least one of their contributing signals was authored by one of these scouts. Combines with source_product as an AND.+ */+ scout?: string+ /**+ * Scout skill_name prefix (e.g. signals-scout-customer-analytics). Reports are kept if at least one of their contributing signals was authored by a scout whose skill_name starts with this prefix — new scouts in the family match without callers listing every name. Combines with the other filters as an AND.+ */+ scout_prefix?: string+ /**+ * Case-insensitive substring match against report title and summary.+ */+ search?: string+ /**+ * Comma-separated list of source record ids. Reports are kept if at least one of their contributing signals came from one of these records — e.g. pass a support ticket's UUID to see what the inbox already found for that ticket. Requires exactly one source_product, since a source id is only unique within its product.+ */+ source_id?: string+ /**+ * Comma-separated list of source products to include. Reports are kept if at least one of their contributing signals comes from one of these products (e.g. error_tracking, session_replay).+ */+ source_product?: string+ /**+ * Comma-separated list of PostHog user UUIDs. Reports are kept if their suggested reviewers include any of the given users.+ */+ suggested_reviewers?: string+ /**+ * Only reports associated with this task (via the report's task associations).+ */+ task_id?: string+ /**+ * PostHog user UUID used when scope=teammate.+ */+ teammate_uuid?: string+ /**+ * Filter by whether the report has no owner and no draft, open, or unknown PR. Resolved reports are never unclaimed.+ */+ unclaimed?: boolean+ /**+ * Filter by the current user's report read state.+ */+ unread?: boolean+ /**+ * When true and priority is omitted, include priorities at or above the requesting user's personal PR-generation threshold, falling back to the project threshold.+ */+ use_priority_preference?: boolean+}++export type SignalsReportsSectionCountsRetrieveAssignee =+ (typeof SignalsReportsSectionCountsRetrieveAssignee)[keyof typeof SignalsReportsSectionCountsRetrieveAssignee]++export const SignalsReportsSectionCountsRetrieveAssignee = {+ Me: 'me',+ Mine: 'mine',+} as const+export type SignalsScoutConfigListParams = {/*** Case-insensitive substring filter over a scout's display name and its skill name. A scout matches on either, so a person who knows the label and a caller who knows the identifier both find it. Omit for the whole fleet.diff --git a/products/signals/frontend/generated/api.ts b/products/signals/frontend/generated/api.tsindex eecfddb41c25..add109e507a4 100644--- a/products/signals/frontend/generated/api.ts+++ b/products/signals/frontend/generated/api.ts@@ -119,6 +119,7 @@ import type {SignalReportRefundResponseApi,SignalReportRefundSummaryResponseApi,SignalReportReingestionStatusApi,+ SignalReportSectionCountsApi,SignalReportSourceMetadataRequestApi,SignalReportSourceMetadataResponseApi,SignalReportStateRequestApi,@@ -158,6 +159,7 @@ import type {SignalsReportsAvailableReviewersRetrieveParams,SignalsReportsListParams,SignalsReportsPrCiStatusesParams,+ SignalsReportsSectionCountsRetrieveParams,SignalsScoutConfigListParams,SignalsScoutConfigSyncParams,SignalsScoutConfigTrialComparisonHistoryParams,@@ -1640,6 +1642,39 @@ export const signalsReportsRefundSummaryRetrieve = async (})}+export const getSignalsReportsSectionCountsRetrieveUrl = (+ projectId: string,+ params?: SignalsReportsSectionCountsRetrieveParams+) => {+ const normalizedParams = new URLSearchParams()++ Object.entries(params || {}).forEach(([key, value]) => {+ if (value !== undefined) {+ normalizedParams.append(key, value === null ? 'null' : String(value))+ }+ })++ const stringifiedParams = normalizedParams.toString()++ return stringifiedParams.length > 0+ ? `/api/projects/${projectId}/signals/reports/section_counts/?${stringifiedParams}`+ : `/api/projects/${projectId}/signals/reports/section_counts/`+}++/**+ * Count the ready reports with and without an implementation pull request, in one query. Accepts the list's filters, so each count matches a `count_only` list request with `status=ready` and the matching `has_implementation_pr`. Rejects `status`, `has_implementation_pr`, `include_all_statuses` and `view`, because the counts set those.+ */+export const signalsReportsSectionCountsRetrieve = async (+ projectId: string,+ params?: SignalsReportsSectionCountsRetrieveParams,+ options?: RequestInit+): Promise<SignalReportSectionCountsApi> => {+ return apiMutator<SignalReportSectionCountsApi>(getSignalsReportsSectionCountsRetrieveUrl(projectId, params), {+ ...options,+ method: 'GET',+ })+}+export const getSignalsReportsSourceMetadataCreateUrl = (projectId: string) => {return `/api/projects/${projectId}/signals/reports/source_metadata/`}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex cf1b01c6c49d..a901e70be8e7 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -110568,6 +110568,13 @@ export namespace Schemas {report_id: string;}+ export interface SignalReportSectionCounts {+ /** Ready reports with an implementation pull request. */+ pull_requests: number;+ /** Ready reports without an implementation pull request. */+ reports: number;+ }+export interface SignalReportSourceMetadata {/** Report id. */readonly id: string;@@ -140136,7 +140143,7 @@ export namespace Schemas {*/created_after?: string;/**- * Report ids to leave out of `results` and `count`, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.+ * Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.* @maxItems 100*/exclude?: string[];@@ -140342,6 +140349,106 @@ export namespace Schemas {report_ids: string;};+ export type SignalsReportsSectionCountsRetrieveParams = {+ /**+ * Comma-separated actionability judgments to include. Valid values: immediately_actionable, requires_human_input, not_actionable. Reports without a judgment are excluded.+ */+ actionability?: string;+ /**+ * Filter by whether the latest actionability judgment says the issue is already being handled. False also includes older reports where that judgment did not record a value.+ */+ already_addressed?: boolean;+ /**+ * 'me' returns reports claimed by exactly the requesting actor: the user, the internal task, or the MCP agent. 'mine' returns every report the requesting user answers for: their own claims, claims by MCP agents acting for them, and claims by internal tasks they started.+ */+ assignee?: SignalsReportsSectionCountsRetrieveAssignee;+ /**+ * Narrow to reports assigned to one space (channel). Absent or empty means all reports regardless of assignment.+ */+ channel_id?: string;+ /**+ * ISO 8601 datetime. Keeps reports created at or after this time.+ */+ created_after?: string;+ /**+ * Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.+ * @maxItems 100+ */+ exclude?: string[];+ /**+ * Include reports kept out of the shared inbox. A report is kept out when the scout that authored it turned off its `inbox` output destination. Defaults to false. Fetching a report by id always works, whatever this value is.+ */+ include_unlisted?: boolean;+ /**+ * Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. Reports without a priority assignment are excluded when this filter is set.+ */+ priority?: string;+ /**+ * Comma-separated <outcome>:<lift> pairs, e.g. fix:2,open:1.5. Keeps reports whose served ranking lift is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.+ */+ ranking_min_lift?: string;+ /**+ * Comma-separated <outcome>:<probability> pairs, e.g. fix:0.3. Keeps reports whose served ranking probability is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.+ */+ ranking_min_probability?: string;+ /**+ * Reviewer scope: for_me, entire_project, or teammate. Pass teammate_uuid with teammate.+ */+ scope?: string;+ /**+ * Comma-separated list of scout skill_name slugs (e.g. signals-scout-error-tracking). Reports are kept if at least one of their contributing signals was authored by one of these scouts. Combines with source_product as an AND.+ */+ scout?: string;+ /**+ * Scout skill_name prefix (e.g. signals-scout-customer-analytics). Reports are kept if at least one of their contributing signals was authored by a scout whose skill_name starts with this prefix — new scouts in the family match without callers listing every name. Combines with the other filters as an AND.+ */+ scout_prefix?: string;+ /**+ * Case-insensitive substring match against report title and summary.+ */+ search?: string;+ /**+ * Comma-separated list of source record ids. Reports are kept if at least one of their contributing signals came from one of these records — e.g. pass a support ticket's UUID to see what the inbox already found for that ticket. Requires exactly one source_product, since a source id is only unique within its product.+ */+ source_id?: string;+ /**+ * Comma-separated list of source products to include. Reports are kept if at least one of their contributing signals comes from one of these products (e.g. error_tracking, session_replay).+ */+ source_product?: string;+ /**+ * Comma-separated list of PostHog user UUIDs. Reports are kept if their suggested reviewers include any of the given users.+ */+ suggested_reviewers?: string;+ /**+ * Only reports associated with this task (via the report's task associations).+ */+ task_id?: string;+ /**+ * PostHog user UUID used when scope=teammate.+ */+ teammate_uuid?: string;+ /**+ * Filter by whether the report has no owner and no draft, open, or unknown PR. Resolved reports are never unclaimed.+ */+ unclaimed?: boolean;+ /**+ * Filter by the current user's report read state.+ */+ unread?: boolean;+ /**+ * When true and priority is omitted, include priorities at or above the requesting user's personal PR-generation threshold, falling back to the project threshold.+ */+ use_priority_preference?: boolean;+ };++ export type SignalsReportsSectionCountsRetrieveAssignee = typeof SignalsReportsSectionCountsRetrieveAssignee[keyof typeof SignalsReportsSectionCountsRetrieveAssignee];+++ export const SignalsReportsSectionCountsRetrieveAssignee = {+ Me: 'me',+ Mine: 'mine',+ } as const;+export type SignalsScoutConfigListParams = {/*** Case-insensitive substring filter over a scout's display name and its skill name. A scout matches on either, so a person who knows the label and a caller who knows the identifier both find it. Omit for the whole fleet.diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex 5080b0526bf7..1a75034eefc2 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -339,7 +339,7 @@ export const SignalsReportsListQueryParams = () => zod.object({.max(signalsReportsListQueryExcludeMax).optional().describe(- 'Report ids to leave out of `results` and `count`, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.'+ 'Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.'),has_implementation_pr: zod.boolean()diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.jsonindex 258bff8a6b45..cd00404eea98 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json@@ -30,7 +30,7 @@"type": "string"},"exclude": {- "description": "Report ids to leave out of `results` and `count`, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.",+ "description": "Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.","items": {"type": "string"},