Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): mobile group report dismissal reasons (#101555)

Tom Owerscc4245a8a038
diff --git a/products/desktop/apps/mobile/src/app/inbox/[...id].tsx b/products/desktop/apps/mobile/src/app/inbox/[...id].tsx
index b979b98e3e5e..74bfb8e22789 100644
--- a/products/desktop/apps/mobile/src/app/inbox/[...id].tsx
+++ b/products/desktop/apps/mobile/src/app/inbox/[...id].tsx
@@ -659,6 +659,10 @@ export default function ReportDetailScreen() {
visible={dismissOpen}
reportId={report.id}
reportTitle={report.title?.trim() ? report.title : "Untitled report"}
+ hasOpenPr={
+ Boolean(report.implementation_pr_url) &&
+ report.implementation_pr_merged !== true
+ }
onClose={() => setDismissOpen(false)}
onDismissed={handleDismissed}
/>
diff --git a/products/desktop/apps/mobile/src/features/inbox/components/DismissReportSheet.test.tsx b/products/desktop/apps/mobile/src/features/inbox/components/DismissReportSheet.test.tsx
index 25b844779528..69cb68dff6d6 100644
--- a/products/desktop/apps/mobile/src/features/inbox/components/DismissReportSheet.test.tsx
+++ b/products/desktop/apps/mobile/src/features/inbox/components/DismissReportSheet.test.tsx
@@ -1,4 +1,7 @@
-import { DISMISSAL_REASON_OPTIONS } from "@posthog/shared";
+import {
+ DISMISSAL_REASON_OPTIONS,
+ isDismissalReasonSnooze,
+} from "@posthog/shared";
import { createElement } from "react";
import { act, create, type ReactTestInstance } from "react-test-renderer";
import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -50,7 +53,7 @@ import { DismissReportSheet } from "./DismissReportSheet";
const REPORT_ID = "report-1";
const FIRST_REASON = DISMISSAL_REASON_OPTIONS[0];
-function renderSheet(visible = true) {
+function renderSheet(visible = true, extraProps: { hasOpenPr?: boolean } = {}) {
const onClose = vi.fn();
const onDismissed = vi.fn();
let renderer: ReturnType<typeof create> | null = null;
@@ -62,6 +65,7 @@ function renderSheet(visible = true) {
reportTitle: "Report one",
onClose,
onDismissed,
+ ...extraProps,
}),
);
});
@@ -93,6 +97,39 @@ function noteInput(renderer: ReturnType<typeof create>): ReactTestInstance {
);
}
+function findRadioByLabel(
+ renderer: ReturnType<typeof create>,
+ label: string,
+): ReactTestInstance {
+ const matches = renderer.root.findAll(
+ (n) =>
+ n.props?.accessibilityLabel === label &&
+ typeof n.props?.onPress === "function",
+ );
+ if (matches.length === 0) throw new Error(`No radio for ${label}`);
+ return matches[0];
+}
+
+function findGroupByLabel(
+ renderer: ReturnType<typeof create>,
+ label: string,
+): ReactTestInstance {
+ const matches = renderer.root.findAll(
+ (n) =>
+ n.props?.accessibilityLabel === label &&
+ n.props?.accessibilityRole === "radiogroup",
+ );
+ if (matches.length === 0) throw new Error(`No group for ${label}`);
+ return matches[0];
+}
+
+function hasTextNode(
+ renderer: ReturnType<typeof create>,
+ content: string,
+): boolean {
+ return renderer.root.findAll((n) => n.props?.children === content).length > 0;
+}
+
describe("DismissReportSheet", () => {
beforeEach(() => {
mocks.updateState.mockReset();
@@ -130,6 +167,109 @@ describe("DismissReportSheet", () => {
expect(noteInput(renderer).props.value).toBe("left over");
});
+ it("groups reasons by outcome and shows the outcome line below the note", () => {
+ const { renderer } = renderSheet(true);
+
+ const pauseGroup = findGroupByLabel(
+ renderer,
+ "Pause until a new matching signal",
+ );
+ const hideGroup = findGroupByLabel(renderer, "Don't surface again");
+
+ const optionValuesIn = (group: ReactTestInstance): string[] => {
+ const seen = new Set<string>();
+ const labels: string[] = [];
+ for (const n of group.findAll(
+ (node) =>
+ node.props?.accessibilityRole === "radio" &&
+ typeof node.props?.accessibilityLabel === "string" &&
+ typeof node.props?.onPress === "function",
+ )) {
+ const label = String(n.props.accessibilityLabel).replace(
+ "Dismissal reason: ",
+ "",
+ );
+ if (seen.has(label)) continue;
+ seen.add(label);
+ labels.push(label);
+ }
+ return labels;
+ };
+
+ const expectedPause = DISMISSAL_REASON_OPTIONS.filter((o) =>
+ isDismissalReasonSnooze(o.value),
+ ).map((o) => o.label);
+ const expectedHide = DISMISSAL_REASON_OPTIONS.filter(
+ (o) => !isDismissalReasonSnooze(o.value),
+ ).map((o) => o.label);
+
+ expect(optionValuesIn(pauseGroup)).toEqual(expectedPause);
+ expect(optionValuesIn(hideGroup)).toEqual(expectedHide);
+
+ pressByLabel(renderer, `Dismissal reason: ${expectedPause[0]}`);
+ expect(
+ findRadioByLabel(renderer, `Dismissal reason: ${expectedPause[0]}`).props
+ .accessibilityState.checked,
+ ).toBe(true);
+ expect(
+ hasTextNode(
+ renderer,
+ "The report comes back if another matching signal arrives.",
+ ),
+ ).toBe(true);
+
+ pressByLabel(renderer, `Dismissal reason: ${expectedHide[0]}`);
+ expect(
+ hasTextNode(renderer, "Matching signals won't surface the report again."),
+ ).toBe(true);
+ });
+
+ it("appends the pull request outcome when the report has an open PR", () => {
+ const { renderer } = renderSheet(true, { hasOpenPr: true });
+ const hideValue = DISMISSAL_REASON_OPTIONS.find(
+ (o) => !isDismissalReasonSnooze(o.value),
+ );
+ if (!hideValue) throw new Error("no hide option");
+
+ pressByLabel(renderer, `Dismissal reason: ${hideValue.label}`);
+
+ expect(
+ hasTextNode(
+ renderer,
+ "Matching signals won't surface the report again. The open pull request will be closed.",
+ ),
+ ).toBe(true);
+ });
+
+ it("selects the other reason when a note is typed with no reason picked", () => {
+ const { renderer } = renderSheet(true);
+
+ act(() => {
+ noteInput(renderer).props.onChangeText("Some detail");
+ });
+
+ const otherOption = findRadioByLabel(
+ renderer,
+ "Dismissal reason: Something else…",
+ );
+ expect(otherOption.props.accessibilityState.checked).toBe(true);
+ });
+
+ it("keeps the picked reason when the user then adds a note", () => {
+ const { renderer } = renderSheet(true);
+
+ pressByLabel(renderer, `Dismissal reason: ${FIRST_REASON.label}`);
+ act(() => {
+ noteInput(renderer).props.onChangeText("extra context");
+ });
+
+ const firstOption = findRadioByLabel(
+ renderer,
+ `Dismissal reason: ${FIRST_REASON.label}`,
+ );
+ expect(firstOption.props.accessibilityState.checked).toBe(true);
+ });
+
it("reopens with the typed reason and note when the write fails", async () => {
mocks.updateState.mockRejectedValue(new Error("network down"));
const { renderer } = renderSheet(true);
diff --git a/products/desktop/apps/mobile/src/features/inbox/components/DismissReportSheet.tsx b/products/desktop/apps/mobile/src/features/inbox/components/DismissReportSheet.tsx
index 365c6d63e695..e6f180de14f5 100644
--- a/products/desktop/apps/mobile/src/features/inbox/components/DismissReportSheet.tsx
+++ b/products/desktop/apps/mobile/src/features/inbox/components/DismissReportSheet.tsx
@@ -2,6 +2,7 @@ import { Text } from "@components/text";
import {
DISMISSAL_REASON_OPTIONS,
type DismissalReasonOptionValue,
+ isDismissalReasonSnooze,
} from "@posthog/shared";
import * as Haptics from "expo-haptics";
import { Check } from "phosphor-react-native";
@@ -27,10 +28,18 @@ export interface DismissReportResult {
note: string | null;
}
+const PAUSE_OPTIONS = DISMISSAL_REASON_OPTIONS.filter((option) =>
+ isDismissalReasonSnooze(option.value),
+);
+const HIDE_OPTIONS = DISMISSAL_REASON_OPTIONS.filter(
+ (option) => !isDismissalReasonSnooze(option.value),
+);
+
interface DismissReportSheetProps {
visible: boolean;
reportId: string;
reportTitle: string;
+ hasOpenPr?: boolean;
onClose: () => void;
/** Fires the moment the user confirms, before the API write settles. */
onDismissed: (result: DismissReportResult) => void;
@@ -40,6 +49,7 @@ export function DismissReportSheet({
visible,
reportId,
reportTitle,
+ hasOpenPr = false,
onClose,
onDismissed,
}: DismissReportSheetProps) {
@@ -72,6 +82,13 @@ export function DismissReportSheet({
const displayedError = draft?.reopen ? draft.errorMessage : undefined;
+ const outcome =
+ reason == null
+ ? null
+ : isDismissalReasonSnooze(reason)
+ ? "The report comes back if another matching signal arrives."
+ : `Matching signals won't surface the report again.${hasOpenPr ? " The open pull request will be closed." : ""}`;
+
const handleClose = () => {
setDraft(reportId, undefined);
onClose();
@@ -150,42 +167,34 @@ export function DismissReportSheet({
{`This will remove "${reportTitle}" from your inbox. Your feedback is saved on the report and helps the agent.`}
</Text>
- <Text className="mt-5 mb-2 font-semibold text-[12px] text-gray-10 uppercase tracking-wide">
- Reason
- </Text>
- <View className="overflow-hidden rounded-xl bg-gray-2">
- {DISMISSAL_REASON_OPTIONS.map((option, idx) => {
- const selected = reason === option.value;
- return (
- <Pressable
- key={option.value}
- onPress={() => setReason(option.value)}
- accessibilityLabel={`Dismissal reason: ${option.label}`}
- accessibilityRole="radio"
- accessibilityState={{ checked: selected }}
- hitSlop={4}
- className={`flex-row items-center justify-between px-3 py-3.5 active:bg-gray-3 ${
- idx > 0 ? "border-gray-5 border-t" : ""
- }`}
- >
- <Text className="flex-1 pr-3 text-[14px] text-gray-12">
- {option.label}
- </Text>
- {selected && (
- <Check size={16} color={themeColors.accent[9]} />
- )}
- </Pressable>
- );
- })}
- </View>
+ <ReasonGroup
+ heading="Pause until a new matching signal"
+ options={PAUSE_OPTIONS}
+ selected={reason}
+ onSelect={setReason}
+ accentColor={themeColors.accent[9]}
+ />
+
+ <ReasonGroup
+ heading="Don't surface again"
+ options={HIDE_OPTIONS}
+ selected={reason}
+ onSelect={setReason}
+ accentColor={themeColors.accent[9]}
+ />
<Text className="mt-5 mb-2 font-semibold text-[12px] text-gray-10 uppercase tracking-wide">
- Note (optional)
+ Details (optional)
</Text>
<TextInput
value={note}
- onChangeText={setNote}
- placeholder="Add detail so the agent can learn"
+ onChangeText={(value) => {
+ setNote(value);
+ if (reason === null && value.trim()) {
+ setReason("other");
+ }
+ }}
+ placeholder="What should the agent know?"
placeholderTextColor={themeColors.gray[9]}
multiline
numberOfLines={3}
@@ -194,6 +203,15 @@ export function DismissReportSheet({
style={{ textAlignVertical: "top" }}
/>
+ {outcome && (
+ <Text
+ accessibilityLiveRegion="polite"
+ className="mt-3 text-[13px] text-gray-11"
+ >
+ {outcome}
+ </Text>
+ )}
+
{displayedError && (
<Text className="mt-3 text-[13px] text-status-error">
{displayedError}
@@ -227,3 +245,48 @@ export function DismissReportSheet({
</Modal>
);
}
+
+function ReasonGroup({
+ heading,
+ options,
+ selected,
+ onSelect,
+ accentColor,
+}: {
+ heading: string;
+ options: readonly (typeof DISMISSAL_REASON_OPTIONS)[number][];
+ selected: DismissalReasonOptionValue | null;
+ onSelect: (value: DismissalReasonOptionValue) => void;
+ accentColor: string;
+}) {
+ return (
+ <View accessibilityRole="radiogroup" accessibilityLabel={heading}>
+ <Text className="mt-5 mb-2 font-semibold text-[12px] text-gray-10 uppercase tracking-wide">
+ {heading}
+ </Text>
+ <View className="overflow-hidden rounded-xl bg-gray-2">
+ {options.map((option, idx) => {
+ const isSelected = selected === option.value;
+ return (
+ <Pressable
+ key={option.value}
+ onPress={() => onSelect(option.value)}
+ accessibilityLabel={`Dismissal reason: ${option.label}`}
+ accessibilityRole="radio"
+ accessibilityState={{ checked: isSelected }}
+ hitSlop={4}
+ className={`flex-row items-center justify-between px-3 py-3.5 active:bg-gray-3 ${
+ idx > 0 ? "border-gray-5 border-t" : ""
+ }`}
+ >
+ <Text className="flex-1 pr-3 text-[14px] text-gray-12">
+ {option.label}
+ </Text>
+ {isSelected && <Check size={16} color={accentColor} />}
+ </Pressable>
+ );
+ })}
+ </View>
+ </View>
+ );
+}
diff --git a/products/desktop/packages/shared/src/index.ts b/products/desktop/packages/shared/src/index.ts
index f6c5f0b3e4f7..4d65252cd841 100644
--- a/products/desktop/packages/shared/src/index.ts
+++ b/products/desktop/packages/shared/src/index.ts
@@ -129,6 +129,7 @@ export {
DISMISSAL_REASON_OPTIONS,
type DismissalReasonOptionValue,
dismissalReasonLabel,
+ isDismissalReasonSnooze,
RESOLVE_REASON_OPTIONS,
type ReportStateReason,
type ResolveReasonOptionValue,