: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): hide PR action for repository-less scout improvements (#123695)
Dylan Martinc320fb64251f
diff --git a/packages/agent/packages/agent-contracts/src/domain-types.ts b/packages/agent/packages/agent-contracts/src/domain-types.tsindex 0271a504a55e..2acc07d14306 100644--- a/packages/agent/packages/agent-contracts/src/domain-types.ts+++ b/packages/agent/packages/agent-contracts/src/domain-types.ts@@ -786,6 +786,10 @@ export interface SignalReport {is_suggested_reviewer?: boolean;/** Distinct source products contributing signals to this report. */source_products?: string[];+ /** Whether the report proposes an improvement to a scout. */+ is_self_improvement_report?: boolean;+ /** Selected code repository, when the report has one. */+ repo_slug?: string | null;/** PR URL from the latest implementation task run, if available. */implementation_pr_url?: string | null;work_state?: "unclaimed" | "working" | "in_review" | "done";diff --git a/products/desktop/packages/core/src/inbox/reportActions.test.ts b/products/desktop/packages/core/src/inbox/reportActions.test.tsindex 91445921461c..a974f6e08b0a 100644--- a/products/desktop/packages/core/src/inbox/reportActions.test.ts+++ b/products/desktop/packages/core/src/inbox/reportActions.test.ts@@ -263,6 +263,28 @@ describe("buildDiscussReportPrompt", () => {});describe("canCreateImplementationPr", () => {+ it("does not offer a pull request for a scout self-improvement report without a repository", () => {+ const report = {+ id: "r",+ status: "pending_input",+ is_self_improvement_report: true,+ repo_slug: null,+ } as Partial<SignalReport> as SignalReport;++ expect(canCreateImplementationPr(report)).toBe(false);+ });++ it("offers a pull request for a scout self-improvement report with a repository", () => {+ const report = {+ id: "r",+ status: "pending_input",+ is_self_improvement_report: true,+ repo_slug: "posthog/posthog",+ } as Partial<SignalReport> as SignalReport;++ expect(canCreateImplementationPr(report)).toBe(true);+ });+it("a merged PR no longer blocks a fresh attempt, but an open one does", () => {const base = {id: "r",diff --git a/products/desktop/packages/core/src/inbox/reportActions.ts b/products/desktop/packages/core/src/inbox/reportActions.tsindex c382b66d2667..9e82001b5e4a 100644--- a/products/desktop/packages/core/src/inbox/reportActions.ts+++ b/products/desktop/packages/core/src/inbox/reportActions.ts@@ -17,6 +17,9 @@ export function canCreateImplementationPr(isTaskLookupPending?: boolean;} = {},): boolean {+ if (report.is_self_improvement_report && !report.repo_slug) {+ return false;+ }if (context.hasLiveImplementationTask || context.isTaskLookupPending) {return false;}diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.pyindex 29cf88a8c9f4..95a335916e1d 100644--- a/products/signals/backend/serializers.py+++ b/products/signals/backend/serializers.py@@ -58,6 +58,7 @@ from products.signals.backend.report_checks import ()from products.signals.backend.report_content_gates import team_report_monitoring_enabledfrom products.signals.backend.reviewer_rules import ReviewerRules+from products.signals.backend.scout_harness.tools.report import is_self_improvement_titlefrom products.warehouse_sources.backend.facade.models import ExternalDataSchemafrom products.warehouse_sources.backend.facade.types import ExternalDataSchemaStatus@@ -1564,6 +1565,12 @@ class SignalReportSerializer(serializers.ModelSerializer):"artefact (when present). Lets list cards show repository context without a per-card fetch."),)+ is_self_improvement_report = serializers.SerializerMethodField(+ help_text=(+ "Whether this is a scout self-improvement report. Most update a team-owned skill in the skills "+ "store, but reports with a selected repository can still produce a pull request."+ ),+ )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).",@@ -1680,6 +1687,7 @@ class SignalReportSerializer(serializers.ModelSerializer):"suppression_source","suppression_explanation","repo_slug",+ "is_self_improvement_report","is_suggested_reviewer","source_products","scout_name",@@ -1790,6 +1798,9 @@ class SignalReportSerializer(serializers.ModelSerializer):def get_summary_lead(self, obj: SignalReport) -> str:return summary_lead(obj.summary, SUMMARY_LEAD_LIMIT)+ def get_is_self_improvement_report(self, obj: SignalReport) -> bool:+ return is_self_improvement_title(obj.title)+def get_priority(self, obj: SignalReport) -> str | None:prefetched = getattr(obj, "prefetched_priority_artefacts", None)if prefetched is not None:diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex b7d80825da53..68c1146a487c 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -3083,6 +3083,21 @@ class TestSignalReportListAPI(APIBaseTest):row = next(r for r in response.json()["results"] if r["id"] == str(report.id))assert row["repo_slug"] is None+ @parameterized.expand(+ [+ ("Scout self-improvement: signals-scout-errors - noisy rule", True),+ ("Error rate increased", False),+ ]+ )+ def test_list_classifies_scout_self_improvement_reports(self, title: str, expected: bool):+ report = self._create_report(title=title)++ response = self.client.get(self._list_url())++ 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["is_self_improvement_report"] is expected+class TestAssociatedTaskRunsForReports(APIBaseTest):"""`SignalReport.associated_task_runs_for_reports` — the batched, page-wide counterpart ofdiff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 01c549a07838..08c5e79dfe62 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -2217,6 +2217,8 @@ export interface SignalReportListApi {* @nullable*/readonly repo_slug: string | null+ /** Whether this is a scout self-improvement report. Most update a team-owned skill in the skills store, but reports with a selected repository can still produce a pull request. */+ readonly is_self_improvement_report: booleanreadonly is_suggested_reviewer: boolean/** Distinct source products contributing signals to this report (from ClickHouse). */readonly source_products: readonly string[]@@ -2467,6 +2469,8 @@ export interface SignalReportApi {* @nullable*/readonly repo_slug: string | null+ /** Whether this is a scout self-improvement report. Most update a team-owned skill in the skills store, but reports with a selected repository can still produce a pull request. */+ readonly is_self_improvement_report: booleanreadonly is_suggested_reviewer: boolean/** Distinct source products contributing signals to this report (from ClickHouse). */readonly source_products: readonly string[]diff --git a/products/signals/frontend/inbox/types.ts b/products/signals/frontend/inbox/types.tsindex 36339b568700..d26f87e70598 100644--- a/products/signals/frontend/inbox/types.ts+++ b/products/signals/frontend/inbox/types.ts@@ -125,6 +125,10 @@ export interface SignalReport extends Pick<SignalReportApi, 'monitoring_started_source_products?: string[]/** skill_name slug of the authoring scout, when scout-authored (raw slug — prettify with `scoutDisplayName`). */scout_name?: string | null+ /** Whether the report proposes an improvement to a scout. */+ is_self_improvement_report?: boolean+ /** Selected code repository, when the report has one. */+ repo_slug?: string | null/** PR URL from the latest implementation task run, if available. */implementation_pr_url?: string | null/** Whether that implementation PR is merged, per the GitHub webhook. Status doesn't imply it: adiff --git a/products/signals/frontend/inbox/utils/reportActions.test.ts b/products/signals/frontend/inbox/utils/reportActions.test.tsindex 795ecd5f920f..e302e501df5b 100644--- a/products/signals/frontend/inbox/utils/reportActions.test.ts+++ b/products/signals/frontend/inbox/utils/reportActions.test.ts@@ -52,4 +52,18 @@ describe('reportActions', () => {expect(canCreateImplementationPr(report)).toBe(expected)})++ it.each([+ ['without a repository', null, false],+ ['with a repository', 'posthog/posthog', true],+ ] as const)('offers implementation on a scout self-improvement report %s: %s', (_, repoSlug, expected) => {+ expect(+ canCreateImplementationPr({+ id: 'report',+ status: SignalReportStatus.PENDING_INPUT,+ is_self_improvement_report: true,+ repo_slug: repoSlug,+ } as SignalReport)+ ).toBe(expected)+ })})diff --git a/products/signals/frontend/inbox/utils/reportActions.ts b/products/signals/frontend/inbox/utils/reportActions.tsindex 2420b3d0f1db..087ba4975b35 100644--- a/products/signals/frontend/inbox/utils/reportActions.ts+++ b/products/signals/frontend/inbox/utils/reportActions.ts@@ -17,6 +17,9 @@ export function canUnassignMe(report: SignalReport, isScopedToMe: boolean): bool* the server-side autostart rules: only when ready & actionable, or blocked on user input.*/export function canCreateImplementationPr(report: SignalReport): boolean {+ if (report.is_self_improvement_report && !report.repo_slug) {+ return false+ }if (primaryReportPullRequest(report).url) {return false}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 40821625b1a8..893b36953afc 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -79995,6 +79995,8 @@ export namespace Schemas {* @nullable*/readonly repo_slug: string | null;+ /** Whether this is a scout self-improvement report. Most update a team-owned skill in the skills store, but reports with a selected repository can still produce a pull request. */+ readonly is_self_improvement_report: boolean;readonly is_suggested_reviewer: boolean;/** Distinct source products contributing signals to this report (from ClickHouse). */readonly source_products: readonly string[];@@ -102760,6 +102762,8 @@ export namespace Schemas {* @nullable*/readonly repo_slug: string | null;+ /** Whether this is a scout self-improvement report. Most update a team-owned skill in the skills store, but reports with a selected repository can still produce a pull request. */+ readonly is_self_improvement_report: boolean;readonly is_suggested_reviewer: boolean;/** Distinct source products contributing signals to this report (from ClickHouse). */readonly source_products: readonly string[];