: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): improve self-driving report dialogs (#100815)
Adam Leithbda79c297344
diff --git a/products/desktop/packages/ui/src/features/inbox/components/DismissReportDialog.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/DismissReportDialog.test.tsxindex 19bcf44af746..b170f3941786 100644--- a/products/desktop/packages/ui/src/features/inbox/components/DismissReportDialog.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/DismissReportDialog.test.tsx@@ -17,33 +17,83 @@ const report = {} satisfies SignalReport;describe("DismissReportDialog", () => {- it("keeps dismiss nomenclature while explaining temporary behavior", async () => {+ it("groups reasons by outcome and explains the choice above the footer", async () => {const user = userEvent.setup();render(<DismissReportDialogopenonOpenChange={vi.fn()}- report={report}+ report={{+ ...report,+ implementation_pr_url: "https://example.com/pr/1",+ }}isSubmitting={false}snoozeDisabledReason={null}onConfirm={vi.fn()}/>,);+ const description = screen.getByText(/dismisses the report for everyone/);+ expect(+ screen.getByRole("group", { name: "Pause until a new matching signal" }),+ ).toContainElement(screen.getByRole("radio", { name: "Already fixed" }));expect(- screen.getByText('Dismiss report "Checkout errors"?'),- ).toBeInTheDocument();- expect(screen.getByText(/dismisses the report for everyone/)).toBeTruthy();+ screen.getByRole("group", { name: "Don't surface again" }),+ ).toContainElement(screen.getByRole("radio", { name: "Something else…" }));await user.click(screen.getByRole("radio", { name: "Already fixed" }));+ expect(description).toHaveTextContent(/dismisses the report for everyone/);+ expect(+ screen.getByText(+ "The report comes back if another matching signal arrives.",+ ),+ ).toBeVisible();+ await user.click(+ screen.getByRole("radio", { name: "Agent's analysis is wrong" }),+ );expect(- screen.getByText('Dismiss report "Checkout errors"?'),- ).toBeInTheDocument();- expect(screen.getByText(/dismisses the report until/)).toBeTruthy();+ screen.getByText(+ "Matching signals won't surface the report again. The open pull request will be closed.",+ ),+ ).toBeVisible();+ });++ it("selects the other reason when the user enters a note first", async () => {+ const user = userEvent.setup();+ const onConfirm = vi.fn();+ render(+ <DismissReportDialog+ open+ onOpenChange={vi.fn()}+ report={report}+ isSubmitting={false}+ snoozeDisabledReason={null}+ onConfirm={onConfirm}+ />,+ );++ const submitButton = screen.getByRole("button", {+ name: "Dismiss report",+ });+ expect(submitButton).toHaveAttribute("aria-disabled", "true");++ await user.type(+ screen.getByLabelText("Details (optional)"),+ "The report needs more context.",+ );+expect(- screen.getByRole("button", { name: "Dismiss report" }),- ).toBeInTheDocument();+ screen.getByRole("radio", { name: "Something else…" }),+ ).toBeChecked();+ expect(submitButton).toHaveAttribute("aria-disabled", "false");++ await user.click(submitButton);++ expect(onConfirm).toHaveBeenCalledWith({+ reason: "other",+ note: "The report needs more context.",+ });});it("preselects a context-menu reason and focuses the note", () => {@@ -62,6 +112,6 @@ describe("DismissReportDialog", () => {expect(screen.getByRole("radio", { name: "Something else…" }),).toBeChecked();- expect(screen.getByPlaceholderText("Optional: add detail")).toHaveFocus();+ expect(screen.getByLabelText("Details (optional)")).toHaveFocus();});});diff --git a/products/desktop/packages/ui/src/features/inbox/components/DismissReportDialog.tsx b/products/desktop/packages/ui/src/features/inbox/components/DismissReportDialog.tsxindex 9846fced1a9f..efdcc34a16cd 100644--- a/products/desktop/packages/ui/src/features/inbox/components/DismissReportDialog.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/DismissReportDialog.tsx@@ -1,4 +1,3 @@-import { EyeSlashIcon, PauseIcon } from "@phosphor-icons/react";import {Button,Dialog,@@ -13,9 +12,6 @@ import {RadioGroup,RadioGroupItem,Textarea,- Tooltip,- TooltipContent,- TooltipTrigger,} from "@posthog/quill";import {DISMISSAL_REASON_OPTIONS,@@ -98,6 +94,33 @@ function DismissReportDialogBody({const hasOpenPr =Boolean(report.implementation_pr_url) &&report.implementation_pr_merged !== true;+ const pauseOptions = DISMISSAL_REASON_OPTIONS.filter((option) =>+ isDismissalReasonSnooze(option.value),+ );+ const hideOptions = DISMISSAL_REASON_OPTIONS.filter(+ (option) => !isDismissalReasonSnooze(option.value),+ );+ const outcome =+ reason == null+ ? null+ : pausesReport+ ? `The ${reportNoun} comes back if another matching signal arrives.`+ : `Matching signals won't surface the ${reportNoun} again.${hasOpenPr ? " The open pull request will be closed." : ""}`;++ const renderOption = (+ option: (typeof DISMISSAL_REASON_OPTIONS)[number],+ disabled: boolean,+ ): React.JSX.Element => {+ const id = `${fieldId}-${option.value}`;+ return (+ <div key={option.value} className="flex items-center gap-2">+ <RadioGroupItem value={option.value} id={id} disabled={disabled} />+ <Label htmlFor={id} className="cursor-pointer font-normal">+ {option.label}+ </Label>+ </div>+ );+ };return (<>@@ -108,12 +131,7 @@ function DismissReportDialogBody({: `Dismiss report "${title}"?`}</DialogTitle><DialogDescription>- {pausesReport- ? `This dismisses the ${reportNoun} until another matching signal arrives.`- : `This dismisses the ${reportNoun} for everyone in this project. Your feedback is saved and helps the agent.`}- {hasOpenPr && !pausesReport- ? " The open pull request will be closed."- : ""}+ {`This dismisses the ${reportNoun} for everyone in this project. Your feedback is saved and helps the agent.`}</DialogDescription></DialogHeader>@@ -124,55 +142,68 @@ function DismissReportDialogBody({onValueChange={(value) =>setReason(value as DismissalReasonOptionValue)}+ className="gap-4">- {DISMISSAL_REASON_OPTIONS.map((option) => {- const pauses = isDismissalReasonSnooze(option.value);- const disabled = pauses && snoozeDisabledReason !== null;- const id = `${fieldId}-${option.value}`;- const explanation = disabled- ? snoozeDisabledReason- : pauses- ? "Dismiss this report until another matching signal arrives."- : "Dismiss this report so matching signals do not surface it again.";- return (- <div key={option.value} className="flex items-center gap-2">- <RadioGroupItem- value={option.value}- id={id}- disabled={disabled}- />- <Tooltip>- <TooltipTrigger- render={- <Label- htmlFor={id}- className="flex cursor-pointer items-center gap-1.5 font-normal"- />- }- >- {option.label}- {pauses ? (- <PauseIcon size={12} className="text-(--gray-9)" />- ) : (- <EyeSlashIcon size={12} className="text-(--gray-9)" />- )}- </TooltipTrigger>- <TooltipContent side="right">{explanation}</TooltipContent>- </Tooltip>- </div>- );- })}+ <fieldset+ aria-describedby={+ snoozeDisabledReason ? `${fieldId}-pause-disabled` : undefined+ }+ className="flex flex-col gap-2"+ >+ <legend className="mb-2 font-medium text-(--gray-11) text-xs">+ Pause until a new matching signal+ </legend>+ {snoozeDisabledReason ? (+ <span+ id={`${fieldId}-pause-disabled`}+ className="-mt-2 text-(--gray-9) text-xs"+ >+ {snoozeDisabledReason}+ </span>+ ) : null}+ {pauseOptions.map((option) =>+ renderOption(option, snoozeDisabledReason !== null),+ )}+ </fieldset>+ <fieldset className="flex flex-col gap-2">+ <legend className="mb-2 font-medium text-(--gray-11) text-xs">+ Don't surface again+ </legend>+ {hideOptions.map((option) => renderOption(option, false))}+ </fieldset></RadioGroup>- <Textarea- autoFocus={initialReason != null}- value={note}- onChange={(event) => setNote(event.target.value)}- placeholder="Optional: add detail"- rows={3}- maxLength={4000}- disabled={isSubmitting}- />+ <div className="flex flex-col gap-2">+ <Label+ htmlFor={`${fieldId}-note`}+ className="font-medium text-(--gray-11) text-xs"+ >+ Details (optional)+ </Label>+ <Textarea+ id={`${fieldId}-note`}+ autoFocus={initialReason != null}+ value={note}+ onChange={(event) => {+ const value = event.target.value;+ setNote(value);+ if (reason === null && value.trim()) {+ setReason("other");+ }+ }}+ placeholder="What should the agent know?"+ rows={3}+ maxLength={4000}+ disabled={isSubmitting}+ />+ </div>++ <p+ aria-live="polite"+ className="text-muted-foreground text-xs empty:hidden"+ >+ {outcome}+ </p></div></DialogBody>diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportTriageFocus.dismiss.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportTriageFocus.dismiss.test.tsxindex 735bb01624b6..e12ccc74c209 100644--- a/products/desktop/packages/ui/src/features/inbox/components/ReportTriageFocus.dismiss.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportTriageFocus.dismiss.test.tsx@@ -124,7 +124,7 @@ describe("ReportTriageFocus dismiss", () => {);await user.keyboard("a");- await screen.findByPlaceholderText("Optional: add detail");+ await screen.findByLabelText("Details (optional)");await user.click(screen.getByRole("radio", { name: /Agent's analysis is wrong/ }),);@@ -132,7 +132,7 @@ describe("ReportTriageFocus dismiss", () => {await waitFor(() => expect(mocks.updateState).toHaveBeenCalled());expect(- screen.queryByPlaceholderText("Optional: add detail"),+ screen.queryByLabelText("Details (optional)"),).not.toBeInTheDocument();await act(async () => {diff --git a/products/desktop/packages/ui/src/features/inbox/components/ResolveReportDialog.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/ResolveReportDialog.test.tsxindex 93ad33acb28c..0e8192880232 100644--- a/products/desktop/packages/ui/src/features/inbox/components/ResolveReportDialog.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/ResolveReportDialog.test.tsx@@ -1,5 +1,6 @@import type { SignalReport } from "@posthog/shared/types";import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";import { describe, expect, it, vi } from "vitest";import { ResolveReportDialog } from "./ResolveReportDialog";@@ -16,6 +17,44 @@ const report = {} satisfies SignalReport;describe("ResolveReportDialog", () => {+ it("selects the other reason when the user enters a note first", async () => {+ const user = userEvent.setup();+ const onConfirm = vi.fn();+ render(+ <ResolveReportDialog+ open+ onOpenChange={vi.fn()}+ report={report}+ isSubmitting={false}+ onConfirm={onConfirm}+ />,+ );++ const submitButton = screen.getByRole("button", {+ name: "Resolve report",+ });+ expect(submitButton).toHaveAttribute("aria-disabled", "true");++ await user.type(+ screen.getByPlaceholderText(+ "Optional: link to the fix or explain what changed",+ ),+ "The fix is in another service.",+ );++ expect(+ screen.getByRole("radio", { name: "Something else…" }),+ ).toBeChecked();+ expect(submitButton).toHaveAttribute("aria-disabled", "false");++ await user.click(submitButton);++ expect(onConfirm).toHaveBeenCalledWith({+ reason: "other",+ note: "The fix is in another service.",+ });+ });+it("preselects a context-menu reason and focuses the note", () => {render(<ResolveReportDialogdiff --git a/products/desktop/packages/ui/src/features/inbox/components/ResolveReportDialog.tsx b/products/desktop/packages/ui/src/features/inbox/components/ResolveReportDialog.tsxindex bdd4a99955a1..49ac615e4ee0 100644--- a/products/desktop/packages/ui/src/features/inbox/components/ResolveReportDialog.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/ResolveReportDialog.tsx@@ -93,7 +93,13 @@ export function ResolveReportDialog({<TextareaautoFocus={initialReason != null}value={note}- onChange={(event) => setNote(event.target.value)}+ onChange={(event) => {+ const value = event.target.value;+ setNote(value);+ if (reason === null && value.trim()) {+ setReason("other");+ }+ }}placeholder="Optional: link to the fix or explain what changed"rows={3}maxLength={4000}diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportDismissAction.test.tsx b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportDismissAction.test.tsxindex c38050accc95..2ff42202c258 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportDismissAction.test.tsx+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportDismissAction.test.tsx@@ -77,7 +77,7 @@ async function enterDismissal(user: ReturnType<typeof userEvent.setup>) {screen.getByRole("radio", { name: /Agent's analysis is wrong/ }),);await user.type(- screen.getByPlaceholderText("Optional: add detail"),+ screen.getByLabelText("Details (optional)"),"Retain this note",);await user.click(screen.getByText("Dismiss report"));@@ -101,7 +101,7 @@ describe("useInboxReportDismissAction", () => {await enterDismissal(user);await waitFor(() => expect(mocks.toastError).toHaveBeenCalled());- expect(screen.getByPlaceholderText("Optional: add detail")).toHaveValue(+ expect(screen.getByLabelText("Details (optional)")).toHaveValue("Retain this note",);});@@ -119,7 +119,7 @@ describe("useInboxReportDismissAction", () => {await enterDismissal(user);expect(- screen.queryByPlaceholderText("Optional: add detail"),+ screen.queryByLabelText("Details (optional)"),).not.toBeInTheDocument();await act(async () => {@@ -137,7 +137,7 @@ describe("useInboxReportDismissAction", () => {await waitFor(() => expect(mocks.updateState).toHaveBeenCalled());expect(mocks.toastSuccess).toHaveBeenCalledWith("1 report dismissed");expect(- screen.queryByPlaceholderText("Optional: add detail"),+ screen.queryByLabelText("Details (optional)"),).not.toBeInTheDocument();});@@ -168,7 +168,7 @@ describe("useInboxReportDismissAction", () => {name: /Agent's analysis is wrong/,}),).toBeChecked();- expect(screen.getByPlaceholderText("Optional: add detail")).toHaveValue(+ expect(screen.getByLabelText("Details (optional)")).toHaveValue("Retain this note",);});