:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop): show clear feedback after report dismissal (#97947)
Dylan Martin82d34b4ea522
diff --git a/products/desktop/docs/INBOX-REPORT-STATES.md b/products/desktop/docs/INBOX-REPORT-STATES.mdnew file mode 100644index 000000000000..2ae446ddd5c0--- /dev/null+++ b/products/desktop/docs/INBOX-REPORT-STATES.md@@ -0,0 +1,31 @@+# Inbox report states++The report banner distinguishes a waiting report from an active investigation:++| State | Banner | Investigation spinner |+| --- | --- | --- |+| `potential` | Waiting for new signals | No |+| `potential` with dismissal reason `already_fixed` | Dismissed until new signals | No |+| `candidate` | Waiting to investigate | No |+| `in_progress` | Agent investigating | Yes |++Choosing **Already fixed** in the Dismiss dialog pauses the report. It returns to+`potential` and can return to the inbox when new matching signals arrive. This+action does not start an investigation. Other dismissal reasons archive the+report with status `suppressed`.++**Already fixed** is available for `in_progress`, `pending_input`, `ready`, and+`failed` reports. It is disabled for `potential` and `candidate` reports. These+reports can still be archived with another dismissal reason.++A `candidate` report does not always have a queued investigation. It can also+be waiting after a quota limit or unavailable signal data stops a run.++If another action archives the report before the pause request completes, the+server rejects the pause. The report stays archived. Restore requests can include+feedback notes. Requests with a pause interval or the `already_fixed` reason+cannot restore an archived report.++Dismissal updates the report immediately. A success message appears after the+server confirms the change. If the request fails, the previous report state is+restored and an error message appears.diff --git a/products/desktop/docs/README.md b/products/desktop/docs/README.mdindex 38c2afba4abc..f68c94fc398e 100644--- a/products/desktop/docs/README.md+++ b/products/desktop/docs/README.md@@ -25,6 +25,7 @@ Start with the guide that matches the work you are doing. [AGENTS.md](../AGENTS.| Guide | Use it for || --- | --- |+| [Inbox report states](./INBOX-REPORT-STATES.md) | Understand dismissal feedback and investigation status. || [Deep links](./DEEP-LINKS.md) | Work with `posthog-code://` routes and OAuth callbacks. || [Pi extensions](./PI-EXTENSIONS.md) | Understand repository trust and desktop RPC behavior for Pi extensions. || [Cloud MCP import](./CLOUD-MCP-IMPORT.md) | Understand importing local MCP configuration into cloud task runs. |diff --git a/products/desktop/packages/core/src/inbox/reportVerdict.test.ts b/products/desktop/packages/core/src/inbox/reportVerdict.test.tsindex 3199e378935d..fa9d0c46fd7b 100644--- a/products/desktop/packages/core/src/inbox/reportVerdict.test.ts+++ b/products/desktop/packages/core/src/inbox/reportVerdict.test.ts@@ -26,8 +26,26 @@ describe("deriveReportVerdict", () => {[{ status: "deleted" }, false, "Archived", "info"],[{ status: "failed" }, false, "Run failed", "danger"],[{ status: "pending_input" }, false, "Waiting on you", "decision"],- [{ status: "potential" }, false, "Agent investigating", "progress"],- [{ status: "candidate" }, false, "Agent investigating", "progress"],+ [{ status: "potential" }, false, "Waiting for new signals", "info"],+ [+ { status: "potential", dismissal_reason: "already_fixed" },+ false,+ "Dismissed until new signals",+ "info",+ ],+ [+ { status: "potential", dismissal_reason: "already_fixed" },+ true,+ "Dismissed until new signals",+ "info",+ ],+ [{ status: "candidate" }, false, "Waiting to investigate", "info"],+ [+ { status: "in_progress", dismissal_reason: "already_fixed" },+ false,+ "Agent investigating",+ "progress",+ ],[{ status: "in_progress" }, false, "Agent investigating", "progress"],// Ready: an existing PR outranks actionability, which outranks nothing.[diff --git a/products/desktop/packages/core/src/inbox/reportVerdict.ts b/products/desktop/packages/core/src/inbox/reportVerdict.tsindex 41f5397d26d1..7f83f0c301ca 100644--- a/products/desktop/packages/core/src/inbox/reportVerdict.ts+++ b/products/desktop/packages/core/src/inbox/reportVerdict.ts@@ -51,7 +51,23 @@ export function deriveReportVerdict(body: "Review the recommendation. Start an implementation task to add direction and choose a model, or ask for more context.",};case "potential":+ return report.dismissal_reason === "already_fixed"+ ? {+ tone: "info",+ title: "Dismissed until new signals",+ body: "This report was dismissed as already fixed. It can return when another matching signal arrives.",+ }+ : {+ tone: "info",+ title: "Waiting for new signals",+ body: "This report is waiting for more matching signals. No investigation is running.",+ };case "candidate":+ return {+ tone: "info",+ title: "Waiting to investigate",+ body: "No investigation is running yet.",+ };case "in_progress":return {tone: "progress",diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.stories.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.stories.tsxnew file mode 100644index 000000000000..650d50eb1193--- /dev/null+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.stories.tsx@@ -0,0 +1,34 @@+import { inboxStoryReport } from "@posthog/ui/features/inbox/components/inboxStoryFixtures";+import type { Meta, StoryObj } from "@storybook/react-vite";+import { ReportVerdictBanner } from "./ReportVerdictBanner";++const meta: Meta<typeof ReportVerdictBanner> = {+ title: "Inbox/Reports/Report verdict",+ component: ReportVerdictBanner,+ parameters: { layout: "padded" },+ args: {+ report: inboxStoryReport({ status: "potential" }),+ },+};++export default meta;+type Story = StoryObj<typeof ReportVerdictBanner>;++export const WaitingForSignals: Story = {};++export const DismissedAsAlreadyFixed: Story = {+ args: {+ report: inboxStoryReport({+ status: "potential",+ dismissal_reason: "already_fixed",+ }),+ },+};++export const WaitingToInvestigate: Story = {+ args: { report: inboxStoryReport({ status: "candidate" }) },+};++export const Investigating: Story = {+ args: { report: inboxStoryReport({ status: "in_progress" }) },+};diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.test.tsxindex 773aef862cd5..2a6a9df6ceed 100644--- a/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.test.tsx@@ -198,6 +198,27 @@ describe("ReportVerdictBanner", () => {);});+ it("removes the investigation spinner after an already-fixed dismissal", () => {+ const { rerender } = render(+ <ReportVerdictBanner report={{ ...report, status: "in_progress" }} />,+ );+ expect(screen.getByLabelText("Loading")).toBeInTheDocument();++ rerender(+ <ReportVerdictBanner+ report={{+ ...report,+ status: "potential",+ dismissal_reason: "already_fixed",+ }}+ />,+ );++ expect(screen.getByText("Dismissed until new signals")).toBeInTheDocument();+ expect(screen.queryByText("Agent investigating")).not.toBeInTheDocument();+ expect(screen.queryByLabelText("Loading")).not.toBeInTheDocument();+ });+it("offers resolve in triage from both the button and shortcut", async () => {const user = userEvent.setup();render(diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.test.tsx b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.test.tsxindex e0f440d0eeb6..1544722b5b83 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.test.tsx@@ -9,6 +9,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest";const mocks = vi.hoisted(() => ({updateState: vi.fn(),track: vi.fn(),+ success: vi.fn(),+ error: vi.fn(),}));vi.mock("@posthog/ui/features/auth/authClient", () => ({@@ -25,6 +27,10 @@ vi.mock("@posthog/ui/shell/analytics", () => ({track: mocks.track,}));+vi.mock("@posthog/ui/primitives/toast", () => ({+ toast: { success: mocks.success, error: mocks.error },+}));+import { useInboxBulkActions } from "./useInboxBulkActions";const report: SignalReport = {@@ -53,75 +59,171 @@ describe("useInboxBulkActions", () => {vi.clearAllMocks();});- it("keeps report metadata for analytics after an optimistic rerender", async () => {- let finishRequest: (() => void) | undefined;- mocks.updateState.mockReturnValue(- new Promise<void>((resolve) => {- finishRequest = resolve;- }),- );- const queryClient = new QueryClient({- defaultOptions: { mutations: { retry: false } },- });- const { result, rerender } = renderHook(- ({ reports }) => useInboxBulkActions(reports, report.id, "list_row"),- {- initialProps: { reports: [report] },- wrapper: createWrapper(queryClient),- },- );-- let action = Promise.resolve(false);- act(() => {- action = result.current.suppressSelected({ reason: "other", note: "" });- });- await waitFor(() => expect(mocks.updateState).toHaveBeenCalledOnce());- rerender({ reports: [] });- await act(async () => finishRequest?.());-- await expect(action).resolves.toBe(true);- expect(mocks.track).toHaveBeenCalledWith(- ANALYTICS_EVENTS.INBOX_REPORT_ACTION,- expect.objectContaining({ report_id: report.id, action_type: "dismiss" }),- );- });-- it("clears a stale note in the optimistic report", async () => {- mocks.updateState.mockReturnValue(new Promise<void>(() => {}));- const queryClient = new QueryClient({- defaultOptions: { mutations: { retry: false } },- });- queryClient.setQueryData(inboxReportDetailQueryKey(report.id), report);+ it.each([+ ["suppressSelected", "dismiss", "other"],+ ["snoozeSelected", "snooze", "already_fixed"],+ ] as const)(+ "%s confirms success after an optimistic rerender",+ async (actionName, actionType, reason) => {+ let finishRequest: (() => void) | undefined;+ mocks.updateState.mockReturnValue(+ new Promise<void>((resolve) => {+ finishRequest = resolve;+ }),+ );+ const queryClient = new QueryClient({+ defaultOptions: { mutations: { retry: false } },+ });+ const { result, rerender } = renderHook(+ ({ reports }) => useInboxBulkActions(reports, report.id, "list_row"),+ {+ initialProps: { reports: [report] },+ wrapper: createWrapper(queryClient),+ },+ );++ let action = Promise.resolve(false);+ act(() => {+ action = result.current[actionName]({+ reason,+ note: "",+ });+ });+ await waitFor(() => expect(mocks.updateState).toHaveBeenCalledOnce());+ expect(mocks.success).not.toHaveBeenCalled();+ rerender({ reports: [] });+ await act(async () => finishRequest?.());++ await expect(action).resolves.toBe(true);+ expect(mocks.track).toHaveBeenCalledWith(+ ANALYTICS_EVENTS.INBOX_REPORT_ACTION,+ expect.objectContaining({+ report_id: report.id,+ action_type: actionType,+ }),+ );+ expect(mocks.success).toHaveBeenCalledOnce();+ },+ );++ it.each([+ ["potential", false, true],+ ["candidate", false, true],+ ["in_progress", true, true],+ ["pending_input", true, true],+ ["ready", true, true],+ ["failed", true, true],+ ["suppressed", false, false],+ ["resolved", false, false],+ ["deleted", false, false],+ ] as const)(+ "%s has separate pause and archive eligibility",+ async (status, canPause, canArchive) => {+ mocks.updateState.mockResolvedValue({ ...report, status: "potential" });+ const queryClient = new QueryClient({+ defaultOptions: { mutations: { retry: false } },+ });+ const { result } = renderHook(+ () => useInboxBulkActions([{ ...report, status }], report.id),+ { wrapper: createWrapper(queryClient) },+ );++ expect(result.current.snoozeDisabledReason === null).toBe(canPause);+ expect(result.current.suppressDisabledReason === null).toBe(canArchive);+ await act(async () => {+ await expect(+ result.current.snoozeSelected({ reason: "already_fixed", note: "" }),+ ).resolves.toBe(canPause);+ });+ expect(mocks.updateState).toHaveBeenCalledTimes(canPause ? 1 : 0);+ },+ );++ it("blocks pausing a mixed selection that includes a waiting report", async () => {+ const waitingReport: SignalReport = {+ ...report,+ id: "report-2",+ status: "potential",+ };+ const queryClient = new QueryClient();const { result } = renderHook(- () => useInboxBulkActions([report], report.id),- { wrapper: createWrapper(queryClient) },- );-- act(() => {- void result.current.suppressSelected({ reason: "other", note: "" });- });-- await waitFor(() =>- expect(- queryClient.getQueryData<SignalReport>(- inboxReportDetailQueryKey(report.id),- )?.dismissal_note,- ).toBeNull(),- );- });-- it("returns false when any selected dismissal fails", async () => {- mocks.updateState.mockRejectedValue(new Error("Request failed"));- const queryClient = new QueryClient({- defaultOptions: { mutations: { retry: false } },- });- const { result } = renderHook(- () => useInboxBulkActions([report], report.id),+ () =>+ useInboxBulkActions(+ [report, waitingReport],+ [report.id, waitingReport.id],+ ),{ wrapper: createWrapper(queryClient) },);+ expect(result.current.suppressDisabledReason).toBeNull();await expect(- result.current.suppressSelected({ reason: "other", note: "" }),+ result.current.snoozeSelected({ reason: "already_fixed", note: "" }),).resolves.toBe(false);+ expect(mocks.updateState).not.toHaveBeenCalled();});++ it.each([+ ["suppressSelected", "suppressed", "other"],+ ["snoozeSelected", "potential", "already_fixed"],+ ] as const)(+ "%s updates the report before the request finishes",+ async (actionName, status, reason) => {+ mocks.updateState.mockReturnValue(new Promise<void>(() => {}));+ const queryClient = new QueryClient({+ defaultOptions: { mutations: { retry: false } },+ });+ queryClient.setQueryData(inboxReportDetailQueryKey(report.id), report);+ const { result } = renderHook(+ () => useInboxBulkActions([report], report.id),+ { wrapper: createWrapper(queryClient) },+ );++ act(() => {+ void result.current[actionName]({ reason, note: "" });+ });++ await waitFor(() =>+ expect(+ queryClient.getQueryData<SignalReport>(+ inboxReportDetailQueryKey(report.id),+ ),+ ).toEqual(+ expect.objectContaining({+ status,+ dismissal_reason: reason,+ dismissal_note: null,+ }),+ ),+ );+ },+ );++ it.each([+ ["suppressSelected", "other"],+ ["snoozeSelected", "already_fixed"],+ ] as const)(+ "%s restores the report and reports a failed request",+ async (actionName, reason) => {+ mocks.updateState.mockRejectedValue(new Error("Request failed"));+ const queryClient = new QueryClient({+ defaultOptions: { mutations: { retry: false } },+ });+ queryClient.setQueryData(inboxReportDetailQueryKey(report.id), report);+ const { result } = renderHook(+ () => useInboxBulkActions([report], report.id),+ { wrapper: createWrapper(queryClient) },+ );++ await expect(+ result.current[actionName]({ reason, note: "" }),+ ).resolves.toBe(false);+ expect(+ queryClient.getQueryData(inboxReportDetailQueryKey(report.id)),+ ).toEqual(report);+ expect(mocks.success).not.toHaveBeenCalled();+ expect(mocks.error).toHaveBeenCalledWith(+ expect.stringContaining("1 failed"),+ );+ },+ );});diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.tsindex 0a13e29d6d6d..3dc864a738d2 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts@@ -93,7 +93,6 @@ async function runBulkAction(};}-/** Active workflow statuses for snooze and suppress. Terminal `suppressed` / `deleted` are excluded. */const suppressibleStatuses = new Set<SignalReport["status"]>(["potential","candidate",@@ -103,6 +102,13 @@ const suppressibleStatuses = new Set<SignalReport["status"]>(["failed",]);+const snoozableStatuses = new Set<SignalReport["status"]>([+ "in_progress",+ "pending_input",+ "ready",+ "failed",+]);+/** Clause after "Disabled because …" (see `@posthog/ui/primitives/Button`). */const DISABLED_NO_SELECTION = "you haven't selected a report";@@ -138,7 +144,7 @@ function formatBulkActionSummary(action === "suppress"? `${pluralized} dismissed`: action === "snooze"- ? `${pluralized} snoozed`+ ? `${pluralized} paused until new signals arrive`: action === "delete"? `${pluralized} deleted`: action === "reingest"@@ -150,7 +156,7 @@ function formatBulkActionSummary(return `${successCount} ${formulated}, ${failureCount} failed`;}-function getSnoozeOrSuppressDisabledReason(+function getSuppressDisabledReason(selectedCount: number,selectedReports: SignalReport[],): string | null {@@ -176,7 +182,7 @@ function getSelectedReportEligibility();const selectedCount = selectedReports.length;- const snoozeOrSuppressDisabledReason = getSnoozeOrSuppressDisabledReason(+ const suppressDisabledReason = getSuppressDisabledReason(selectedCount,selectedReports,);@@ -185,8 +191,12 @@ function getSelectedReportEligibility(selectedReports,selectedIds: selectedReports.map((report) => report.id),selectedCount,- snoozeDisabledReason: snoozeOrSuppressDisabledReason,- suppressDisabledReason: snoozeOrSuppressDisabledReason,+ snoozeDisabledReason:+ suppressDisabledReason ??+ (selectedReports.every((report) => snoozableStatuses.has(report.status))+ ? null+ : "a selected report is waiting for signals or an investigation"),+ suppressDisabledReason,deleteDisabledReason: selectedCount === 0 ? DISABLED_NO_SELECTION : null,reingestDisabledReason: selectedCount === 0 ? DISABLED_NO_SELECTION : null,removeReviewerDisabledReason:@@ -503,6 +513,8 @@ export function useInboxBulkActions(if (result.failureCount > 0) {toast.error(formatBulkActionSummary("snooze", result));+ } else {+ toast.success(formatBulkActionSummary("snooze", result));}},onError: (error, _variables, context) => {diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex b2c87ab09b04..b3f88fde1529 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -2440,6 +2440,32 @@ class TestSignalReportSuppressionAPI(APIBaseTest):assert report.status == SignalReport.Status.POTENTIALassert report.signals_at_run == 15+ @parameterized.expand(+ [+ ("snooze", {"snooze_for": 1}),+ ("dismissal", {"snooze_for": 1, "dismissal_reason": "already_fixed", "dismissal_note": "Fixed"}),+ ("feedback", {"dismissal_reason": "already_fixed"}),+ ]+ )+ def test_pause_does_not_restore_an_archived_report(self, _name, pause_input):+ report = self._create_report()+ response = self.client.post(+ self._state_url(str(report.id)), data=json.dumps({"state": "suppressed"}), content_type="application/json"+ )+ assert response.status_code == status.HTTP_200_OK++ response = self.client.post(+ self._state_url(str(report.id)),+ data=json.dumps({"state": "potential", **pause_input}),+ content_type="application/json",+ )++ assert response.status_code == status.HTTP_409_CONFLICT+ report.refresh_from_db()+ assert report.status == SignalReport.Status.SUPPRESSED+ assert report.status_before_suppression == SignalReport.Status.READY+ assert not report.artefacts.filter(type=SignalReportArtefact.ArtefactType.DISMISSAL).exists()+@parameterized.expand([("zero", 0), ("negative", -1), ("too_large", 100_001)])def test_snooze_for_out_of_bounds_rejected(self, _name, snooze_for):report = self._create_report()diff --git a/products/signals/backend/views.py b/products/signals/backend/views.pyindex e6645b6935f6..657039fbf143 100644--- a/products/signals/backend/views.py+++ b/products/signals/backend/views.py@@ -2698,9 +2698,14 @@ class SignalReportViewSet(# "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.+ # always dropping back to potential.effective_target = target_statusif report.status == SignalReport.Status.SUPPRESSED and target_status == SignalReport.Status.POTENTIAL:+ if snooze_for is not None or dismissal_reason == "already_fixed":+ return (+ SignalReportBulkStateOutcome.SKIPPED,+ "This report is archived. Refresh it before continuing.",+ )effective_target = report.restore_target_status()effective_snooze_for = snooze_for if target == "potential" else None