: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(inbox): add archived tab with restore (#64876)
Andrew Maguire42a103bc3cab
diff --git a/frontend/src/scenes/inbox/InboxScene.tsx b/frontend/src/scenes/inbox/InboxScene.tsxindex 024ff74a8269..1d6384ce68e6 100644--- a/frontend/src/scenes/inbox/InboxScene.tsx+++ b/frontend/src/scenes/inbox/InboxScene.tsx@@ -17,6 +17,7 @@ import { ReportDetail, ReportDetailSkeleton } from './components/detail/ReportDeimport { AgentSetupColumn } from './components/shell/AgentSetupColumn'import { InboxScopeSelect } from './components/shell/InboxScopeSelect'import { InboxTabBar } from './components/shell/InboxTabBar'+import { ArchivedTab } from './components/tabs/ArchivedTab'import { NotActionableTab } from './components/tabs/NotActionableTab'import { PullRequestsTab } from './components/tabs/PullRequestsTab'import { ReportsTab } from './components/tabs/ReportsTab'@@ -34,7 +35,7 @@ const SETUP_RAIL_MIN_PX = 1024/** Tabs that show the centered report list (scope chrome in the header). Runs/Configuration are special. */function isReportListTab(tab: InboxTabKey): boolean {- return tab === 'pulls' || tab === 'reports' || tab === 'not-actionable'+ return tab === 'pulls' || tab === 'reports' || tab === 'not-actionable' || tab === 'archived'}function ActiveTabBody({ tab, runsReports }: { tab: InboxTabKey; runsReports: SignalReport[] }): JSX.Element {@@ -45,6 +46,8 @@ function ActiveTabBody({ tab, runsReports }: { tab: InboxTabKey; runsReports: Sireturn <ReportsTab />case 'not-actionable':return <NotActionableTab />+ case 'archived':+ return <ArchivedTab />case 'runs':return <RunsTab reports={runsReports} />case 'config':diff --git a/frontend/src/scenes/inbox/components/InboxReportList.tsx b/frontend/src/scenes/inbox/components/InboxReportList.tsxindex f151467259c4..58a260d151b6 100644--- a/frontend/src/scenes/inbox/components/InboxReportList.tsx+++ b/frontend/src/scenes/inbox/components/InboxReportList.tsx@@ -15,6 +15,8 @@ export interface InboxReportCardProps {report: SignalReporttabKey: InboxFlatListTabKeyonArchive: (reason: DismissalReasonValue, note: string) => void+ /** Restore a suppressed report back to the inbox. Only wired on the Archived tab. */+ onRestore?: () => void/** Rendered as an attached row inside a shared bordered container (vs. a freestanding card). */attached?: boolean}@@ -57,7 +59,7 @@ function ActiveFiltersBanner(): JSX.Element | null {function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListProps): JSX.Element {const { reports, count, hasMore, reportsResponseLoading, isLoaded } = useValues(reportListLogic)- const { ensureLoaded, loadMore, archiveReport, refresh } = useActions(reportListLogic)+ const { ensureLoaded, loadMore, archiveReport, restoreReport, refresh } = useActions(reportListLogic)const sentinelRef = useRef<HTMLDivElement>(null)// Read fresh state at intersection time via refs so the observer is created once and not@@ -118,6 +120,7 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListPropsreport={report}tabKey={tabKey}onArchive={(reason, note) => archiveReport(report.id, reason, note)}+ onRestore={() => restoreReport(report.id)}/>))}{/* Skeleton cards continue the list while the next page loads – sleeker than a spinner. */}diff --git a/frontend/src/scenes/inbox/components/cards/ReportCard.tsx b/frontend/src/scenes/inbox/components/cards/ReportCard.tsxindex a80fe2b340d8..2b9140402dcb 100644--- a/frontend/src/scenes/inbox/components/cards/ReportCard.tsx+++ b/frontend/src/scenes/inbox/components/cards/ReportCard.tsx@@ -1,14 +1,14 @@import clsx from 'clsx'import { router } from 'kea-router'-import { IconArchive, IconPullRequest } from '@posthog/icons'+import { IconArchive, IconPullRequest, IconUndo } from '@posthog/icons'import { LemonButton, LemonTag, LemonTagType, Link, Tooltip } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'import { urls } from 'scenes/urls'import { InboxFlatListTabKey, SignalReport, SignalReportStatus } from '../../types'-import { DismissalReasonValue } from '../../utils/dismissalReasons'+import { dismissalReasonLabel, DismissalReasonValue } from '../../utils/dismissalReasons'import {deriveHeadline,displayConventionalCommitTitle,@@ -131,12 +131,15 @@ export function ReportCard({tabKey = 'reports',attached = false,onArchive,+ onRestore,}: {report: SignalReporttabKey?: InboxFlatListTabKeyattached?: booleanonArchive?: (reason: DismissalReasonValue, note: string) => void+ onRestore?: () => void}): JSX.Element {+ const isArchived = tabKey === 'archived'const prUrl = safeHttpUrl(report.implementation_pr_url)const prUrlParts = prUrl ? parsePrUrlParts(prUrl) : nullconst hasPr = prUrlParts != null@@ -152,10 +155,17 @@ export function ReportCard({const { isArchiving, onArchiveClick } = useReportArchive({ reportId: report.id, cardTitle, onArchive })+ // On the Archive tab, surface why it was dismissed (reason tag + note tooltip) when we have it.+ const dismissalLabel = isArchived ? dismissalReasonLabel(report.dismissal_reason) : null+// PR cards show repo · source; reports show source · status · actionability.const showMeta = hasPr? repoSlug != null || hasSource- : hasSource || !isReady || report.actionability != null || report.is_suggested_reviewer === true+ : hasSource ||+ !isReady ||+ report.actionability != null ||+ report.is_suggested_reviewer === true ||+ !!dismissalLabelreturn (<div className={clsx('relative', inboxCardRowClassName(attached, { dashed: !hasPr }))}>@@ -210,6 +220,13 @@ export function ReportCard({{!hasPr && report.actionability && (<SignalReportActionabilityBadge actionability={report.actionability} />)}+ {dismissalLabel && (+ <Tooltip title={report.dismissal_note || undefined}>+ <LemonTag size="small" icon={<IconArchive />}>+ {dismissalLabel}+ </LemonTag>+ </Tooltip>+ )}</div>) : null}@@ -225,28 +242,47 @@ export function ReportCard({</Link><div className="flex items-center justify-end gap-2.5 shrink-0 @lg:self-stretch @lg:border-l @lg:border-primary @lg:pl-3">- <LemonButton- type="secondary"- size="small"- icon={<IconArchive />}- tooltip="Archive this report"- aria-label="Archive this report"- loading={isArchiving}- onClick={onArchiveClick}- >- Archive- </LemonButton>- <LemonButton- type="primary"- size="small"- onClick={(event) => {- event.preventDefault()- event.stopPropagation()- router.actions.push(detailUrl)- }}- >- Review- </LemonButton>+ {isArchived ? (+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconUndo />}+ tooltip="Restore this report to the inbox"+ aria-label="Restore this report to the inbox"+ onClick={(event) => {+ event.preventDefault()+ event.stopPropagation()+ onRestore?.()+ }}+ >+ Restore+ </LemonButton>+ ) : (+ <>+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconArchive />}+ tooltip="Archive this report"+ aria-label="Archive this report"+ loading={isArchiving}+ onClick={onArchiveClick}+ >+ Archive+ </LemonButton>+ <LemonButton+ type="primary"+ size="small"+ onClick={(event) => {+ event.preventDefault()+ event.stopPropagation()+ router.actions.push(detailUrl)+ }}+ >+ Review+ </LemonButton>+ </>+ )}</div></div>)diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsxindex b66993ac854b..f72d62f5f396 100644--- a/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx+++ b/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx@@ -1,15 +1,18 @@import { useActions, useValues } from 'kea'import { router } from 'kea-router'import posthog from 'posthog-js'+import { useState } from 'react'-import { IconArchive, IconPullRequest } from '@posthog/icons'-import { LemonButton } from '@posthog/lemon-ui'+import { IconArchive, IconPullRequest, IconUndo } from '@posthog/icons'+import { LemonButton, lemonToast } from '@posthog/lemon-ui'+import api from 'lib/api'import { urls } from 'scenes/urls'import { inboxSceneLogic } from '../../inboxSceneLogic'import { inboxTaskKickoffLogic } from '../../inboxTaskKickoffLogic'-import { ACTIONABLE_ACTIONABILITY_VALUES, SignalReport } from '../../types'+import { INBOX_FLAT_TAB_LIST_PARAMS, reportListLogic } from '../../logics/reportListLogic'+import { ACTIONABLE_ACTIONABILITY_VALUES, SignalReport, SignalReportStatus } from '../../types'import { useReportArchive } from '../cards/useReportArchive'/** Mirror desktop's `Inbox report action` analytics for detail-pane actions. */@@ -54,8 +57,10 @@ export function ReportDetailActions({ report }: { report: SignalReport }): JSX.Econst { isCreatingPr } = useValues(inboxTaskKickoffLogic)const { createPrFromReport } = useActions(inboxTaskKickoffLogic)const { activeTab } = useValues(inboxSceneLogic)+ const [isRestoring, setIsRestoring] = useState(false)const showCreatePr = canCreateImplementationPr(report)+ const isArchived = report.status === SignalReportStatus.SUPPRESSEDconst { isArchiving, onArchiveClick } = useReportArchive({reportId: report.id,@@ -64,6 +69,47 @@ export function ReportDetailActions({ report }: { report: SignalReport }): JSX.EonArchived: () => router.actions.push(urls.inbox(activeTab)),})+ const onRestoreClick = async (): Promise<void> => {+ // Prefer the mounted Archived list logic so it optimistically drops the row and fixes its+ // count + tab badge synchronously (it also fires the API call + toast). Navigate straight back.+ const archivedList = reportListLogic.findMounted({+ tabKey: 'archived',+ listParams: INBOX_FLAT_TAB_LIST_PARAMS.archived,+ })+ if (archivedList) {+ archivedList.actions.restoreReport(report.id)+ router.actions.push(urls.inbox(activeTab))+ return+ }+ // Fallback for a deep-linked detail with no mounted Archived list (e.g. cold load).+ setIsRestoring(true)+ try {+ await api.signalReports.setState(report.id, { state: 'potential' })+ lemonToast.success('Report restored to inbox')+ router.actions.push(urls.inbox(activeTab))+ } catch (error: any) {+ lemonToast.error(error?.detail || error?.message || 'Failed to restore report')+ } finally {+ setIsRestoring(false)+ }+ }++ // An already-archived report offers Restore instead of Archive (and no Create PR).+ if (isArchived) {+ return (+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconUndo />}+ loading={isRestoring}+ tooltip="Restore this report to your inbox"+ onClick={() => void onRestoreClick()}+ >+ Restore+ </LemonButton>+ )+ }+return (<><LemonButtondiff --git a/frontend/src/scenes/inbox/components/tabs/ArchivedTab.tsx b/frontend/src/scenes/inbox/components/tabs/ArchivedTab.tsxnew file mode 100644index 000000000000..b306aa1076f2--- /dev/null+++ b/frontend/src/scenes/inbox/components/tabs/ArchivedTab.tsx@@ -0,0 +1,25 @@+import { IconArchive } from '@posthog/icons'++import { INBOX_FLAT_TAB_LIST_PARAMS } from '../../logics/reportListLogic'+import { ReportCard } from '../cards/ReportCard'+import { InboxReportList } from '../InboxReportList'++/**+ * Reports the user dismissed (status `suppressed`). Same flat-list primitive as the other+ * report tabs – only the filter differs. Each card offers a Restore action that re-promotes+ * the report back into the inbox.+ */+export function ArchivedTab(): JSX.Element {+ return (+ <InboxReportList+ tabKey="archived"+ listParams={INBOX_FLAT_TAB_LIST_PARAMS.archived}+ Card={ReportCard}+ emptyState={{+ icon: <IconArchive className="text-2xl" />,+ title: 'Nothing archived',+ description: 'Reports you archive land here, where you can review them or restore them to the inbox.',+ }}+ />+ )+}diff --git a/frontend/src/scenes/inbox/logics/reportListLogic.ts b/frontend/src/scenes/inbox/logics/reportListLogic.tsindex 4b11a28c2689..2398a74a74fb 100644--- a/frontend/src/scenes/inbox/logics/reportListLogic.ts+++ b/frontend/src/scenes/inbox/logics/reportListLogic.ts@@ -35,6 +35,8 @@ export const INBOX_FLAT_TAB_LIST_PARAMS: Record<InboxFlatListTabKey, ReportListPactionability: ACTIONABLE_ACTIONABILITY_VALUES.join(','),},'not-actionable': { actionability: 'not_actionable' },+ // Archived = reports the user dismissed (suppressed). Restorable back into the inbox.+ archived: { status: 'suppressed' },}function teammateUuidFromScope(scope: string): string | undefined {@@ -72,6 +74,7 @@ export const reportListLogic = kea<reportListLogicType>([ensureLoaded: true,loadMore: true,archiveReport: (reportId: string, reason: DismissalReasonValue, note: string) => ({ reportId, reason, note }),+ restoreReport: (reportId: string) => ({ reportId }),removeReport: (reportId: string) => ({ reportId }),refresh: true,}),@@ -208,6 +211,18 @@ export const reportListLogic = kea<reportListLogicType>([actions.refresh()}},+ // Restore a suppressed report back to the inbox (transition to `potential`). Optimistically+ // drops it from the Archived list; the report re-enters the pipeline and resurfaces elsewhere.+ restoreReport: async ({ reportId }) => {+ actions.removeReport(reportId)+ try {+ await api.signalReports.setState(reportId, { state: 'potential' })+ lemonToast.success('Report restored to inbox')+ } catch (error: any) {+ lemonToast.error(error?.detail || error?.message || 'Failed to restore report')+ actions.refresh()+ }+ },// Bulk archive happens in the singleton; refresh this tab once it lands.[inboxBulkActionsLogic.actionTypes.bulkDismissSuccess]: () => actions.refresh(),})),diff --git a/frontend/src/scenes/inbox/types.ts b/frontend/src/scenes/inbox/types.tsindex bfc207b89925..e34061547b25 100644--- a/frontend/src/scenes/inbox/types.ts+++ b/frontend/src/scenes/inbox/types.ts@@ -46,6 +46,10 @@ export interface SignalReport {source_products?: string[]/** 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. */+ dismissal_reason?: string | null+ /** Free-form note from the latest dismissal artefact (when archived). */+ dismissal_note?: string | null}export enum SignalReportStatus {@@ -99,15 +103,16 @@ export enum SignalSourceConfigStatus {// ── Inbox 2.0 IA: tabs + scope ──────────────────────────────────────────────-export type InboxTabKey = 'pulls' | 'reports' | 'not-actionable' | 'runs' | 'config'+export type InboxTabKey = 'pulls' | 'reports' | 'not-actionable' | 'runs' | 'archived' | 'config'-export const INBOX_TAB_KEYS: InboxTabKey[] = ['pulls', 'reports', 'not-actionable', 'runs', 'config']+export const INBOX_TAB_KEYS: InboxTabKey[] = ['pulls', 'reports', 'not-actionable', 'runs', 'archived', 'config']export const INBOX_TAB_LABEL: Record<InboxTabKey, string> = {pulls: 'Pull requests',reports: 'Reports','not-actionable': 'Not actionable',runs: 'Runs',+ archived: 'Archive',config: 'Configuration',}@@ -119,7 +124,7 @@ export const INBOX_TAB_LABEL: Record<InboxTabKey, string> = {export const INBOX_CONFIG_TAB_KEY: InboxTabKey = 'config'/** Tabs that show a report-count chip. */-export const INBOX_REPORT_TAB_KEYS: InboxTabKey[] = ['pulls', 'reports', 'not-actionable', 'runs']+export const INBOX_REPORT_TAB_KEYS: InboxTabKey[] = ['pulls', 'reports', 'not-actionable', 'runs', 'archived']/*** Tabs only visible to staff users (internal). Non-staff see Pull requests + Reports.@@ -127,8 +132,8 @@ export const INBOX_REPORT_TAB_KEYS: InboxTabKey[] = ['pulls', 'reports', 'not-ac*/export const INBOX_STAFF_ONLY_TAB_KEYS: InboxTabKey[] = ['not-actionable', 'runs']-/** The three flat report-list tabs that share the keyed reportListLogic + InboxReportList primitive. */-export const INBOX_FLAT_LIST_TAB_KEYS = ['pulls', 'reports', 'not-actionable'] as const+/** The flat report-list tabs that share the keyed reportListLogic + InboxReportList primitive. */+export const INBOX_FLAT_LIST_TAB_KEYS = ['pulls', 'reports', 'not-actionable', 'archived'] as constexport type InboxFlatListTabKey = (typeof INBOX_FLAT_LIST_TAB_KEYS)[number]export interface InboxTabCounts {@@ -136,9 +141,10 @@ export interface InboxTabCounts {reports: number'not-actionable': numberruns: number+ archived: number}-export const EMPTY_TAB_COUNTS: InboxTabCounts = { pulls: 0, reports: 0, 'not-actionable': 0, runs: 0 }+export const EMPTY_TAB_COUNTS: InboxTabCounts = { pulls: 0, reports: 0, 'not-actionable': 0, runs: 0, archived: 0 }/** `for-you` (suggested-reviewer reports), `entire-project` (all), or `teammate:<uuid>`. */export type InboxScope = 'for-you' | 'entire-project' | `teammate:${string}`diff --git a/frontend/src/scenes/inbox/utils/dismissalReasons.ts b/frontend/src/scenes/inbox/utils/dismissalReasons.tsindex 81bfabaf1d6f..74f20118f6e6 100644--- a/frontend/src/scenes/inbox/utils/dismissalReasons.ts+++ b/frontend/src/scenes/inbox/utils/dismissalReasons.ts@@ -36,3 +36,11 @@ export function isDismissalReasonSnooze(value: DismissalReasonValue): boolean {const option = DISMISSAL_REASON_OPTIONS.find((o) => o.value === value)return option != null && 'snoozesInsteadOfDismiss' in option && option.snoozesInsteadOfDismiss === true}++/** Human label for a persisted dismissal reason code, or the raw code if it's not a known option. */+export function dismissalReasonLabel(value: string | null | undefined): string | null {+ if (!value) {+ return null+ }+ return DISMISSAL_REASON_OPTIONS.find((o) => o.value === value)?.label ?? value+}diff --git a/products/signals/backend/migrations/0042_signalreport_status_before_suppression.py b/products/signals/backend/migrations/0042_signalreport_status_before_suppression.pynew file mode 100644index 000000000000..5b6c829f2e4b--- /dev/null+++ b/products/signals/backend/migrations/0042_signalreport_status_before_suppression.py@@ -0,0 +1,32 @@+# Generated by Django 5.2.14 on 2026-06-19 15:52++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("signals", "0041_alter_signalscoutconfig_run_interval_minutes"),+ ]++ operations = [+ migrations.AddField(+ model_name="signalreport",+ name="status_before_suppression",+ field=models.CharField(+ blank=True,+ choices=[+ ("potential", "Potential"),+ ("candidate", "Candidate"),+ ("in_progress", "In Progress"),+ ("pending_input", "Pending Input"),+ ("ready", "Ready"),+ ("resolved", "Resolved"),+ ("failed", "Failed"),+ ("deleted", "Deleted"),+ ("suppressed", "Suppressed"),+ ],+ max_length=20,+ null=True,+ ),+ ),+ ]diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txtindex 15c7a70c8c57..4a7de5ac5b61 100644--- a/products/signals/backend/migrations/max_migration.txt+++ b/products/signals/backend/migrations/max_migration.txt@@ -1 +1 @@-0041_alter_signalscoutconfig_run_interval_minutes+0042_signalreport_status_before_suppressiondiff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex 9240ee547030..6f79e2b47907 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -166,6 +166,10 @@ class SignalReport(UUIDModel):team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)status = models.CharField(max_length=20, choices=Status, default=Status.POTENTIAL)+ # The status held immediately before the report was suppressed (archived). Lets "restore"+ # return the report to where it was instead of always dropping it back to POTENTIAL.+ # Null for reports that were never suppressed (and cleared again on restore).+ status_before_suppression = models.CharField(max_length=20, choices=Status, null=True, blank=True)total_weight = models.FloatField(default=0.0)signal_count = models.IntegerField(default=0)@@ -267,6 +271,9 @@ class SignalReport(UUIDModel):case (S.IN_PROGRESS | S.SUPPRESSED | S.READY | S.RESOLVED, S.POTENTIAL):self.promoted_at = Noneupdated_fields.add("promoted_at")+ if self.status == S.SUPPRESSED:+ self.status_before_suppression = None+ updated_fields.add("status_before_suppression")if snooze_for is not None:self.signals_at_run = self.signal_count + snooze_forupdated_fields.add("signals_at_run")@@ -277,6 +284,14 @@ class SignalReport(UUIDModel):self.error = errorupdated_fields.add("error")+ # Restore (un-archive) a suppressed report to the researched, user-visible state it held+ # before suppression. Title/summary/error are already set from the earlier research run,+ # so they are preserved as-is. In-flight states (candidate/in_progress) are never restored+ # here — they have no live workflow to resume and instead route back through POTENTIAL above.+ case (S.SUPPRESSED, S.PENDING_INPUT | S.READY | S.RESOLVED | S.FAILED):+ self.status_before_suppression = None+ updated_fields.add("status_before_suppression")+# Any non-deleted status can failcase (S.POTENTIAL | S.CANDIDATE | S.IN_PROGRESS | S.PENDING_INPUT | S.READY | S.RESOLVED, S.FAILED):if error is None:@@ -289,8 +304,10 @@ class SignalReport(UUIDModel):S.POTENTIAL | S.CANDIDATE | S.IN_PROGRESS | S.PENDING_INPUT | S.READY | S.RESOLVED | S.FAILED,S.SUPPRESSED,):+ # Remember where it was so "restore" can return it there (see restore_target_status).+ self.status_before_suppression = self.statusself.promoted_at = None- updated_fields.add("promoted_at")+ updated_fields.update(["status_before_suppression", "promoted_at"])# Any non-deleted status can be deletedcase (@@ -319,6 +336,22 @@ class SignalReport(UUIDModel):updated_fields.update(["status", "updated_at"])return list(updated_fields)+ def restore_target_status(self) -> "SignalReport.Status":+ """+ The status a suppressed report should return to on restore (un-archive).++ A report archived while fully researched (ready / pending_input / resolved / failed) returns+ to that exact state so it reappears where the user archived it from. Anything else — including+ in-flight states with no live workflow, or legacy rows with no recorded prior status — routes+ back through POTENTIAL to re-enter the pipeline.+ """+ S = self.Status+ researched = {S.READY, S.PENDING_INPUT, S.RESOLVED, S.FAILED}+ prior = self.status_before_suppression+ if prior in {s.value for s in researched}:+ return S(prior)+ return S.POTENTIAL+class SignalEmissionRecord(UUIDModel):"""Tracks which source records have been emitted as signals.diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex bea93f441431..62760ea7ff3e 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -1162,3 +1162,50 @@ class TestSignalReportSuppressionAPI(APIBaseTest):assert response.status_code == status.HTTP_200_OK, response.json()report.refresh_from_db()assert report.status == SignalReport.Status.POTENTIAL++ @parameterized.expand(+ [+ # prior status before archiving, expected status after restore+ ("ready", SignalReport.Status.READY, SignalReport.Status.READY),+ ("pending_input", SignalReport.Status.PENDING_INPUT, SignalReport.Status.PENDING_INPUT),+ ("resolved", SignalReport.Status.RESOLVED, SignalReport.Status.RESOLVED),+ ("failed", SignalReport.Status.FAILED, SignalReport.Status.FAILED),+ # In-flight / pre-research states have no live workflow, so restore re-enters the pipeline.+ ("potential", SignalReport.Status.POTENTIAL, SignalReport.Status.POTENTIAL),+ ("candidate", SignalReport.Status.CANDIDATE, SignalReport.Status.POTENTIAL),+ ("in_progress", SignalReport.Status.IN_PROGRESS, SignalReport.Status.POTENTIAL),+ ]+ )+ def test_restore_returns_report_to_pre_suppression_status(self, _name, prior_status, expected_restored_status):+ report = SignalReport.objects.create(team=self.team, status=prior_status, title="t", summary="s")++ suppress = self.client.post(+ self._state_url(str(report.id)), data=json.dumps({"state": "suppressed"}), content_type="application/json"+ )+ assert suppress.status_code == status.HTTP_200_OK, suppress.json()+ report.refresh_from_db()+ assert report.status == SignalReport.Status.SUPPRESSED+ assert report.status_before_suppression == prior_status++ restore = self.client.post(+ self._state_url(str(report.id)), data=json.dumps({"state": "potential"}), content_type="application/json"+ )+ assert restore.status_code == status.HTTP_200_OK, restore.json()+ report.refresh_from_db()+ assert report.status == expected_restored_status+ assert report.status_before_suppression is None++ def test_restore_preserves_title_and_summary(self):+ report = SignalReport.objects.create(+ team=self.team, status=SignalReport.Status.READY, title="Original title", summary="Original summary"+ )+ self.client.post(+ self._state_url(str(report.id)), data=json.dumps({"state": "suppressed"}), content_type="application/json"+ )+ self.client.post(+ self._state_url(str(report.id)), data=json.dumps({"state": "potential"}), content_type="application/json"+ )+ report.refresh_from_db()+ assert report.status == SignalReport.Status.READY+ assert report.title == "Original title"+ assert report.summary == "Original summary"diff --git a/products/signals/backend/views.py b/products/signals/backend/views.pyindex 31a8d75e798d..d0fb0b671f25 100644--- a/products/signals/backend/views.py+++ b/products/signals/backend/views.py@@ -1016,8 +1016,15 @@ class SignalReportViewSet(# passed explicitly rather than splatting caller-supplied kwargs.snooze_for = data.get("snooze_for") if target == "potential" else None+ # "potential" on a suppressed report means "restore" (un-archive): return it to the state it+ # held before suppression when that was a researched, user-visible report, instead of always+ # dropping back to potential. snooze_for is irrelevant here and ignored by transition_to.+ target_status = SignalReport.Status(target)+ if report.status == SignalReport.Status.SUPPRESSED and target_status == SignalReport.Status.POTENTIAL:+ target_status = report.restore_target_status()+try:- updated_fields = report.transition_to(SignalReport.Status(target), snooze_for=snooze_for)+ updated_fields = report.transition_to(target_status, snooze_for=snooze_for)except InvalidStatusTransition as e:logger.warning("Invalid status transition for SignalReport %s: %s", report.id, e, exc_info=True)return Response(