: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): show scout name on inbox list cards and header chip (#67487)
Andrew Maguire87b67c80fd2e
diff --git a/frontend/src/scenes/inbox/components/cards/ReportCard.tsx b/frontend/src/scenes/inbox/components/cards/ReportCard.tsxindex 87927ab75f06..cecc4f21e06a 100644--- a/frontend/src/scenes/inbox/components/cards/ReportCard.tsx+++ b/frontend/src/scenes/inbox/components/cards/ReportCard.tsx@@ -5,9 +5,10 @@ import { IconArchive, IconPullRequest, IconUndo } from '@posthog/icons'import { LemonButton, LemonTag, LemonTagType, Link, Tooltip } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'+import { scoutDisplayName } from 'lib/signals/signalCardSourceLine'import { urls } from 'scenes/urls'-import { InboxFlatListTabKey, SignalReport, SignalReportStatus } from '../../types'+import { InboxFlatListTabKey, SignalReport, SignalReportStatus, SignalSourceProduct } from '../../types'import { dismissalReasonLabel, DismissalReasonValue } from '../../utils/dismissalReasons'import {deriveHeadline,@@ -37,16 +38,28 @@ export function ConventionalCommitScopeTag({ type, scope }: { type: string; scop}/** Icon stack + primary source-product label, with a `+ n` tail when more sources contributed. */-export function InboxCardSourceMeta({ sourceProducts }: { sourceProducts?: string[] | null }): JSX.Element | null {+export function InboxCardSourceMeta({+ sourceProducts,+ scoutName,+}: {+ sourceProducts?: string[] | null+ /** Authoring scout's display name, when scout-authored — appended to the "Scout" label. */+ scoutName?: string | null+}): JSX.Element | null {const [primary, ...overflow] = knownSourceProductEntries(sourceProducts)if (!primary) {return null}+ // Name the authoring scout on a scout-authored report so it's clear at a glance who wrote it.+ const primaryLabel =+ primary.key === SignalSourceProduct.SIGNALS_SCOUT && scoutName+ ? `${primary.meta.label} · ${scoutName}`+ : primary.meta.labelreturn (<div className="flex items-center gap-2 min-w-0 text-xs text-tertiary leading-none select-none"><SourceProductIconRow entries={[primary, ...overflow]} className="flex items-center gap-1.5 shrink-0" /><span>- {primary.meta.label}+ {primaryLabel}{overflow.length > 0 ? ` + ${overflow.length}` : null}</span></div>@@ -235,7 +248,10 @@ export function ReportCard({{showMeta ? (<div className="flex items-center flex-wrap mt-1.5 min-w-0 gap-2.5 text-xs text-tertiary leading-none select-none">{hasPr && repoSlug ? <span className="truncate font-mono">{repoSlug}</span> : null}- <InboxCardSourceMeta sourceProducts={report.source_products} />+ <InboxCardSourceMeta+ sourceProducts={report.source_products}+ scoutName={scoutDisplayName(report.scout_name)}+ />{!hasPr && (!isReady || !report.actionability) && (<SignalReportStatusBadge status={report.status} />)}diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsxindex b5964c36e693..2b82b71393db 100644--- a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx+++ b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx@@ -262,12 +262,8 @@ export function InboxDetailFrame({const evidenceCount = reportSignals !== null ? signals.length : report.signal_countconst hasEvidence = evidenceCount > 0- // Which scout authored this report — read off the backing signals (every scout-authored signal- // carries its `skill_name`). Null for pipeline reports; upgrades the header "Scout" chip once loaded.- const scoutSignal = signals.find(- (s) => s.source_product === 'signals_scout' && typeof s.extra?.skill_name === 'string'- )- const scoutName = scoutSignal ? scoutDisplayName(scoutSignal.extra.skill_name as string) : null+ // Which scout authored this report — the serializer resolves the skill_name off the backing signals.+ const scoutName = scoutDisplayName(report.scout_name)const summaryPending =report.status === SignalReportStatus.IN_PROGRESS || report.status === SignalReportStatus.CANDIDATEdiff --git a/frontend/src/scenes/inbox/types.ts b/frontend/src/scenes/inbox/types.tsindex 693700b04098..39dc084e5991 100644--- a/frontend/src/scenes/inbox/types.ts+++ b/frontend/src/scenes/inbox/types.ts@@ -45,6 +45,8 @@ export interface SignalReport {already_addressed?: boolean | null/** Distinct source products contributing signals to this report. */source_products?: string[]+ /** skill_name slug of the authoring scout, when scout-authored (raw slug — prettify with `scoutDisplayName`). */+ scout_name?: string | null/** PR URL from the latest implementation task run, if available. */implementation_pr_url?: string | null/** Reason code from the latest dismissal artefact (when archived). See dismissalReasons. */diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.pyindex 2b6271d88046..c4666d4d5281 100644--- a/products/signals/backend/serializers.py+++ b/products/signals/backend/serializers.py@@ -290,6 +290,9 @@ class SignalReportSerializer(serializers.ModelSerializer):source_products = serializers.SerializerMethodField(help_text="Distinct source products contributing signals to this report (from ClickHouse).",)+ scout_name = serializers.SerializerMethodField(+ help_text="skill_name slug of the scout that authored this report, when scout-authored (from ClickHouse); null otherwise.",+ )implementation_pr_url = serializers.SerializerMethodField(help_text="PR URL from the latest implementation task run, if available.",)@@ -314,6 +317,7 @@ class SignalReportSerializer(serializers.ModelSerializer):"dismissal_note","is_suggested_reviewer","source_products",+ "scout_name","implementation_pr_url",]read_only_fields = fields@@ -406,6 +410,12 @@ class SignalReportSerializer(serializers.ModelSerializer):return source_products_map.get(str(obj.id), [])return []+ def get_scout_name(self, obj: SignalReport) -> str | None:+ scout_names_map: dict[str, str] | None = self.context.get("scout_names_map")+ if scout_names_map is not None:+ return scout_names_map.get(str(obj.id))+ return None+def get_implementation_pr_url(self, obj: SignalReport) -> str | None:implementation_pr_url_map: dict[str, str] | None = self.context.get("implementation_pr_url_map")if implementation_pr_url_map is not None:diff --git a/products/signals/backend/temporal/signal_queries.py b/products/signals/backend/temporal/signal_queries.pyindex 3840b970a67d..9f7076d5cc4b 100644--- a/products/signals/backend/temporal/signal_queries.py+++ b/products/signals/backend/temporal/signal_queries.py@@ -608,10 +608,23 @@ def fetch_report_ids_for_source_products(team: Team, source_products: list[str])# ----------------------------------------------------------------------------def fetch_source_products_for_reports(team: Team, report_ids: list[str]) -> dict[str, list[str]]:- """Return a mapping of report_id -> distinct source_products for those reports.+@dataclass(frozen=True)+class ReportSignalMeta:+ """Per-report signal metadata read off ClickHouse for the inbox list/detail views."""- Only includes non-deleted signals. Source products are returned in sorted order.+ source_products: list[str]+ # Raw skill_name slug of the authoring scout (e.g. "signals-scout-error-tracking"), when the+ # report's backing signals carry one. None for pipeline reports and reports emitted before the+ # scout stamped skill_name onto its signals.+ scout_name: str | None+++def fetch_source_products_for_reports(team: Team, report_ids: list[str]) -> dict[str, ReportSignalMeta]:+ """Return a mapping of report_id -> `ReportSignalMeta` (distinct source_products + authoring scout).++ Only includes non-deleted signals. Source products are returned in sorted order. `scout_name` is+ any non-empty `extra.skill_name` on the report's signals (all scout-authored signals of a report+ share one), or None.Bounds the argMax dedup to documents that ever carried one of these report_ids, insteadof deduping the team's whole signal history. The unbounded dedup's memory grows with the@@ -626,12 +639,16 @@ def fetch_source_products_for_reports(team: Team, report_ids: list[str]) -> dictreturn {}ch_query = """- SELECT report_id, arraySort(groupUniqArray(source_product)) as source_products+ SELECT+ report_id,+ arraySort(groupUniqArray(source_product)) as source_products,+ anyIf(skill_name, skill_name != '') as scout_nameFROM (SELECTJSONExtractString(metadata, 'report_id') as report_id,JSONExtractBool(metadata, 'deleted') as is_deleted,- JSONExtractString(metadata, 'source_product') as source_product+ JSONExtractString(metadata, 'source_product') as source_product,+ JSONExtractString(metadata, 'extra', 'skill_name') as skill_nameFROM (SELECT argMax(metadata, inserted_at) as metadataFROM document_embeddings@@ -667,7 +684,11 @@ def fetch_source_products_for_reports(team: Team, report_ids: list[str]) -> dict},)- return {row[0]: row[1] for row in (result.results or []) if row[0]}+ return {+ row[0]: ReportSignalMeta(source_products=row[1], scout_name=(row[2] or None))+ for row in (result.results or [])+ if row[0]+ }# ---------------------------------------------------------------------------diff --git a/products/signals/backend/test/test_signal_queries.py b/products/signals/backend/test/test_signal_queries.pyindex 938eba0d0b68..fef97e152b80 100644--- a/products/signals/backend/test/test_signal_queries.py+++ b/products/signals/backend/test/test_signal_queries.py@@ -11,6 +11,7 @@ from posthog.clickhouse.client import sync_executefrom products.signals.backend.temporal.signal_queries import (EMBEDDING_MODEL,+ ReportSignalMeta,fetch_signals_for_report_sync,fetch_source_products_for_reports,)@@ -29,19 +30,22 @@ class _SignalEmbeddingsTestBase(ClickhouseTestMixin, APIBaseTest):inserted_at: datetime,deleted: bool = False,content: str = "the signal content",+ skill_name: str | None = None,) -> None:"""Write one version of a signal document straight to the model-specific embeddings table.Multiple versions of the same document_id (varying inserted_at) model theReplacingMergeTree's pre-merge state that the argMax dedup has to resolve."""- metadata = {+ metadata: dict = {"report_id": report_id,"source_product": source_product,"source_type": "some_type","source_id": f"src-{document_id}","deleted": deleted,}+ if skill_name is not None:+ metadata["extra"] = {"skill_name": skill_name}sync_execute(f"""INSERT INTO {_MODEL_TABLE} (@@ -93,7 +97,10 @@ class TestFetchSourceProductsForReports(_SignalEmbeddingsTestBase):result = fetch_source_products_for_reports(self.team, ["rA", "rB"])- assert result == {"rA": ["errors", "replay"], "rB": ["surveys"]}+ assert result == {+ "rA": ReportSignalMeta(source_products=["errors", "replay"], scout_name=None),+ "rB": ReportSignalMeta(source_products=["surveys"], scout_name=None),+ }def test_only_returns_requested_reports(self) -> None:self._emit_version(document_id="d1", report_id="wanted", source_product="errors", inserted_at=self.base)@@ -101,18 +108,49 @@ class TestFetchSourceProductsForReports(_SignalEmbeddingsTestBase):result = fetch_source_products_for_reports(self.team, ["wanted"])- assert result == {"wanted": ["errors"]}+ assert result == {"wanted": ReportSignalMeta(source_products=["errors"], scout_name=None)}++ def test_extracts_authoring_scout_name_from_signal_extra(self) -> None:+ # Guards the nested `extra.skill_name` extraction that drives the inbox's "Scout · <name>"+ # label — a broken JSON path or the anyIf filter would silently drop it back to null.+ self._emit_version(+ document_id="d1",+ report_id="rScout",+ source_product="signals_scout",+ inserted_at=self.base,+ skill_name="signals-scout-error-tracking",+ )+ self._emit_version(document_id="d2", report_id="rPipeline", source_product="errors", inserted_at=self.base)++ result = fetch_source_products_for_reports(self.team, ["rScout", "rPipeline"])++ assert result == {+ "rScout": ReportSignalMeta(source_products=["signals_scout"], scout_name="signals-scout-error-tracking"),+ "rPipeline": ReportSignalMeta(source_products=["errors"], scout_name=None),+ }@parameterized.expand([# A signal re-grouped to a different report must count under its latest report only —# never the old one. Pushing the report_id filter before the argMax would resurface it# under rOld; keeping it after preserves "latest version wins".- ("regrouped_to_new_report", ("rOld", False), ("rNew", False), ["rOld", "rNew"], {"rNew": ["errors"]}),+ (+ "regrouped_to_new_report",+ ("rOld", False),+ ("rNew", False),+ ["rOld", "rNew"],+ {"rNew": ReportSignalMeta(source_products=["errors"], scout_name=None)},+ ),# Soft-delete re-emits the signal with deleted=True and a newer inserted_at -> it drops out.("deleted_in_latest_version", ("rA", False), ("rA", True), ["rA"], {}),# ...and a delete that was later undone (newer non-deleted version) comes back.- ("revived_in_latest_version", ("rA", True), ("rA", False), ["rA"], {"rA": ["errors"]}),+ (+ "revived_in_latest_version",+ ("rA", True),+ ("rA", False),+ ["rA"],+ {"rA": ReportSignalMeta(source_products=["errors"], scout_name=None)},+ ),])def test_latest_version_wins(@@ -121,7 +159,7 @@ class TestFetchSourceProductsForReports(_SignalEmbeddingsTestBase):first: tuple[str, bool],latest: tuple[str, bool],report_ids: list[str],- expected: dict[str, list[str]],+ expected: dict[str, ReportSignalMeta],) -> None:first_report, first_deleted = firstlatest_report, latest_deleted = latestdiff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex be2f03b06b71..cf97ab9d9529 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -23,6 +23,7 @@ from posthog.models.team.team import Teamfrom products.signals.backend.implementation_pr import fetch_implementation_pr_urls_for_reportsfrom products.signals.backend.models import SignalReport, SignalReportArtefact, SignalReportTaskfrom products.signals.backend.task_run_artefacts import append_task_run_artefact, record_implementation_task+from products.signals.backend.temporal.signal_queries import ReportSignalMetaif TYPE_CHECKING:from products.tasks.backend.models import Task, TaskRun@@ -874,12 +875,18 @@ class TestSignalReportListAPI(APIBaseTest):with patch("products.signals.backend.views.fetch_source_products_for_reports",- return_value={str(report.id): ["zendesk", "github"]},+ return_value={+ str(report.id): ReportSignalMeta(+ source_products=["zendesk", "github"], scout_name="signals-scout-error-tracking"+ )+ },):response = self.client.get(f"/api/projects/{self.team.id}/signals/reports/{report.id}/")assert response.status_code == status.HTTP_200_OKassert response.json()["source_products"] == ["zendesk", "github"]+ # scout_name flows from the ClickHouse meta through the view's map split into the serializer.+ assert response.json()["scout_name"] == "signals-scout-error-tracking"def test_source_products_present_on_signals_action(self):report = self._create_report()@@ -887,7 +894,7 @@ class TestSignalReportListAPI(APIBaseTest):with (patch("products.signals.backend.views.fetch_source_products_for_reports",- return_value={str(report.id): ["zendesk"]},+ return_value={str(report.id): ReportSignalMeta(source_products=["zendesk"], scout_name=None)},),patch("products.signals.backend.views.fetch_signals_for_report_sync", return_value=[]),):@@ -930,7 +937,7 @@ class TestSignalReportListAPI(APIBaseTest):with (patch("products.signals.backend.views.fetch_source_products_for_reports",- return_value={str(report.id): ["zendesk"]},+ return_value={str(report.id): ReportSignalMeta(source_products=["zendesk"], scout_name=None)},),patch("products.signals.backend.views.fetch_signals_for_report_sync", return_value=[]),):@@ -1253,7 +1260,7 @@ class TestSignalReportSuppressionAPI(APIBaseTest):with patch("products.signals.backend.views.fetch_source_products_for_reports",- return_value={str(report.id): ["zendesk"]},+ return_value={str(report.id): ReportSignalMeta(source_products=["zendesk"], scout_name=None)},):response = self.client.post(self._state_url(str(report.id)),diff --git a/products/signals/backend/views.py b/products/signals/backend/views.pyindex a1b635e4ce8d..19274cadcd55 100644--- a/products/signals/backend/views.py+++ b/products/signals/backend/views.py@@ -1016,10 +1016,10 @@ class SignalReportViewSet(# report (or an already-committed state change) into a 500.report_ids = [str(report.id)]try:- source_products_map = fetch_source_products_for_reports(self.team, report_ids)+ signal_meta_map = fetch_source_products_for_reports(self.team, report_ids)except Exception:logger.exception("signals.enriched_context.source_products_failed", report_id=str(report.id))- source_products_map = {}+ signal_meta_map = {}try:implementation_pr_url_map = fetch_implementation_pr_urls_for_reports(report_ids)except Exception:@@ -1027,7 +1027,8 @@ class SignalReportViewSet(implementation_pr_url_map = {}return {**self.get_serializer_context(),- "source_products_map": source_products_map,+ "source_products_map": {rid: meta.source_products for rid, meta in signal_meta_map.items()},+ "scout_names_map": {rid: meta.scout_name for rid, meta in signal_meta_map.items() if meta.scout_name},"implementation_pr_url_map": implementation_pr_url_map,}@@ -1182,14 +1183,15 @@ class SignalReportViewSet(trace.get_current_span().set_attribute("signals.reports.list.count", len(report_ids))with tracer.start_as_current_span("signals.reports.list.fetch_source_products"):- source_products_map = fetch_source_products_for_reports(self.team, report_ids) if report_ids else {}+ signal_meta_map = fetch_source_products_for_reports(self.team, report_ids) if report_ids else {}with tracer.start_as_current_span("signals.reports.list.fetch_implementation_pr_urls"):implementation_pr_url_map = fetch_implementation_pr_urls_for_reports(report_ids)context = {**self.get_serializer_context(),- "source_products_map": source_products_map,+ "source_products_map": {rid: meta.source_products for rid, meta in signal_meta_map.items()},+ "scout_names_map": {rid: meta.scout_name for rid, meta in signal_meta_map.items() if meta.scout_name},"implementation_pr_url_map": implementation_pr_url_map,}serializer = self.get_serializer(reports, many=True, context=context)diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 459959bed9a6..9f31c4b88d2b 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -102,6 +102,11 @@ export interface SignalReportApi {readonly is_suggested_reviewer: boolean/** Distinct source products contributing signals to this report (from ClickHouse). */readonly source_products: readonly string[]+ /**+ * skill_name slug of the scout that authored this report, when scout-authored (from ClickHouse); null otherwise.+ * @nullable+ */+ readonly scout_name: string | null/*** PR URL from the latest implementation task run, if available.* @nullablediff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex c581c80b8846..16118252268d 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -33218,6 +33218,11 @@ export namespace Schemas {readonly is_suggested_reviewer: boolean;/** Distinct source products contributing signals to this report (from ClickHouse). */readonly source_products: readonly string[];+ /**+ * skill_name slug of the scout that authored this report, when scout-authored (from ClickHouse); null otherwise.+ * @nullable+ */+ readonly scout_name: string | null;/*** PR URL from the latest implementation task run, if available.* @nullable