: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(desktop): mobile lead report pages with a verdict banner (#88365)
Tom Owersfef289758d8e
diff --git a/products/desktop/apps/mobile/src/app/inbox/[...id].tsx b/products/desktop/apps/mobile/src/app/inbox/[...id].tsxindex ec4e1dfa48c9..d085b21fe0d9 100644--- a/products/desktop/apps/mobile/src/app/inbox/[...id].tsx+++ b/products/desktop/apps/mobile/src/app/inbox/[...id].tsx@@ -23,11 +23,8 @@ import {CaretRight,ChatCircle,Lightning,- Play,- Plus,Receipt,ThumbsDown,- Warning,} from "phosphor-react-native";import { useFeatureFlag, usePostHog } from "posthog-react-native";import { useCallback, useEffect, useMemo, useState } from "react";@@ -54,6 +51,7 @@ import {import { RefundReportSheet } from "@/features/inbox/components/RefundReportSheet";import { ReportActivity } from "@/features/inbox/components/ReportActivity";import { ReportFeedbackFooter } from "@/features/inbox/components/ReportFeedbackFooter";+import { ReportVerdictBanner } from "@/features/inbox/components/ReportVerdictBanner";import { SignalCard } from "@/features/inbox/components/SignalCard";import {type ReviewerActionExtra,@@ -65,6 +63,7 @@ import {useInboxReportArtefacts,useInboxReportSignals,} from "@/features/inbox/hooks/useInboxReports";+import { isReportAwaitingInput } from "@/features/inbox/reportVerdictAction";import { useInboxStore } from "@/features/inbox/stores/inboxStore";import { PrStatusBadge } from "@/features/tasks/components/PrStatusBadge";import {@@ -72,6 +71,7 @@ import {type InboxReportActionType,useAnalytics,} from "@/lib/analytics";+import { openExternalUrl } from "@/lib/openExternalUrl";import { useThemeColors } from "@/lib/theme";const statusColorMap: Record<string, { bg: string; text: string }> = {@@ -328,6 +328,28 @@ export default function ReportDetailScreen() {[report, router, reportRepo, tracker],);+ const handleBannerStart = useCallback(() => {+ Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);+ setCreatePrFeedbackOpen(true);+ }, []);++ const handleOpenPr = useCallback(+ (url: string) => {+ if (!report) return;+ tracker.signalAction({+ report_id: report.id,+ report_title: report.title ?? null,+ report_age_hours: computeReportAgeHours(report.created_at),+ action_type: "open_pr",+ surface: "detail_pane",+ is_bulk: false,+ bulk_size: 1,+ });+ openExternalUrl(url);+ },+ [report, tracker],+ );+const handleDismissed = useCallback((result: DismissReportResult) => {setDismissOpen(false);@@ -428,25 +450,17 @@ export default function ReportDetailScreen() {const isReady = report.status === "ready";- const isAwaitingInput =- report.status === "pending_input" ||- (report.status === "ready" &&- report.actionability === "requires_human_input");-- const canStartTask =- isAwaitingInput ||- (report.status === "ready" &&- report.actionability === "immediately_actionable" &&- report.already_addressed !== true);+ const isAwaitingInput = isReportAwaitingInput(report);const alreadyAddressed =report.already_addressed ??actionabilityJudgment?.already_addressed ??false;- const primaryActionLabel = isAwaitingInput- ? "Implement as new task"- : "Start task";+ // Fold the artefact-derived already_addressed onto the report the verdict+ // reads, so the "already fixed" verdict shows even when only the judgment+ // artefact carries it.+ const bannerReport = { ...report, already_addressed: alreadyAddressed };const { canRefund: canRefundPr, disabledReason: refundDisabledReason } =computeRefundEligibility(report, refundFlagEnabled);@@ -504,35 +518,12 @@ export default function ReportDetailScreen() {) : null}</View>- {/* Failed warning */}- {report.status === "failed" && (- <View className="mb-4 flex-row items-start gap-2 rounded-lg bg-status-error/10 p-3">- <Warning size={16} color={themeColors.status.error} weight="fill" />- <View className="flex-1">- <Text className="font-medium text-[13px] text-status-error">- Report processing failed- </Text>- <Text className="mt-0.5 text-[12px] text-status-error">- There was an issue processing this report. It may be retried- automatically.- </Text>- </View>- </View>- )}-- {/* Already-addressed banner */}- {alreadyAddressed && (- <View className="mb-4 flex-row items-start gap-2 rounded-lg border border-status-warning/40 bg-status-warning/10 p-3">- <Warning- size={16}- color={themeColors.status.warning}- weight="fill"- />- <Text className="flex-1 text-[13px] text-status-warning">- This issue may already be addressed in recent code changes.- </Text>- </View>- )}+ {/* Verdict banner: the report's state and its one ask, up front */}+ <ReportVerdictBanner+ report={bannerReport}+ onStart={handleBannerStart}+ onOpenPr={handleOpenPr}+ />{/* Summary */}{report.summary && (@@ -648,35 +639,6 @@ export default function ReportDetailScreen() {</Text></Pressable>)}-- {canStartTask && (- <View className="flex-row items-center overflow-hidden rounded-full bg-accent-9 shadow-lg">- <Pressable- onPress={() => handleStartTask()}- className="flex-row items-center gap-2 py-3.5 pr-3 pl-4 active:opacity-80"- >- {isAwaitingInput ? (- <Plus size={18} color="#ffffff" weight="bold" />- ) : (- <Play size={18} color="#ffffff" weight="fill" />- )}- <Text className="font-semibold text-[15px] text-white">- {primaryActionLabel}- </Text>- </Pressable>- <View className="h-6 w-px bg-white/25" />- <Pressable- onPress={() => {- Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);- setCreatePrFeedbackOpen(true);- }}- accessibilityLabel="Add feedback"- className="py-3.5 pr-4 pl-3 active:opacity-80"- >- <CaretDown size={16} color="#ffffff" weight="bold" />- </Pressable>- </View>- )}</View><DismissReportSheetdiff --git a/products/desktop/apps/mobile/src/features/inbox/components/ReportVerdictBanner.tsx b/products/desktop/apps/mobile/src/features/inbox/components/ReportVerdictBanner.tsxnew file mode 100644index 000000000000..07f5c9e85fb0--- /dev/null+++ b/products/desktop/apps/mobile/src/features/inbox/components/ReportVerdictBanner.tsx@@ -0,0 +1,89 @@+import { Text } from "@components/text";+import {+ deriveReportVerdict,+ type ReportVerdictTone,+} from "@posthog/core/inbox/reportVerdict";+import type { SignalReport } from "@posthog/shared/domain-types";+import { ArrowSquareOut, Play, Plus } from "phosphor-react-native";+import { ActivityIndicator, Pressable, View } from "react-native";+import { resolveReportVerdictAction } from "@/features/inbox/reportVerdictAction";+import { useThemeColors } from "@/lib/theme";++const TONE_CONTAINER: Record<ReportVerdictTone, string> = {+ decision: "border-status-warning/40 bg-status-warning/10",+ danger: "border-status-error/40 bg-status-error/10",+ progress: "border-gray-6 bg-gray-2",+ info: "border-gray-6 bg-gray-2",+};++interface ReportVerdictBannerProps {+ report: SignalReport;+ onStart: () => void;+ onOpenPr: (url: string) => void;+}++/**+ * Leads the report detail with its verdict: what state the report is in, what it+ * asks of the reader, and the one action that answers the ask.+ */+export function ReportVerdictBanner({+ report,+ onStart,+ onOpenPr,+}: ReportVerdictBannerProps) {+ const themeColors = useThemeColors();+ const action = resolveReportVerdictAction(report);+ const verdict = deriveReportVerdict(report, {+ hasExistingPr: action?.kind === "view_pr",+ });++ return (+ <View+ className={`mb-4 gap-2 rounded-xl border p-4 ${TONE_CONTAINER[verdict.tone]}`}+ >+ <View className="flex-row items-center gap-2">+ {verdict.tone === "progress" && (+ <ActivityIndicator size="small" color={themeColors.gray[11]} />+ )}+ <Text className="flex-1 font-semibold text-[15px] text-gray-12">+ {verdict.title}+ </Text>+ </View>+ <Text className="text-[13px] text-gray-11 leading-snug">+ {verdict.body}+ </Text>++ {action?.kind === "start" && (+ <Pressable+ onPress={onStart}+ accessibilityRole="button"+ accessibilityLabel={action.label}+ className="mt-1 flex-row items-center gap-2 self-start rounded-full bg-accent-9 px-4 py-2.5 active:opacity-80"+ >+ {action.awaitingInput ? (+ <Plus size={16} color="#ffffff" weight="bold" />+ ) : (+ <Play size={16} color="#ffffff" weight="fill" />+ )}+ <Text className="font-semibold text-[14px] text-white">+ {action.label}+ </Text>+ </Pressable>+ )}++ {action?.kind === "view_pr" && (+ <Pressable+ onPress={() => onOpenPr(action.url)}+ accessibilityRole="button"+ accessibilityLabel="View PR"+ className="mt-1 flex-row items-center gap-2 self-start rounded-full border border-gray-6 bg-background px-4 py-2.5 active:opacity-80"+ >+ <ArrowSquareOut size={16} color={themeColors.gray[12]} />+ <Text className="font-semibold text-[14px] text-gray-12">+ View PR+ </Text>+ </Pressable>+ )}+ </View>+ );+}diff --git a/products/desktop/apps/mobile/src/features/inbox/reportVerdictAction.test.ts b/products/desktop/apps/mobile/src/features/inbox/reportVerdictAction.test.tsnew file mode 100644index 000000000000..d130fa14bbc8--- /dev/null+++ b/products/desktop/apps/mobile/src/features/inbox/reportVerdictAction.test.ts@@ -0,0 +1,129 @@+import type {+ SignalReport,+ SignalReportActionability,+ SignalReportStatus,+} from "@posthog/shared/domain-types";+import { describe, expect, it } from "vitest";+import {+ type ReportVerdictAction,+ resolveReportVerdictAction,+} from "./reportVerdictAction";++function report(overrides: Partial<SignalReport>): SignalReport {+ return {+ id: "r1",+ title: "A report",+ summary: "",+ status: "ready",+ total_weight: 1,+ signal_count: 1,+ created_at: "2024-01-01T00:00:00Z",+ updated_at: "2024-01-01T00:00:00Z",+ artefact_count: 0,+ ...overrides,+ };+}++describe("resolveReportVerdictAction", () => {+ const cases: Array<{+ name: string;+ overrides: Partial<SignalReport>;+ expected: ReportVerdictAction;+ }> = [+ {+ name: "ready + immediately actionable → start",+ overrides: { status: "ready", actionability: "immediately_actionable" },+ expected: { kind: "start", label: "Start task", awaitingInput: false },+ },+ {+ name: "ready + requires human input → implement as new task",+ overrides: { status: "ready", actionability: "requires_human_input" },+ expected: {+ kind: "start",+ label: "Implement as new task",+ awaitingInput: true,+ },+ },+ {+ name: "pending_input → implement as new task",+ overrides: { status: "pending_input" },+ expected: {+ kind: "start",+ label: "Implement as new task",+ awaitingInput: true,+ },+ },+ {+ name: "live PR takes precedence over start",+ overrides: {+ status: "ready",+ actionability: "immediately_actionable",+ implementation_pr_url: "https://github.com/o/r/pull/1",+ },+ expected: { kind: "view_pr", url: "https://github.com/o/r/pull/1" },+ },+ {+ name: "merged PR is not live: offer a fresh start",+ overrides: {+ status: "ready",+ actionability: "immediately_actionable",+ implementation_pr_url: "https://github.com/o/r/pull/1",+ implementation_pr_merged: true,+ },+ expected: { kind: "start", label: "Start task", awaitingInput: false },+ },+ {+ name: "non-GitHub PR url is not trusted: no action, not presented as a PR",+ overrides: {+ status: "ready",+ actionability: "immediately_actionable",+ implementation_pr_url: "https://attacker.example/pull/1",+ },+ expected: null,+ },+ {+ name: "already addressed → no action",+ overrides: {+ status: "ready",+ actionability: "immediately_actionable",+ already_addressed: true,+ },+ expected: null,+ },+ {+ name: "not actionable → no action",+ overrides: { status: "ready", actionability: "not_actionable" },+ expected: null,+ },+ {+ name: "in progress → no action",+ overrides: { status: "in_progress" },+ expected: null,+ },+ {+ name: "failed → no action",+ overrides: { status: "failed" },+ expected: null,+ },+ ];++ it.each(cases)("$name", ({ overrides, expected }) => {+ expect(resolveReportVerdictAction(report(overrides))).toEqual(expected);+ });++ it.each<SignalReportStatus>(["resolved", "suppressed", "deleted"])(+ "terminal status %s offers no action even with a live PR",+ (status) => {+ expect(+ resolveReportVerdictAction(+ report({+ status,+ actionability:+ "immediately_actionable" as SignalReportActionability,+ implementation_pr_url: "https://github.com/o/r/pull/1",+ }),+ ),+ ).toBeNull();+ },+ );+});diff --git a/products/desktop/apps/mobile/src/features/inbox/reportVerdictAction.ts b/products/desktop/apps/mobile/src/features/inbox/reportVerdictAction.tsnew file mode 100644index 000000000000..2c4679c7f53f--- /dev/null+++ b/products/desktop/apps/mobile/src/features/inbox/reportVerdictAction.ts@@ -0,0 +1,58 @@+import { canCreateImplementationPr } from "@posthog/core/inbox/reportActions";+import { parsePrUrl } from "@posthog/core/inbox/reportPresentation";+import type { SignalReport } from "@posthog/shared/domain-types";++export type ReportVerdictAction =+ | { kind: "start"; label: string; awaitingInput: boolean }+ | { kind: "view_pr"; url: string }+ | null;++/** True when the report is blocked on user input the reader can supply. */+export function isReportAwaitingInput(report: SignalReport): boolean {+ return (+ report.status === "pending_input" ||+ (report.status === "ready" &&+ report.actionability === "requires_human_input")+ );+}++/**+ * The implementation PR to link to, or null. A merged PR is history, not live+ * work. `implementation_pr_url` flows in from task-run output, so it is only+ * trusted as a canonical GitHub PR URL — anything else is not presented as+ * "View PR".+ */+function liveImplementationPrUrl(report: SignalReport): string | null {+ if (report.implementation_pr_merged) return null;+ const url = report.implementation_pr_url;+ if (!url || !parsePrUrl(url)) return null;+ return url;+}++/**+ * The one action the verdict banner offers: open the live PR, start the fix, or+ * nothing. Mobile has no continuable-task lookup, so an existing PR is read from+ * `implementation_pr_url` alone.+ */+export function resolveReportVerdictAction(+ report: SignalReport,+): ReportVerdictAction {+ if (+ report.status === "resolved" ||+ report.status === "suppressed" ||+ report.status === "deleted"+ ) {+ return null;+ }+ const prUrl = liveImplementationPrUrl(report);+ if (prUrl) return { kind: "view_pr", url: prUrl };+ if (canCreateImplementationPr(report)) {+ const awaitingInput = isReportAwaitingInput(report);+ return {+ kind: "start",+ label: awaitingInput ? "Implement as new task" : "Start task",+ awaitingInput,+ };+ }+ return null;+}