: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): allow editing report priority in the inbox (#114869)
Mikayla Thompsonf339527d3ede
diff --git a/docs/internal/inbox-ranking-training.md b/docs/internal/inbox-ranking-training.mdindex 4d353538775a..d99b5a4abab2 100644--- a/docs/internal/inbox-ranking-training.md+++ b/docs/internal/inbox-ranking-training.md@@ -1,5 +1,11 @@# Inbox ranking training examples+Priority edits in the web inbox append a `priority_judgment` artefact instead of changing the original assessment.+The correction's `adjustment` records `previous_priority`, `previous_judgment_id`, and `source="inbox_sidebar"`.+The artefact's team/report IDs, creation timestamp, and actor attribution identify the correction and its author; the linked judgment retains the original explanation and dollar estimate.+Selecting the current priority adds no correction. These records are available for future priority learning; they do not introduce a new ranking label or training head.+Research already running when a priority is edited preserves that correction; a later research run can reassess it.+The report-embedding and title-embedding ranking families use one example per report per head, from the report's birth-day snapshot.This prevents long-lived reports from receiving more weight in training because they appear in more daily snapshots.Birth days use the UTC interval returned by `snapshot_bounds`, including the start and excluding the end.diff --git a/products/signals/backend/artefact_schemas.py b/products/signals/backend/artefact_schemas.pyindex 9c695be0fa2e..e2e518d6818c 100644--- a/products/signals/backend/artefact_schemas.py+++ b/products/signals/backend/artefact_schemas.py@@ -148,6 +148,12 @@ def priority_from_judgment(content: str | None) -> str | None:return priority if isinstance(priority, str) else None+class PriorityAdjustment(BaseModel):+ previous_priority: Priority | None+ previous_judgment_id: UUID | None+ source: Literal["inbox_sidebar"] = "inbox_sidebar"++class PriorityAssessment(BaseModel):"""Content schema for a `priority_judgment` artefact."""@@ -160,6 +166,11 @@ class PriorityAssessment(BaseModel):),)priority: Priority = Field(description="Priority (P0-P4)")+ adjustment: PriorityAdjustment | None = Field(+ default=None,+ exclude_if=lambda adjustment: adjustment is None,+ description="Correction metadata recorded when a person changes the priority in the inbox.",+ )dollar_value: float | None = Field(default=None,description=(diff --git a/products/signals/backend/report_priority.py b/products/signals/backend/report_priority.pynew file mode 100644index 000000000000..f8cc4facb71f--- /dev/null+++ b/products/signals/backend/report_priority.py@@ -0,0 +1,39 @@+from django.db import transaction++from products.signals.backend.artefact_attribution import ArtefactAttribution+from products.signals.backend.artefact_schemas import PriorityAdjustment, PriorityAssessment, priority_from_judgment+from products.signals.backend.enums import ReportPriority+from products.signals.backend.models import SignalReport, SignalReportArtefact+++def update_report_priority(*, report: SignalReport, priority: ReportPriority, attribution: ArtefactAttribution) -> None:+ with transaction.atomic():+ SignalReport.objects.select_for_update().get(id=report.id, team_id=report.team_id)+ previous = (+ SignalReportArtefact.objects.filter(+ team_id=report.team_id,+ report_id=report.id,+ type=SignalReportArtefact.ArtefactType.PRIORITY_JUDGMENT,+ )+ .order_by("-created_at", "-id")+ .first()+ )+ previous_priority = priority_from_judgment(previous.content) if previous else None+ if previous_priority == priority:+ return+ SignalReportArtefact.append_status(+ team_id=report.team_id,+ report_id=str(report.id),+ attribution=attribution,+ content=PriorityAssessment(+ priority=priority,+ explanation="Priority changed in the inbox.",+ adjustment=PriorityAdjustment(+ previous_priority=ReportPriority(previous_priority)+ if previous_priority in [value.value for value in ReportPriority]+ else None,+ previous_judgment_id=previous.id if previous else None,+ ),+ ),+ )+ report.save(update_fields=["updated_at"])diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.pyindex 06953d78539c..e38da9ba8879 100644--- a/products/signals/backend/serializers.py+++ b/products/signals/backend/serializers.py@@ -1190,6 +1190,13 @@ class ReportRankingSerializer(serializers.Serializer):)+class SignalReportPriorityUpdateSerializer(serializers.Serializer):+ priority = serializers.ChoiceField(+ choices=AutonomyPriority.choices,+ help_text="New report priority, from P0 (critical) to P4 (minimal).",+ )++class SignalReportSerializer(serializers.ModelSerializer):artefact_count = serializers.IntegerField(read_only=True)charts = ReportChartSerializer(diff --git a/products/signals/backend/temporal/agentic/report.py b/products/signals/backend/temporal/agentic/report.pyindex 2a971ec5d5cf..0fb4a0312d85 100644--- a/products/signals/backend/temporal/agentic/report.py+++ b/products/signals/backend/temporal/agentic/report.py@@ -628,7 +628,31 @@ def _reviewer_selection_written_since(team_id: int, report_id: str, since: datet).exists()-def _append_agentic_report_artefacts(*, team_id: int, report_id: str, artefacts: list[ArtefactDraft]) -> bool:+def _priority_adjusted_since(team_id: int, report_id: str, priority_judgment_id: UUID | None) -> bool:+ judgments = SignalReportArtefact.objects.filter(+ team_id=team_id,+ report_id=report_id,+ type=SignalReportArtefact.ArtefactType.PRIORITY_JUDGMENT,+ ).order_by("-created_at", "-id")+ for judgment_id, content in judgments.values_list("id", "content").iterator():+ if judgment_id == priority_judgment_id:+ break+ try:+ assessment = PriorityAssessment.model_validate_json(content)+ except ValidationError:+ continue+ if assessment.adjustment is not None:+ return True+ return False+++def _append_agentic_report_artefacts(+ *,+ team_id: int,+ report_id: str,+ artefacts: list[ArtefactDraft],+ priority_judgment_id: UUID | None = None,+) -> bool:# Append-only: each (re-promotion) run adds a new version of its artefacts rather than# replacing the previous ones. The report's current judgments / repo selection / reviewers are# the latest row of each type; findings are keyed by `signal_id` (latest per signal wins).@@ -644,8 +668,12 @@ def _append_agentic_report_artefacts(*, team_id: int, report_id: str, artefacts:# `mark_report_pending_input`). The research activity only resolves the payload; see# `_resolve_report_charts_payload` and `RunAgenticReportOutput.charts`.with transaction.atomic():+ # Priority edits take the same lock, so a correction cannot arrive between this check and append.+ SignalReport.objects.select_for_update().get(id=report_id, team_id=team_id)+ priority_adjusted_mid_run = any(isinstance(draft.content, PriorityAssessment) for draft in artefacts) and (+ _priority_adjusted_since(team_id, report_id, priority_judgment_id)+ )if any(isinstance(draft.content, SuggestedReviewers) for draft in artefacts):- SignalReport.objects.select_for_update().get(id=report_id, team_id=team_id)human_selected_reviewers = SignalReportArtefact.objects.filter(team_id=team_id,report_id=report_id,@@ -656,6 +684,8 @@ def _append_agentic_report_artefacts(*, team_id: int, report_id: str, artefacts:human_selected_reviewers = Falsewrote_reviewers = Falsefor draft in artefacts:+ if priority_adjusted_mid_run and isinstance(draft.content, PriorityAssessment):+ continueif human_selected_reviewers and isinstance(draft.content, SuggestedReviewers):continueSignalReportArtefact.append(@@ -725,6 +755,7 @@ async def _persist_agentic_report_artefacts(result: ReportResearchOutput,repo_selection: RepoSelectionResult,repo_selection_as_of: datetime | None = None,+ priority_judgment_id: UUID | None = None,) -> None:# Resolve suggested reviewers from commit hashes (always, from the effective findings —# auto-start below needs them even when nothing is persisted this run)@@ -799,6 +830,7 @@ async def _persist_agentic_report_artefacts(team_id=team_id,report_id=report_id,artefacts=artefacts,+ priority_judgment_id=priority_judgment_id,)# Telemetry mirrors persistence: fires when a suggested_reviewers artefact was appended@@ -993,6 +1025,16 @@ async def run_agentic_report_activity(input: RunAgenticReportInput) -> RunAgentichecks_snapshot = await database_sync_to_async(_load_check_snapshot, thread_sensitive=False)(input.team_id, input.report_id)+ priority_judgment_id = (+ await SignalReportArtefact.objects.filter(+ team_id=input.team_id,+ report_id=input.report_id,+ type=SignalReportArtefact.ArtefactType.PRIORITY_JUDGMENT,+ )+ .order_by("-created_at", "-id")+ .values_list("id", flat=True)+ .afirst()+ )previous_research = await _load_previous_research(input.team_id, input.report_id)previous_checks = await database_sync_to_async(_load_previous_checks, thread_sensitive=False)(input.team_id, input.report_id@@ -1043,6 +1085,7 @@ async def run_agentic_report_activity(input: RunAgenticReportInput) -> RunAgentiresult,input.repo_selection,repo_selection_as_of=input.repo_selection_as_of,+ priority_judgment_id=priority_judgment_id,)actionability = result.effective_actionability()priority = result.effective_priority()diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex 36164917b731..eae05f96560e 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -4057,6 +4057,60 @@ class TestSignalReportLegacyTaskArtefactList(APIBaseTest):class TestSignalReportContentUpdateAPI(APIBaseTest):+ def test_priority_edit_keeps_dismissed_report_suppressed(self) -> None:+ report = self._create_report(report_status=SignalReport.Status.SUPPRESSED)+ response = self.client.put(self._url(str(report.id)) + "priority/", {"priority": "P2"}, format="json")+ assert response.status_code == status.HTTP_200_OK+ assert response.json()["priority"] == "P2"+ report.refresh_from_db()+ assert report.status == SignalReport.Status.SUPPRESSED++ @parameterized.expand([(priority,) for priority in ReportPriority])+ def test_priority_edit_preserves_prediction_and_records_correction(self, priority: ReportPriority) -> None:+ report = self._create_report()+ previous_priority = ReportPriority.P4 if priority != ReportPriority.P4 else ReportPriority.P0+ previous = SignalReportArtefact.append_status(+ team_id=self.team.id,+ report_id=str(report.id),+ content=PriorityAssessment(priority=previous_priority, explanation="Original assessment", dollar_value=100),+ attribution=ArtefactAttribution.system(),+ )+ url = self._url(str(report.id)) + "priority/"+ response = self.client.put(url, {"priority": priority}, format="json")+ assert response.status_code == status.HTTP_200_OK+ assert response.json()["priority"] == priority+ correction = report.artefacts.filter(type="priority_judgment").latest("created_at")+ assert correction.created_by_id == self.user.id+ assert correction.actor_kind == "user"+ assert correction.created_at >= previous.created_at+ assert json.loads(correction.content)["adjustment"] == {+ "previous_priority": previous_priority,+ "previous_judgment_id": str(previous.id),+ "source": "inbox_sidebar",+ }+ previous.refresh_from_db()+ assert json.loads(previous.content)["priority"] == previous_priority+ assert json.loads(previous.content)["dollar_value"] == 100+ assert self.client.get(self._url(str(report.id))).json()["priority"] == priority+ listed = self.client.get(f"/api/projects/{self.team.id}/signals/reports/?priority={priority}")+ assert str(report.id) in {row["id"] for row in listed.json()["results"]}+ assert self.client.put(url, {"priority": priority}, format="json").status_code == status.HTTP_200_OK+ assert report.artefacts.filter(type="priority_judgment").count() == 2++ @parameterized.expand([(None,), ("P5",), ("high",)])+ def test_priority_edit_rejects_invalid_values(self, priority: str | None) -> None:+ report = self._create_report()+ response = self.client.put(self._url(str(report.id)) + "priority/", {"priority": priority}, format="json")+ assert response.status_code == status.HTTP_400_BAD_REQUEST+ assert not report.artefacts.exists()++ def test_priority_edit_cannot_write_to_another_project(self) -> None:+ other_team = Team.objects.create(organization=self.organization)+ report = self._create_report(team=other_team)+ response = self.client.put(self._url(str(report.id)) + "priority/", {"priority": "P1"}, format="json")+ assert response.status_code == status.HTTP_404_NOT_FOUND+ assert not report.artefacts.exists()+def _url(self, report_id: str) -> str:return f"/api/projects/{self.team.id}/signals/reports/{report_id}/"diff --git a/products/signals/backend/views.py b/products/signals/backend/views.pyindex 9231a8e6e23f..00d400aa1f77 100644--- a/products/signals/backend/views.py+++ b/products/signals/backend/views.py@@ -111,6 +111,7 @@ from products.signals.backend.billing import ()from products.signals.backend.briefing_reports import open_report_counts, reports_for_briefingfrom products.signals.backend.dismissal_notes import forward_dismissal_note+from products.signals.backend.enums import ReportPriorityfrom products.signals.backend.facade.api import emit_signalfrom products.signals.backend.feedback_notes import forward_feedback_notefrom products.signals.backend.implementation_pr import (@@ -173,6 +174,7 @@ from products.signals.backend.report_merge import ()from products.signals.backend.report_metric_access import ReportMetricAccessPolicyfrom products.signals.backend.report_metric_refresh import CURRENT_REPORT_STATUSES, refresh_report_metric_snapshots+from products.signals.backend.report_priority import update_report_priorityfrom products.signals.backend.report_read_state import (ReportReadStateRequestSerializer,ReportReadStateResponseSerializer,@@ -207,6 +209,7 @@ from products.signals.backend.serializers import (SignalReportListSerializer,SignalReportMetricRefreshRequestSerializer,SignalReportMetricRefreshResponseSerializer,+ SignalReportPriorityUpdateSerializer,SignalReportRefundSerializer,SignalReportSerializer,SignalReportsForYouQuerySerializer,@@ -1335,6 +1338,7 @@ class SignalReportViewSet("pr_checks","pr_comments","claim",+ "priority",})@@ -2098,6 +2102,24 @@ class SignalReportViewSet()return Response(response_serializer.data)+ @validated_request(+ request_serializer=SignalReportPriorityUpdateSerializer,+ responses={200: SignalReportSerializer},+ summary="Change a report's priority",+ description="Append an attributed priority correction, preserving the previous judgment for future learning.",+ operation_id="signals_reports_priority_update",+ )+ @action(detail=True, methods=["put"], required_scopes=["task:write"])+ def priority(self, request: ValidatedRequest, *args: object, **kwargs: object) -> Response:+ report = cast(SignalReport, self.get_object())+ update_report_priority(+ report=report,+ priority=ReportPriority(request.validated_data["priority"]),+ attribution=self._request_attribution(),+ )+ report.__dict__.pop("prefetched_priority_artefacts", None)+ return Response(SignalReportSerializer(report, context=self._enriched_report_context(report)).data)+@validated_request(request_serializer=SignalReportContentUpdateSerializer,responses={diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 52b60ba2d921..b941d4d08744 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -1381,6 +1381,17 @@ export interface PullRequestReviewCommentReactionCreateResponseApi {readonly reaction: PullRequestCommentReactionApi}+export interface SignalReportPriorityUpdateApi {+ /** New report priority, from P0 (critical) to P4 (minimal).+ *+ * * `P0` - P0+ * * `P1` - P1+ * * `P2` - P2+ * * `P3` - P3+ * * `P4` - P4 */+ priority: AutonomyPriorityEnumApi+}+export interface SignalReportRefundRequestApi {/** Why this PR is being refunded. One of: pr_incorrect (the PR doesn't address what the report promised), pr_not_useful (technically fine but not worth paying for), duplicate (covers work already charged elsewhere), other. Required — refund reviews key on it.*diff --git a/products/signals/frontend/generated/api.ts b/products/signals/frontend/generated/api.tsindex 07f74e34ea51..cdb644f5ff6a 100644--- a/products/signals/frontend/generated/api.ts+++ b/products/signals/frontend/generated/api.ts@@ -99,6 +99,7 @@ import type {SignalReportMergeResponseApi,SignalReportMetricRefreshRequestApi,SignalReportMetricRefreshResponseApi,+ SignalReportPriorityUpdateApi,SignalReportRefundRequestApi,SignalReportRefundResponseApi,SignalReportRefundSummaryResponseApi,@@ -705,6 +706,28 @@ export const signalsReportPrReviewCommentReactionDestroy = async ()}+export const getSignalsReportsPriorityUpdateUrl = (projectId: string, id: string) => {+ return `/api/projects/${projectId}/signals/reports/${id}/priority/`+}++/**+ * Append an attributed priority correction, preserving the previous judgment for future learning.+ * @summary Change a report's priority+ */+export const signalsReportsPriorityUpdate = async (+ projectId: string,+ id: string,+ signalReportPriorityUpdateApi: SignalReportPriorityUpdateApi,+ options?: RequestInit+): Promise<SignalReportApi> => {+ return apiMutator<SignalReportApi>(getSignalsReportsPriorityUpdateUrl(projectId, id), {+ ...options,+ method: 'PUT',+ headers: { 'Content-Type': 'application/json', ...options?.headers },+ body: JSON.stringify(signalReportPriorityUpdateApi),+ })+}+export const getSignalsReportsRefundCreateUrl = (projectId: string, id: string) => {return `/api/projects/${projectId}/signals/reports/${id}/refund/`}diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.tsindex 391b0ae96572..f24f126eb293 100644--- a/products/signals/frontend/generated/api.zod.ts+++ b/products/signals/frontend/generated/api.zod.ts@@ -282,6 +282,19 @@ export const SignalsReportPrReviewCommentReactionsCreateBody = /* @__PURE__ */ z}).describe('Request body for adding an emoji reaction to a review comment.')+/**+ * Append an attributed priority correction, preserving the previous judgment for future learning.+ * @summary Change a report's priority+ */+export const SignalsReportsPriorityUpdateBody = /* @__PURE__ */ zod.object({+ priority: zod+ .enum(['P0', 'P1', 'P2', 'P3', 'P4'])+ .describe('\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4')+ .describe(+ 'New report priority, from P0 (critical) to P4 (minimal).\n\n\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'+ ),+})+/*** Refund the flat charge for this report's implementation PR and archive the report. Refunds auto-approve: the charge is either excluded from usage before it is ever reported to billing (refund on the same UTC day as the PR run) or returned as a Stripe customer-balance credit on the next invoice. A refunded PR does not count toward the free monthly PR allowance. One refund per report, ever — repeat calls return the existing refund with already_refunded=true. The report is archived as part of the refund (a resolved report stays resolved) and can't be restored afterwards.* @summary Refund a report's implementation PRdiff --git a/products/signals/frontend/inbox/components/detail/InboxDetail.stories.tsx b/products/signals/frontend/inbox/components/detail/InboxDetail.stories.tsxindex 0b3a2cf76202..ef08c05793fc 100644--- a/products/signals/frontend/inbox/components/detail/InboxDetail.stories.tsx+++ b/products/signals/frontend/inbox/components/detail/InboxDetail.stories.tsx@@ -1,7 +1,7 @@import type { Meta, StoryObj } from '@storybook/react'import { useActions } from 'kea'import { HttpResponse } from 'msw'-import { useEffect } from 'react'+import { useEffect, useState } from 'react'import { FEATURE_FLAGS } from 'lib/constants'@@ -195,10 +195,11 @@ function Frame({ children }: { children: React.ReactNode }): JSX.Element {}export const StatusBlock: Story = {- render: () => {+ render: function RenderStatusBlock() {+ const [priority, setPriority] = useState<NonNullable<SignalReport['priority']>>('P1')const report = makeReport({status: SignalReportStatus.READY,- priority: 'P1',+ priority,actionability: 'immediately_actionable',implementation_pr_url: 'https://github.com/PostHog/posthog/pull/12002',implementation_pr_state: 'open',@@ -238,7 +239,7 @@ export const StatusBlock: Story = {return (<Frame><div className="w-[26rem] border border-primary bg-surface-primary p-5">- <ReportStatusSection report={report} />+ <ReportStatusSection report={report} onPriorityChange={setPriority} /></div></Frame>)diff --git a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx b/products/signals/frontend/inbox/components/detail/ReportDetail.tsxindex 5d498d5b9970..22d09be9e908 100644--- a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx+++ b/products/signals/frontend/inbox/components/detail/ReportDetail.tsx@@ -236,8 +236,12 @@ export function InboxDetailFrame({reportTaskToOpen,reportChecks,reportChecksError,+ prioritySaving,+ report: currentReport,} = useValues(inboxReportDetailLogic(logicProps))- const { setDetailTab, expandEvidence, collapseEvidence } = useActions(inboxReportDetailLogic(logicProps))+ const { setDetailTab, expandEvidence, collapseEvidence, updatePriority } = useActions(+ inboxReportDetailLogic(logicProps)+ )const { evidenceRailCollapsed } = useValues(inboxDetailLayoutLogic)const { toggleEvidenceRail } = useActions(inboxDetailLayoutLogic)// The API returns evidence oldest-first, but a reader wants the most recent signal at the top of@@ -427,7 +431,12 @@ export function InboxDetailFrame({<aside className={DETAIL_ASIDE_COLLAPSED_CLASS}>{showRailButton}</aside>) : (<aside className={DETAIL_ASIDE_CLASS}>- <ReportStatusSection report={report} rightSlot={hideRailButton} />+ <ReportStatusSection+ report={currentReport ?? report}+ rightSlot={hideRailButton}+ onPriorityChange={updatePriority}+ prioritySaving={prioritySaving}+ />{/* The observation leads, then the evidence its claims rest on. */}{primaryMetric && (<DetailSectiondiff --git a/products/signals/frontend/inbox/components/detail/ReportStatusSection.tsx b/products/signals/frontend/inbox/components/detail/ReportStatusSection.tsxindex 7e4dc9859351..af253ee1d2ad 100644--- a/products/signals/frontend/inbox/components/detail/ReportStatusSection.tsx+++ b/products/signals/frontend/inbox/components/detail/ReportStatusSection.tsx@@ -1,10 +1,14 @@import { type ReactNode } from 'react'import { IconInfo } from '@posthog/icons'+import { LemonSelect, LemonTag } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'import { Link } from 'lib/lemon-ui/Link'+import type { ReportPriorityApi } from 'products/signals/frontend/generated/api.schemas'++import { PRIORITY_MEANING, PRIORITY_TAG_TYPE } from '../../filterOptions'import { SignalReport } from '../../types'import { parsePrUrlParts, safeHttpUrl } from '../../utils/reportPresentation'import { ReportPullRequest, reportPullRequests } from '../../utils/reportPullRequests'@@ -47,9 +51,13 @@ function externalClaimLabel(report: SignalReport): string | null {export function ReportStatusSection({report,rightSlot,+ onPriorityChange,+ prioritySaving = false,}: {report: SignalReportrightSlot?: ReactNode+ onPriorityChange?: (priority: ReportPriorityApi) => void+ prioritySaving?: boolean}): JSX.Element {const externalClaim = externalClaimLabel(report)const pullRequests = reportPullRequests(report)@@ -60,7 +68,45 @@ export function ReportStatusSection({<dl className="m-0 flex flex-col gap-2"><StatusRow label="Report status">{STATUS_LABELS[report.status] ?? report.status}</StatusRow>{externalClaim && <StatusRow label="In progress by">{externalClaim}</StatusRow>}- {report.priority && <StatusRow label="Priority">{report.priority}</StatusRow>}+ {report.priority && (+ <StatusRow label="Priority">+ {onPriorityChange ? (+ <LemonSelect<ReportPriorityApi>+ aria-label="Change report priority"+ data-attr="report-priority-select"+ value={report.priority}+ onChange={onPriorityChange}+ loading={prioritySaving}+ disabledReason={prioritySaving ? 'Saving priority…' : undefined}+ size="xsmall"+ type="tertiary"+ dropdownPlacement="bottom-end"+ dropdownMatchSelectWidth={false}+ menu={{ className: 'w-56' }}+ options={Object.entries(PRIORITY_MEANING).map(([priority, { label }]) => ({+ value: priority as ReportPriorityApi,+ label: `${priority} · ${label}`,+ labelInMenu: (+ <span className="flex items-center gap-2">+ <LemonTag+ type={PRIORITY_TAG_TYPE[priority as ReportPriorityApi]}+ size="small"+ >+ {priority}+ </LemonTag>+ <span className="text-default">{label}</span>+ </span>+ ),+ }))}+ renderButtonContent={() => (+ <span className="text-default text-xs font-normal">{report.priority}</span>+ )}+ />+ ) : (+ report.priority+ )}+ </StatusRow>+ )}{pullRequests.map((pullRequest, index) => {const prUrl = safeHttpUrl(pullRequest.url)const prRef = prUrl ? parsePrUrlParts(prUrl) : nulldiff --git a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.tsindex 1646a79baca8..87421fc45e01 100644--- a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts+++ b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts@@ -2,6 +2,8 @@ import { waitFor } from '@testing-library/react'import { expectLogic } from 'kea-test-utils'import posthog from 'posthog-js'+import { lemonToast } from '@posthog/lemon-ui'+import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'@@ -13,6 +15,7 @@ import { ReportTaskPurpose } from '../components/detail/artefactTypes'import { INBOX_EVENTS } from '../inboxAnalytics'import { inboxSceneLogic } from '../inboxSceneLogic'import { EnrichedReviewer, SignalReport } from '../types'+import { inboxBulkActionsLogic } from './inboxBulkActionsLogic'import { ReportTaskEntry, implementationSlotClaim, inboxReportDetailLogic } from './inboxReportDetailLogic'const REPORT = { id: 'report-1', status: 'ready', title: 'Checkout errors spiked' } as unknown as SignalReport@@ -26,6 +29,118 @@ const linkedTask = (purpose: ReportTaskPurpose, status: TaskRunStatus | null, pr}) as unknown as ReportTaskEntrydescribe('inboxReportDetailLogic', () => {+ describe('priority editing', () => {+ let logic: ReturnType<typeof inboxReportDetailLogic.build>++ beforeEach(async () => {+ useMocks({+ get: {+ '/api/projects/:team_id/signals/reports/:id/artefacts/': { results: [] },+ '/api/projects/:team_id/signals/reports/:id/signals/': { signals: [] },+ '/api/projects/:team_id/signals/reports/:id/checks/': { results: [] },+ '/api/projects/:team_id/signals/reports/available_reviewers/': [],+ },+ })+ initKeaTests()+ logic = inboxReportDetailLogic({ reportId: REPORT.id, report: { ...REPORT, priority: 'P1' } })+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()+ })++ afterEach(() => {+ if (logic.isMounted()) {+ logic.unmount()+ }+ })++ it('refreshes the inbox after a successful save when the detail has unmounted', async () => {+ const bulkLogic = inboxBulkActionsLogic()+ bulkLogic.mount()+ const refresh = jest.spyOn(bulkLogic.actions, 'reportStateChanged')+ const errorToast = jest.spyOn(lemonToast, 'error')+ let completeSave: () => void = () => {}+ const pendingSave = new Promise<void>((resolve) => {+ completeSave = resolve+ })+ const save = jest.fn(async () => {+ await pendingSave+ return [200, { ...REPORT, priority: 'P2' }]+ })+ useMocks({ put: { '/api/projects/:team_id/signals/reports/:id/priority/': save } })+ try {+ logic.actions.updatePriority('P2')+ await waitFor(() => expect(save).toHaveBeenCalledTimes(1))+ logic.unmount()+ completeSave()+ await waitFor(() => expect(refresh).toHaveBeenCalledTimes(1))+ expect(errorToast).not.toHaveBeenCalled()+ } finally {+ refresh.mockRestore()+ errorToast.mockRestore()+ bulkLogic.unmount()+ }+ })++ it('preserves drafts and expanded runs on priority saves and refreshed props, but clears them for another report', async () => {+ const draft = { path: 'src/example.ts', line: 12, side: 'RIGHT' as const }+ logic.actions.openDraftThread(draft)+ logic.actions.setEditingCommentId('comment-1')+ logic.actions.toggleExpandedTask('task-1')+ useMocks({ put: { '/api/projects/:team_id/signals/reports/:id/priority/': { ...REPORT, priority: 'P2' } } })+ logic.actions.updatePriority('P2')+ await expectLogic(logic).toFinishAllListeners()+ expect(logic.values.draftThread).toEqual(draft)+ expect(logic.values.editingCommentId).toBe('comment-1')+ expect(logic.values.expandedTaskIds).toEqual(['task-1'])+ inboxReportDetailLogic({ reportId: REPORT.id, report: { ...REPORT, priority: 'P2' } })+ expect(logic.values.draftThread).toEqual(draft)+ expect(logic.values.editingCommentId).toBe('comment-1')+ expect(logic.values.expandedTaskIds).toEqual(['task-1'])+ logic.actions.setReport({ ...REPORT, id: 'another-report' })+ expect(logic.values.draftThread).toBeNull()+ expect(logic.values.editingCommentId).toBeNull()+ expect(logic.values.expandedTaskIds).toEqual([])+ })++ it('saves the priority and ignores another edit while the request is in flight', async () => {+ let completeSave: () => void = () => {}+ const pendingSave = new Promise<void>((resolve) => {+ completeSave = resolve+ })+ const save = jest.fn(async () => {+ await pendingSave+ return [200, { ...REPORT, priority: 'P2', updated_at: '2026-10-10T12:00:00Z' }]+ })+ useMocks({ put: { '/api/projects/:team_id/signals/reports/:id/priority/': save } })+ logic.actions.updatePriority('P2')+ await waitFor(() => expect(save).toHaveBeenCalledTimes(1))+ expect(logic.values.prioritySaving).toBe(true)+ expect(logic.values.report?.priority).toBe('P1')+ logic.actions.updatePriority('P0')+ completeSave()+ await expectLogic(logic).toFinishAllListeners()+ expect(save).toHaveBeenCalledTimes(1)+ expect(logic.values.report?.priority).toBe('P2')+ expect(logic.values.prioritySaving).toBe(false)+ logic.actions.updatePriority('P2')+ await expectLogic(logic).toFinishAllListeners()+ expect(save).toHaveBeenCalledTimes(1)+ })++ it('keeps the saved priority after a failure and allows retrying', async () => {+ useMocks({ put: { '/api/projects/:team_id/signals/reports/:id/priority/': () => [500, {}] } })+ logic.actions.updatePriority('P2')+ await expectLogic(logic).toFinishAllListeners()+ expect(logic.values.report?.priority).toBe('P1')+ expect(logic.values.prioritySaving).toBe(false)+ useMocks({ put: { '/api/projects/:team_id/signals/reports/:id/priority/': { ...REPORT, priority: 'P2' } } })+ logic.actions.updatePriority('P2')+ await expectLogic(logic).toFinishAllListeners()+ expect(logic.values.report?.priority).toBe('P2')+ expect(logic.values.prioritySaving).toBe(false)+ })+ })+describe('check approval', () => {const openCheck = {id: 'check-1',diff --git a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.tsindex 5c2a9d01f9fc..5ec523098664 100644--- a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts@@ -40,6 +40,7 @@ import {signalsReportPrReviewCommentUpdate,signalsReportsFeedbackCreate,signalsReportsSignalsRetrieve,+ signalsReportsPriorityUpdate,} from 'products/signals/frontend/generated/api'import type {CommitDiffResponseApi,@@ -47,7 +48,9 @@ import type {PullRequestCommentApi,PullRequestCommentReactionApi,ReportChartApi,+ ReportPriorityApi,SignalReportCheckApi,+ SignalReportApi,} from 'products/signals/frontend/generated/api.schemas'import type { SignalNodeApi } from 'products/signals/frontend/generated/api.schemas'@@ -327,6 +330,7 @@ export interface inboxReportDetailLogicValues {prCommentsLoading: booleanprimaryTask: ReportTaskEntry | nullpriorityExplanation: string | null+ prioritySaving: booleanreport: SignalReport | nullreportArtefacts: SignalReportArtefact[] | nullreportArtefactsLoading: boolean@@ -586,6 +590,9 @@ export interface inboxReportDetailLogicActions {setOptimisticReviewers: (reviewers: EnrichedReviewer[] | null) => {reviewers: EnrichedReviewer[] | null}+ setPrioritySaving: (saving: boolean) => {+ saving: boolean+ }setReport: (report: SignalReport | null) => {report: SignalReport | null}@@ -609,6 +616,9 @@ export interface inboxReportDetailLogicActions {commentId: stringcontent: string}+ updatePriority: (priority: ReportPriorityApi) => {+ priority: ReportPriorityApi+ }updateReviewers: (content: Record<string, string>[],optimistic: EnrichedReviewer[]@@ -712,6 +722,8 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([setEditingCommentId: (commentId: string | null) => ({ commentId }),selectPullRequest: (url: string) => ({ url }),setReport: (report: SignalReport | null) => ({ report }),+ updatePriority: (priority: ReportPriorityApi) => ({ priority }),+ setPrioritySaving: (saving: boolean) => ({ saving }),// Optimistically replace the reviewer list while the PUT is in flight, then reload from the server.// Addressed by report (not artefact) so a report with no reviewers yet can still be assigned one.// Mirrors desktop `useUpdateSuggestedReviewers` optimistic behavior.@@ -928,7 +940,7 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([],})),- reducers({+ reducers(({ props }) => ({selectedPullRequestUrl: [null as string | null, { selectPullRequest: (_, { url }) => url }],// Checks whose cancel request is in flight, so each row's Stop button disables itself// without blocking a second row.@@ -951,6 +963,7 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([},],evidenceExpanded: [false, { expandEvidence: () => true, collapseEvidence: () => false }],+ prioritySaving: [false, { setPrioritySaving: (_, { saving }) => saving }],report: [null as SignalReport | null,{@@ -982,7 +995,7 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([{toggleExpandedTask: (state, { taskId }) =>state.includes(taskId) ? state.filter((id) => id !== taskId) : [...state, taskId],- setReport: () => [],+ setReport: (state, { report }) => (report?.id === props.reportId ? state : []),},],// Which tab the report column shows. The logic is keyed by report id, so each report keeps its@@ -1090,7 +1103,7 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([{openDraftThread: (_, { draft }) => draft,closeDraftThread: () => null,- setReport: () => null,+ setReport: (state, { report }) => (report?.id === props.reportId ? state : null),},],// Which thread's composer has a post in flight — gates its submit button and textarea.@@ -1106,10 +1119,10 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([null as string | null,{setEditingCommentId: (_, { commentId }) => commentId,- setReport: () => null,+ setReport: (state, { report }) => (report?.id === props.reportId ? state : null),},],- }),+ })),selectors({// Mirrors the optimistic override lifecycle: an update is in flight exactly while the@@ -1400,6 +1413,40 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([}),listeners(({ actions, asyncActions, values, props, selectors }) => ({+ updatePriority: async ({ priority }) => {+ const teamId = teamLogic.values.currentTeamId+ const currentReport = values.report+ if (!teamId || !currentReport || values.prioritySaving || currentReport.priority === priority) {+ return+ }+ actions.setPrioritySaving(true)+ let updated: SignalReportApi+ try {+ updated = await signalsReportsPriorityUpdate(String(teamId), props.reportId, { priority })+ } catch {+ if (inboxReportDetailLogic.isMounted(props)) {+ actions.setPrioritySaving(false)+ lemonToast.error("Couldn't save the priority. Try again.")+ }+ return+ }+ inboxBulkActionsLogic.findMounted()?.actions.reportStateChanged()+ if (!inboxReportDetailLogic.isMounted(props)) {+ return+ }+ const report: SignalReport = {+ ...(values.report ?? currentReport),+ priority,+ updated_at: updated.updated_at,+ }+ actions.setReport(report)+ const scene = inboxSceneLogic.findMounted()+ if (scene?.values.selectedReportId === props.reportId) {+ scene.actions.seedSelectedReport(report)+ }+ actions.loadReportArtefacts()+ actions.setPrioritySaving(false)+ },approveReportCheck: async ({ checkId }) => {const teamId = teamLogic.values.currentTeamIdif (!teamId) {diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 144409b54d87..dd555b3f1d5e 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -99573,6 +99573,17 @@ export namespace Schemas {readonly reports: readonly SignalReportMetricSnapshots[];}+ export interface SignalReportPriorityUpdate {+ /** New report priority, from P0 (critical) to P4 (minimal).+ *+ * * `P0` - P0+ * * `P1` - P1+ * * `P2` - P2+ * * `P3` - P3+ * * `P4` - P4 */+ priority: AutonomyPriorityEnum;+ }+export interface SignalReportRefundRequest {/** Why this PR is being refunded. One of: pr_incorrect (the PR doesn't address what the report promised), pr_not_useful (technically fine but not worth paying for), duplicate (covers work already charged elsewhere), other. Required — refund reviews key on it.*