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): fix plan step labels, link lookup and implement button (#122667)

Alex Lebedevb88b5d133408
diff --git a/products/signals/ARCHITECTURE.md b/products/signals/ARCHITECTURE.md
index 50663209d9a2..93cce28862ad 100644
--- a/products/signals/ARCHITECTURE.md
+++ b/products/signals/ARCHITECTURE.md
@@ -1511,7 +1511,7 @@ A `report_link` artefact is one directed row on the report the sentence starts f
`backend/typed_report_links.py` is the read side, and every reader goes through it. Link reads use the writer database to avoid replica delay.
- `outgoing_links` is a seek on `(report, type)`: what this report says about others.
-- `incoming_links` is a team-scoped scan, because `content` is a `TextField` and no row is mirrored. Candidates are narrowed with `content__contains` on the target's UUID and then confirmed by parsing, so a free-text `reason` that quotes a UUID is not an edge to it. A deleted source report is dropped by default; the recurrence chain is the one reader that asks for them, because it walks _through_ deleted intermediates to find the live successor. If the scan ever shows up in query timings, the fix is a materialised target column or a JSON index, not a mirror row.
+- `incoming_links` seeks on `link_target_id`, the target report id that every write and edit copies out of `content`. A backfill migration filled the rows written before the column existed. No row is mirrored onto the target, because the direction is the payload. Candidates are then confirmed by parsing. A deleted source report is dropped by default; the recurrence chain is the one reader that asks for them, because it walks _through_ deleted intermediates to find the live successor.
- `duplicate_chain` follows `duplicate_of` and returns every report on the path, nearest first. A reader deciding whether the cluster is already being worked on needs all of them, because a pull request stays on the report whose run opened it: in A -> B -> C the fix can be in flight on B while C carries none.
- `duplicate_root` returns the last member of that chain, which is the id that names the cluster.
@@ -1535,7 +1535,7 @@ The implementation path checks these gates again under the report lock before ta
**Stacked plans** (`backend/stack_plan.py`). Research can return an optional `layers` plan on `ReportPresentationOutput`: two to six layers, each with a title, a scope, and the index of an earlier layer it depends on. A forward reference falls back to the previous layer, so the order is always acyclic. When the pass settles ready, `mark_report_ready_activity` creates one ready child report per layer in the same transaction. Each child gets the scope as its summary, the plan's latest safety, actionability, priority, repository and reviewer judgments, a `part_of` link to the plan, and a `depends_on` link to its dependency. A layer is born ready without `promoted_at`, like a scout report: it runs no research, so it fires no `signal_report_started`, and the inbox ranking spine takes it in through its born-visible branch. A plan that already has children keeps them on a re-research. The plan itself is held by the `plan_parent` gate, and its settle-point auto-start then starts the layers whose dependencies already have a pull request. After that, each pull request sync on a report queues `start_dependent_stack_layers`, which starts the waiting layers. A layer whose dependency has an open or draft pull request starts on that dependency's automation branch, and the run state carries `stack_base_branch`, so the task launch protects that branch as the PR base instead of the base of the dependency's PR. A merged dependency leaves the layer on the default base. Replacing a whole stack after a lower layer is superseded, a server-side GitHub stack link, and a collapsed inbox list are not built yet.
-**Report detail** (`backend/report_plan.py`). The report detail response carries a `plan` field: the plan the report leads or belongs to, with each step's title, status, primary pull request, and the steps of the same plan it `depends_on`. A report with incoming `part_of` edges is a plan and lists its own steps, even when it is also a step of a larger plan. Otherwise its oldest outgoing `part_of` names the plan. Deleted steps, and dependencies on reports outside the plan, are left out. The field is null in list responses, because the incoming read is a team-scoped scan. The inbox renders it as a Plan block in the summary, after the Solution section, and hides the `## Plan` sentence that `_layer_summary` writes on each layer. The frontend finds that sentence by its text (`isGeneratedPlanSection`), so the two must change together.
+**Report detail** (`backend/report_plan.py`). The report detail response carries a `plan` field: the plan the report leads or belongs to, with each step's title, status, `suppression_source`, primary pull request, and the steps of the same plan it `depends_on`. A report with incoming `part_of` edges is a plan and lists its own steps, even when it is also a step of a larger plan. Otherwise its oldest outgoing `part_of` names the plan. Deleted steps, and dependencies on reports outside the plan, are left out. The field is null in list responses, because it costs several queries per report. The inbox renders it as a Plan block in the summary, after the Solution section, and hides the `## Plan` sentence that `_layer_summary` writes on each layer. The frontend finds that sentence by its text (`isGeneratedPlanSection`), so the two must change together.
**The recurrence chain** (`backend/recurrence.py`) reads incoming `recurrence_of` edges to follow a forked report to its current live successor.
diff --git a/products/signals/backend/migrations/0205_signalreportartefact_link_target.py b/products/signals/backend/migrations/0205_signalreportartefact_link_target.py
new file mode 100644
index 000000000000..51bdbe31b8e7
--- /dev/null
+++ b/products/signals/backend/migrations/0205_signalreportartefact_link_target.py
@@ -0,0 +1,15 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("signals", "0204_report_monitoring_result"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="signalreportartefact",
+ name="link_target_id",
+ field=models.UUIDField(blank=True, null=True),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/0206_signalreportartefact_link_target_index.py b/products/signals/backend/migrations/0206_signalreportartefact_link_target_index.py
new file mode 100644
index 000000000000..d90a41f03c2a
--- /dev/null
+++ b/products/signals/backend/migrations/0206_signalreportartefact_link_target_index.py
@@ -0,0 +1,22 @@
+from django.db import migrations, models
+
+from posthog.migration_helpers import SafeAddIndexConcurrently
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [
+ ("signals", "0205_signalreportartefact_link_target"),
+ ]
+
+ operations = [
+ SafeAddIndexConcurrently(
+ model_name="signalreportartefact",
+ index=models.Index(
+ condition=models.Q(("type", "report_link")),
+ fields=["link_target_id"],
+ name="signals_link_target_idx",
+ ),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/0207_backfill_report_link_targets.py b/products/signals/backend/migrations/0207_backfill_report_link_targets.py
new file mode 100644
index 000000000000..894002785b9e
--- /dev/null
+++ b/products/signals/backend/migrations/0207_backfill_report_link_targets.py
@@ -0,0 +1,51 @@
+import json
+import uuid
+
+from django.db import migrations
+
+
+def _link_target(content: str) -> str | None:
+ """The canonical id of the report a `report_link` row names, or None when the row does not parse.
+
+ The parsing is repeated here rather than taken from `ReportLink`, because what an applied
+ migration did must not change when the live schema changes. A row that does not parse names no
+ edge for any reader, so leaving it null loses nothing.
+ """
+ try:
+ parsed = json.loads(content)
+ except (json.JSONDecodeError, TypeError, ValueError):
+ return None
+ if not isinstance(parsed, dict):
+ return None
+ try:
+ return str(uuid.UUID(str(parsed.get("report_id"))))
+ except ValueError:
+ return None
+
+
+def backfill_report_link_targets(apps, schema_editor):
+ """Fill `link_target_id` on every `report_link` row written before the column existed.
+
+ Reports link rarely, so the rows are few: one pass reads them all, and one UPDATE per target
+ fills them.
+ """
+ SignalReportArtefact = apps.get_model("signals", "SignalReportArtefact")
+ unfilled = SignalReportArtefact.objects.filter(type="report_link", link_target_id__isnull=True)
+ ids_by_target: dict[str, list[uuid.UUID]] = {}
+ for artefact_id, content in unfilled.values_list("id", "content").iterator(chunk_size=1000):
+ target = _link_target(content)
+ if target is not None:
+ ids_by_target.setdefault(target, []).append(artefact_id)
+ for target, ids in ids_by_target.items():
+ # `update()`, not `save()`, so filling the column does not bump `updated_at`.
+ unfilled.filter(id__in=ids).update(link_target_id=target)
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("signals", "0206_signalreportartefact_link_target_index"),
+ ]
+
+ operations = [
+ migrations.RunPython(backfill_report_link_targets, migrations.RunPython.noop),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index 9ad0218fcc9c..815a011c5b13 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0204_report_monitoring_result
+0207_backfill_report_link_targets
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index 3e91917ce679..8cbaf6f03d8d 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -1535,6 +1535,11 @@ class SignalReportArtefact(UUIDModel):
db_index=False,
related_name="+",
)
+ # The report a `report_link` row points at, copied out of `content` on every write, so finding
+ # the links that point at a report is an index seek instead of a text search of the team's link
+ # rows. Null on every other type. A plain id, not a foreign key, because the row is the source
+ # report's record of what it said, and `content` keeps naming the target after the target is gone.
+ link_target_id = models.UUIDField(null=True, blank=True)
class Meta:
indexes = [
@@ -1555,6 +1560,11 @@ class SignalReportArtefact(UUIDModel):
condition=models.Q(type="implementation_decision"),
name="signals_dispatch_sweep_idx",
),
+ models.Index(
+ fields=["link_target_id"],
+ condition=models.Q(type="report_link"),
+ name="signals_link_target_idx",
+ ),
]
@classmethod
@@ -1670,6 +1680,7 @@ class SignalReportArtefact(UUIDModel):
task_id=attribution.task_id,
claim_id=claim_id,
channel_id=content.channel_id if isinstance(content, ChannelAssignment) else None,
+ link_target_id=content.report_id if isinstance(content, ReportLink) else None,
)
@classmethod
@@ -2198,6 +2209,9 @@ class SignalReportArtefact(UUIDModel):
if isinstance(parsed, ChannelAssignment):
self.channel_id = parsed.channel_id
update_fields.append("channel_id")
+ if isinstance(parsed, ReportLink):
+ self.link_target_id = parsed.report_id
+ update_fields.append("link_target_id")
self.save(update_fields=update_fields)
if self.type == SignalReportArtefact.ArtefactType.SUGGESTED_REVIEWERS:
self._schedule_autostart_reevaluation(team_id=self.team_id, report_id=str(self.report_id))
diff --git a/products/signals/backend/report_plan.py b/products/signals/backend/report_plan.py
index c4b956f6e912..38bc7e1319d1 100644
--- a/products/signals/backend/report_plan.py
+++ b/products/signals/backend/report_plan.py
@@ -2,7 +2,7 @@
A plan is a report that other reports point at with a `part_of` link. Research writes these links
when it splits work into stacked layers (`stack_plan.py`), and scouts can write them too. A link
-lives only on the step, so finding a plan's steps is an incoming-link scan.
+lives only on the step, so finding a plan's steps is an incoming-link read.
"""
from posthog.dataclasses import frozen
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.py
index 58586cb89687..29cf88a8c9f4 100644
--- a/products/signals/backend/serializers.py
+++ b/products/signals/backend/serializers.py
@@ -5,7 +5,7 @@ from collections.abc import Mapping
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, cast
-from django.db.models import TextChoices
+from django.db.models import Prefetch, TextChoices
from django.utils import timezone
import structlog
@@ -67,7 +67,7 @@ if TYPE_CHECKING:
from products.signals.backend.implementation_pr import ImplementationPr
from products.signals.backend.report_claims import ReportClaim
- from products.signals.backend.report_plan import ReportPlan
+ from products.signals.backend.report_plan import ReportPlan, ReportPlanStep
from .artefact_schemas import (
NON_WRITABLE_ARTEFACT_TYPES,
@@ -1416,6 +1416,13 @@ class ReportPlanStepSerializer(serializers.Serializer):
allow_null=True,
help_text="Latest known state of that pull request: unknown, draft, open, closed, or merged.",
)
+ suppression_source = serializers.SerializerMethodField(
+ help_text="Who or what suppressed the step, with the same values as the report's `suppression_source`. Null unless the step is suppressed.",
+ )
+
+ @extend_schema_field(serializers.ChoiceField(choices=SignalReportSuppressionSource.choices, allow_null=True))
+ def get_suppression_source(self, step: "ReportPlanStep") -> str | None:
+ return self.context.get("step_suppression_sources", {}).get(step.id)
class ReportPlanSerializer(serializers.Serializer):
@@ -1639,7 +1646,7 @@ class SignalReportSerializer(serializers.ModelSerializer):
help_text=(
"The plan this report leads or is a step of, with every step in it. A report that other reports "
"link to with `part_of` is a plan. Null when the report is in no plan, and always null in list "
- "responses, because finding a plan's steps scans the project's report links."
+ "responses, because finding a plan's steps costs several queries per report."
),
)
@@ -1737,7 +1744,30 @@ class SignalReportSerializer(serializers.ModelSerializer):
dataclasses.replace(step, status=self._display_status(obj, step.status)) for step in plan.steps
),
)
- return dict(ReportPlanSerializer(plan).data)
+ suppressed_step_ids = [step.id for step in plan.steps if step.status == SignalReport.Status.SUPPRESSED]
+ step_suppression_sources = {
+ str(step_report.id): suppression[0].value
+ for step_report in SignalReport.objects.filter(
+ team_id=obj.team_id, id__in=suppressed_step_ids
+ ).prefetch_related(*self._suppression_prefetches())
+ if (suppression := self._suppression(step_report)) is not None
+ }
+ return dict(ReportPlanSerializer(plan, context={"step_suppression_sources": step_suppression_sources}).data)
+
+ @staticmethod
+ def _suppression_prefetches() -> list[Prefetch]:
+ return [
+ Prefetch(
+ "artefacts",
+ queryset=SignalReportArtefact.objects.filter(type=artefact_type).order_by("-created_at"),
+ to_attr=to_attr,
+ )
+ for artefact_type, to_attr in (
+ (SignalReportArtefact.ArtefactType.DISMISSAL, "prefetched_dismissal_artefacts"),
+ (SignalReportArtefact.ArtefactType.SAFETY_JUDGMENT, "prefetched_safety_artefacts"),
+ (SignalReportArtefact.ArtefactType.ACTIONABILITY_JUDGMENT, "prefetched_actionability_artefacts"),
+ )
+ ]
def _get_actionability_artefact_data(self, obj: SignalReport) -> dict | None:
prefetched = getattr(obj, "prefetched_actionability_artefacts", None)
diff --git a/products/signals/backend/test/test_report_links.py b/products/signals/backend/test/test_report_links.py
index e8bb010ad6b7..e1f4138fe900 100644
--- a/products/signals/backend/test/test_report_links.py
+++ b/products/signals/backend/test/test_report_links.py
@@ -87,6 +87,17 @@ class TestReportLinkReaders(BaseTest):
assert [edge.kind for edge in edges] == [ReportLinkKind.FOLLOW_UP_OF]
assert good.id is not None
+ def test_an_edited_link_reads_from_the_report_it_now_names(self):
+ source, earlier_target, target = self._report("source"), self._report("earlier"), self._report("target")
+ link = self._link(source, earlier_target, ReportLinkKind.PART_OF)
+
+ link.update_content({"kind": "part_of", "report_id": str(target.id)})
+
+ assert incoming_links(team_id=self.team.id, report_id=earlier_target.id) == []
+ assert [edge.source_id for edge in incoming_links(team_id=self.team.id, report_id=target.id)] == [
+ str(source.id)
+ ]
+
def test_a_reason_that_quotes_the_uuid_is_not_an_edge_to_it(self):
source, target, bystander = self._report("source"), self._report("target"), self._report("bystander")
self._link(source, bystander, ReportLinkKind.DEPENDS_ON, reason=f"not the same as {target.id}")
diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.py
index abb9f0f6beb5..b7d80825da53 100644
--- a/products/signals/backend/test/test_signal_report_api.py
+++ b/products/signals/backend/test/test_signal_report_api.py
@@ -808,12 +808,20 @@ class TestSignalReportListAPI(APIBaseTest):
def test_plan_shows_on_the_detail_of_a_step_and_not_in_the_list(self):
plan = self._create_report(title="feat(x): the plan")
step = self._create_report(title="feat(x): a step")
- SignalReportArtefact.add_log(
- team_id=self.team.id,
- report_id=str(step.id),
- content=ReportLink(kind=ReportLinkKind.PART_OF, report_id=str(plan.id)),
- attribution=ArtefactAttribution.system(),
- )
+ held_back_step = self._create_report(title="feat(x): a held back step", status=SignalReport.Status.SUPPRESSED)
+ SignalReportArtefact.objects.create(
+ team=self.team,
+ report=held_back_step,
+ type=SignalReportArtefact.ArtefactType.SAFETY_JUDGMENT,
+ content=json.dumps({"choice": False, "explanation": "Asks to disable a safety control."}),
+ )
+ for step_report in (step, held_back_step):
+ SignalReportArtefact.add_log(
+ team_id=self.team.id,
+ report_id=str(step_report.id),
+ content=ReportLink(kind=ReportLinkKind.PART_OF, report_id=str(plan.id)),
+ attribution=ArtefactAttribution.system(),
+ )
detail = self.client.get(f"/api/projects/{self.team.id}/signals/reports/{step.id}/").json()
assert detail["plan"] == {
@@ -828,7 +836,17 @@ class TestSignalReportListAPI(APIBaseTest):
"depends_on": [],
"implementation_pr_url": None,
"implementation_pr_state": None,
- }
+ "suppression_source": None,
+ },
+ {
+ "id": str(held_back_step.id),
+ "title": "feat(x): a held back step",
+ "status": "suppressed",
+ "depends_on": [],
+ "implementation_pr_url": None,
+ "implementation_pr_state": None,
+ "suppression_source": "safety_judge",
+ },
],
}
row = next(r for r in self.client.get(self._list_url()).json()["results"] if r["id"] == str(step.id))
diff --git a/products/signals/backend/typed_report_links.py b/products/signals/backend/typed_report_links.py
index ec64d52766e8..06ea7516d7ff 100644
--- a/products/signals/backend/typed_report_links.py
+++ b/products/signals/backend/typed_report_links.py
@@ -6,11 +6,9 @@ live on `SignalReportArtefact`. Every reader goes through this module instead of
itself, so the tolerance for a row that no longer parses, the graph budgets, and the direction
vocabulary are decided once.
-Reading outgoing edges is a seek on `(report, type)`. Reading incoming edges is a team-scoped scan,
-because `content` is a `TextField` and nothing mirrors the row onto the target: the candidate rows
-are narrowed with a `content__contains` on the target's UUID and then confirmed by parsing. Links
-are rare and team-scoped, so the scan is cheap. If it ever shows up in query timings, the fix is a
-materialised target column or a JSON index, not a mirror row, because the direction is the payload.
+Reading outgoing edges is a seek on `(report, type)`. Reading incoming edges is a seek on
+`link_target_id`, which every write copies out of `content`, and the candidates are then confirmed by
+parsing. Nothing mirrors the row onto the target, because the direction is the payload.
"""
import uuid
@@ -124,7 +122,7 @@ def incoming_links(
candidates = SignalReportArtefact.objects.using("default").filter(
team_id=team_id,
type=SignalReportArtefact.ArtefactType.REPORT_LINK,
- content__contains=target_id,
+ link_target_id=target_id,
)
if not include_deleted_sources:
candidates = candidates.exclude(report__status=SignalReport.Status.DELETED)
@@ -133,8 +131,7 @@ def incoming_links(
: SignalReportArtefact.MAX_REPORT_LINK_GRAPH_ROWS
]
)
- # `content__contains` also matches a row whose free-text `reason` quotes the UUID, so the
- # parsed target decides.
+ # `link_target_id` is a copy of the target in `content`, so the parsed target decides if they differ.
return [edge for edge in _edges_from_rows(rows, kinds=kinds) if edge.target_id == target_id]
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 5d025ba15a50..01c549a07838 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -2116,6 +2116,8 @@ export interface ReportPlanStepApi {
* * `closed` - Closed
* * `merged` - Merged */
readonly implementation_pr_state: SignalReportAssignmentPrStateEnumApi | null
+ /** Who or what suppressed the step, with the same values as the report's `suppression_source`. Null unless the step is suppressed. */
+ readonly suppression_source: SignalReportSuppressionSourceEnumApi | null
}
export interface ReportPlanApi {
@@ -2270,7 +2272,7 @@ export interface SignalReportListApi {
readonly channel_id: string | null
/** The served ranking model's predictions from the latest ranking score artefact. Its status says whether the report is scored, stale or unscored, or that the user cannot see the ranking model. */
readonly ranking: ReportRankingApi
- /** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps scans the project's report links. */
+ /** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps costs several queries per report. */
readonly plan: ReportPlanApi | null
/**
* Coarse sort key from the ranker named by the list response's ranker field, for sort=recommended only. Lower keys rank first. It is the score decile of the ranker's outcome (open, action or fix), then the priority as a tiebreak. The priority ranker uses the priority only. Reports without a usable score sort after scored ones. Null for every other sort.
@@ -2520,7 +2522,7 @@ export interface SignalReportApi {
readonly channel_id: string | null
/** The served ranking model's predictions from the latest ranking score artefact. Its status says whether the report is scored, stale or unscored, or that the user cannot see the ranking model. */
readonly ranking: ReportRankingApi
- /** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps scans the project's report links. */
+ /** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps costs several queries per report. */
readonly plan: ReportPlanApi | null
}
diff --git a/products/signals/frontend/inbox/components/detail/InboxDetail.stories.tsx b/products/signals/frontend/inbox/components/detail/InboxDetail.stories.tsx
index 964fe8ddbd35..91de1997a6d0 100644
--- a/products/signals/frontend/inbox/components/detail/InboxDetail.stories.tsx
+++ b/products/signals/frontend/inbox/components/detail/InboxDetail.stories.tsx
@@ -394,6 +394,7 @@ const exportsPlan: ReportPlanApi = {
depends_on: [],
implementation_pr_url: 'https://github.com/example/app/pull/41',
implementation_pr_state: 'merged',
+ suppression_source: null,
},
{
id: '019e64b8-0000-7000-8000-000000000212',
@@ -402,6 +403,7 @@ const exportsPlan: ReportPlanApi = {
depends_on: ['019e64b8-0000-7000-8000-000000000211'],
implementation_pr_url: 'https://github.com/example/app/pull/42',
implementation_pr_state: 'open',
+ suppression_source: null,
},
{
id: '019e64b8-0000-7000-8000-000000000213',
@@ -410,6 +412,7 @@ const exportsPlan: ReportPlanApi = {
depends_on: ['019e64b8-0000-7000-8000-000000000212'],
implementation_pr_url: null,
implementation_pr_state: null,
+ suppression_source: null,
},
],
}
diff --git a/products/signals/frontend/inbox/components/detail/ReportPlanBlock.tsx b/products/signals/frontend/inbox/components/detail/ReportPlanBlock.tsx
index 6abefbe3bc57..1c7412483217 100644
--- a/products/signals/frontend/inbox/components/detail/ReportPlanBlock.tsx
+++ b/products/signals/frontend/inbox/components/detail/ReportPlanBlock.tsx
@@ -60,7 +60,10 @@ export function ReportPlanBlock({ reportId, plan }: { reportId: string; plan: Re
{title}
</Link>
)}
- <SignalReportStatusBadge status={step.status as SignalReportStatus} />
+ <SignalReportStatusBadge
+ status={step.status as SignalReportStatus}
+ suppressionSource={step.suppression_source}
+ />
{prNumber ? (
<PrBadge
prNumber={prNumber}
diff --git a/products/signals/frontend/inbox/utils/reportActions.test.ts b/products/signals/frontend/inbox/utils/reportActions.test.ts
index bdde8c96c8f5..795ecd5f920f 100644
--- a/products/signals/frontend/inbox/utils/reportActions.test.ts
+++ b/products/signals/frontend/inbox/utils/reportActions.test.ts
@@ -1,7 +1,7 @@
import { SignalReport, SignalReportStatus } from '../types'
-import { canMonitorReport, canResolveReport } from './reportActions'
+import { canCreateImplementationPr, canMonitorReport, canResolveReport } from './reportActions'
-describe('canResolveReport', () => {
+describe('reportActions', () => {
it.each([
[SignalReportStatus.READY, true],
[SignalReportStatus.PENDING_INPUT, true],
@@ -38,4 +38,18 @@ describe('canResolveReport', () => {
)
).toBe(hasFollowUpChecks)
})
+
+ it.each([
+ ['the plan itself', false, 'report'],
+ ['a step of a plan', true, 'plan'],
+ ] as const)('offers implementation on %s: %s', (_, expected, planId) => {
+ const report = {
+ id: 'report',
+ status: SignalReportStatus.READY,
+ actionability: 'immediately_actionable',
+ plan: { id: planId, title: 'Plan', status: 'ready', steps: [] },
+ } as unknown as SignalReport
+
+ expect(canCreateImplementationPr(report)).toBe(expected)
+ })
})
diff --git a/products/signals/frontend/inbox/utils/reportActions.ts b/products/signals/frontend/inbox/utils/reportActions.ts
index cd63313fb4e2..2420b3d0f1db 100644
--- a/products/signals/frontend/inbox/utils/reportActions.ts
+++ b/products/signals/frontend/inbox/utils/reportActions.ts
@@ -23,6 +23,11 @@ export function canCreateImplementationPr(report: SignalReport): boolean {
if (report.already_addressed === true) {
return false
}
+ // A plan's steps do its work, so a run on the plan itself would repeat theirs. Auto-start skips a
+ // plan for the same reason. List rows carry no `plan`, so only a loaded report can tell.
+ if (report.plan?.id === report.id) {
+ return false
+ }
if (report.status === 'pending_input') {
return true
}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index fa1492e612d8..1cde3b0ff299 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -79749,6 +79749,8 @@ export namespace Schemas {
* * `closed` - Closed
* * `merged` - Merged */
readonly implementation_pr_state: SignalReportAssignmentPrStateEnum | null;
+ /** Who or what suppressed the step, with the same values as the report's `suppression_source`. Null unless the step is suppressed. */
+ readonly suppression_source: SignalReportSuppressionSourceEnum | null;
}
export interface ReportPlan {
@@ -79903,7 +79905,7 @@ export namespace Schemas {
readonly channel_id: string | null;
/** The served ranking model's predictions from the latest ranking score artefact. Its status says whether the report is scored, stale or unscored, or that the user cannot see the ranking model. */
readonly ranking: ReportRanking;
- /** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps scans the project's report links. */
+ /** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps costs several queries per report. */
readonly plan: ReportPlan | null;
/**
* Coarse sort key from the ranker named by the list response's ranker field, for sort=recommended only. Lower keys rank first. It is the score decile of the ranker's outcome (open, action or fix), then the priority as a tiebreak. The priority ranker uses the priority only. Reports without a usable score sort after scored ones. Null for every other sort.
@@ -102524,7 +102526,7 @@ export namespace Schemas {
readonly channel_id: string | null;
/** The served ranking model's predictions from the latest ranking score artefact. Its status says whether the report is scored, stale or unscored, or that the user cannot see the ranking model. */
readonly ranking: ReportRanking;
- /** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps scans the project's report links. */
+ /** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps costs several queries per report. */
readonly plan: ReportPlan | null;
}