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.

fix(signals): stop labeling a filed inbox report as scout output (#129231)

posthog[bot]3a2a13f4e87d
diff --git a/frontend/src/lib/signals/signalCardSourceLine.test.ts b/frontend/src/lib/signals/signalCardSourceLine.test.ts
new file mode 100644
index 000000000000..5d8fd777b3a8
--- /dev/null
+++ b/frontend/src/lib/signals/signalCardSourceLine.test.ts
@@ -0,0 +1,23 @@
+import { signalCardSourceLine } from './signalCardSourceLine'
+
+describe('signalCardSourceLine', () => {
+ test.each([
+ ['a filed report reads as a team member', 'user_authored', 'cross_source_issue', undefined, 'Team member'],
+ [
+ 'a scout finding names its scout',
+ 'signals_scout',
+ 'cross_source_issue',
+ { skill_name: 'signals-scout-error-tracking' },
+ 'Scout · Error tracking',
+ ],
+ [
+ 'an unknown source falls back to its identifiers',
+ 'new_source',
+ 'some_type',
+ undefined,
+ 'new source · some type',
+ ],
+ ])('%s', (_name, source_product, source_type, extra, expected) => {
+ expect(signalCardSourceLine({ source_product, source_type, extra })).toBe(expected)
+ })
+})
diff --git a/frontend/src/lib/signals/signalCardSourceLine.ts b/frontend/src/lib/signals/signalCardSourceLine.ts
index dd766ac467d5..95103d4a468d 100644
--- a/frontend/src/lib/signals/signalCardSourceLine.ts
+++ b/frontend/src/lib/signals/signalCardSourceLine.ts
@@ -24,6 +24,7 @@ const SOURCE_LINE_BY_PRODUCT = new Map<string, string>([
['session_replay', 'Session replay · Problem segment'],
['replay_vision', 'Replay vision · Scanner finding'],
['health_checks', 'Health checks · Instrumentation issue'],
+ ['user_authored', 'Team member'],
])
// Keyed `${source_product}/${source_type}`.
diff --git a/products/signals/backend/report_generation/resolve_reviewers.py b/products/signals/backend/report_generation/resolve_reviewers.py
index 1922249cd005..eb33e60ddbef 100644
--- a/products/signals/backend/report_generation/resolve_reviewers.py
+++ b/products/signals/backend/report_generation/resolve_reviewers.py
@@ -129,6 +129,7 @@ def enrich_reviewer_dicts_with_org_members(
uuid_to_user: Mapping[str, User] | None = None,
scout_display_names: Mapping[str, str] | None = None,
manual_adders: Sequence[User | None] | None = None,
+ user_authored: bool = False,
) -> list[dict]:
"""Enrich reviewer dicts (from artefact content) with fresh PostHog user info.
@@ -179,7 +180,11 @@ def enrich_reviewer_dicts_with_org_members(
user = resolved_map.get(login.strip().lower())
enriched.append(
_with_reviewer_presentation(
- r, user, scout_display_names, manual_adders[index] if manual_adders is not None else None
+ r,
+ user,
+ scout_display_names,
+ manual_adders[index] if manual_adders is not None else None,
+ user_authored=user_authored,
)
)
@@ -282,7 +287,12 @@ def _commit_explanation(commits: list[object]) -> str:
def _with_reviewer_presentation(
- reviewer: dict, user: User | None, scout_display_names: Mapping[str, str], manual_adder: User | None
+ reviewer: dict,
+ user: User | None,
+ scout_display_names: Mapping[str, str],
+ manual_adder: User | None,
+ *,
+ user_authored: bool = False,
) -> dict:
commits = reviewer.get("relevant_commits")
commit_list: list[object] = commits if isinstance(commits, list) else []
@@ -312,6 +322,10 @@ def _with_reviewer_presentation(
source_label = "Added by teammate"
name = manual_adder.get_full_name().strip() or manual_adder.email if manual_adder else None
explanation = f"Added by {name}" if name else None
+ elif user_authored:
+ # The member who filed the report named this reviewer, so no agent suggested them.
+ source_label = "Added by teammate"
+ explanation = safe_reason
else:
source_label = "Agent suggestion"
explanation = safe_reason
diff --git a/products/signals/backend/scout_harness/tools/report.py b/products/signals/backend/scout_harness/tools/report.py
index f75423ea4392..5034aa5f5837 100644
--- a/products/signals/backend/scout_harness/tools/report.py
+++ b/products/signals/backend/scout_harness/tools/report.py
@@ -1522,9 +1522,9 @@ async def _resolve_report_repository(
one on its own."""
repository = _normalize_repository(repository)
if repository == NO_REPO:
- return RepoSelectionResult(repository=None, reason="Scout passed NO_REPO; report lands without a draft PR.")
+ return RepoSelectionResult(repository=None, reason="No repository selected, so this report has no draft PR.")
if repository is not None:
- return RepoSelectionResult(repository=repository, reason="Repository provided by the scout.")
+ return RepoSelectionResult(repository=repository, reason="Repository named in the report.")
if not wants_full_selection:
connected_repos = await database_sync_to_async(_connected_repositories, thread_sensitive=False)(team_id)
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.py
index 93d853ec5f79..9065380fb8bc 100644
--- a/products/signals/backend/serializers.py
+++ b/products/signals/backend/serializers.py
@@ -3312,6 +3312,12 @@ class SignalReportArtefactSerializer(serializers.ModelSerializer):
def get_actor_kind(self, obj: SignalReportArtefact) -> str:
return obj.actor_kind or SignalActorKind.SYSTEM
+ def _report_is_user_authored(self, obj: SignalReportArtefact) -> bool:
+ user_authored = self.context.get("signals_report_user_authored")
+ if isinstance(user_authored, bool):
+ return user_authored
+ return SignalReport.objects.filter(id=obj.report_id, team_id=obj.team_id, user_authored=True).exists()
+
def get_content(self, obj: SignalReportArtefact) -> dict | list:
try:
parsed = json.loads(obj.content)
@@ -3339,6 +3345,7 @@ class SignalReportArtefactSerializer(serializers.ModelSerializer):
uuid_to_user=reviewer_uuid_map,
scout_display_names=scout_display_names,
manual_adders=trusted_manual_reviewer_adders(obj, parsed, self.context.get("signals_reviewer_history")),
+ user_authored=self._report_is_user_authored(obj),
)
if obj.type in {
diff --git a/products/signals/backend/test/test_resolve_reviewers.py b/products/signals/backend/test/test_resolve_reviewers.py
index d318bb210266..33de780a23b3 100644
--- a/products/signals/backend/test/test_resolve_reviewers.py
+++ b/products/signals/backend/test/test_resolve_reviewers.py
@@ -137,7 +137,11 @@ def test_uuid_reviewer_does_not_fall_back_to_a_reassigned_login(organization, te
assert enriched[0]["user"]["id"] == original.id
-def test_enriches_reviewer_sources_and_explanations():
+ "user_authored, unsourced_label",
+ [(False, "Agent suggestion"), (True, "Added by teammate")],
+)
+def test_enriches_reviewer_sources_and_explanations(user_authored, unsourced_label):
shared_reason = "The checkout parser belongs to the checkout platform team's service."
enriched = enrich_reviewer_dicts_with_org_members(
1,
@@ -183,10 +187,16 @@ def test_enriches_reviewer_sources_and_explanations():
"source_skill": "signals-scout-checkout-reliability",
"is_default_owner": True,
},
+ {
+ "github_login": "named-reviewer",
+ "relevant_commits": [],
+ "reason": "Owns the checkout handler.",
+ },
],
login_to_user={},
uuid_to_user={},
scout_display_names={},
+ user_authored=user_authored,
)
assert enriched[0]["source_label"] == "Code history"
@@ -199,6 +209,8 @@ def test_enriches_reviewer_sources_and_explanations():
assert enriched[4]["explanation"] is None
assert enriched[5]["source_label"] == "Default owner"
assert enriched[5]["explanation"] == "Nobody owns this area yet, so it went to the project's default owner."
+ assert enriched[6]["source_label"] == unsourced_label
+ assert enriched[6]["explanation"] == "Owns the checkout handler."
@pytest.mark.django_db
diff --git a/products/signals/backend/test/test_scout_report_api.py b/products/signals/backend/test/test_scout_report_api.py
index ddf13126ae92..d989859446c2 100644
--- a/products/signals/backend/test/test_scout_report_api.py
+++ b/products/signals/backend/test/test_scout_report_api.py
@@ -3232,6 +3232,21 @@ class TestUserReportCreateAPI(APIBaseTest):
assert (report.user_authored, report.created_by_id) == (True, self.user.id)
assert {call.kwargs["metadata"]["source_product"] for call in embed.call_args_list} == {"user_authored"}
+ def test_reviewer_named_in_a_filed_report_reads_as_added_by_teammate(self) -> None:
+ payload = self._payload(
+ suggested_reviewers=[{"user_uuid": str(self.user.uuid), "reason": "Owns the checkout handler."}]
+ )
+ with _safe_judge(), patch(EMBED_PATH):
+ response = self.client.post(self._url(), payload, format="json")
+ assert response.status_code == status.HTTP_201_CREATED, response.content
+
+ artefacts = self.client.get(f"{self._url()}{response.json()['report_id']}/artefacts/")
+ assert artefacts.status_code == status.HTTP_200_OK, artefacts.content
+ reviewers = next(a["content"] for a in artefacts.json()["results"] if a["type"] == "suggested_reviewers")
+ assert [(r["source_label"], r["explanation"]) for r in reviewers] == [
+ ("Added by teammate", "Owns the checkout handler.")
+ ]
+
@parameterized.expand(
[
("inbox_write", ["inbox:write"], status.HTTP_201_CREATED),
diff --git a/products/signals/backend/views.py b/products/signals/backend/views.py
index 2d30da4d6e67..17d2d3490e5c 100644
--- a/products/signals/backend/views.py
+++ b/products/signals/backend/views.py
@@ -6575,6 +6575,9 @@ class SignalReportArtefactViewSet(
"signals_github_login_to_user_map": login_map,
"signals_reviewer_user_uuid_map": uuid_map,
"signals_scout_display_names": scout_display_names,
+ "signals_report_user_authored": SignalReport.objects.filter(
+ id=self._validated_report_id(), team_id=self.team.id, user_authored=True
+ ).exists(),
"signals_compact_ranking_scores": True,
"signals_reviewer_history": [
artefact