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): correct mobile report task launches (#102032)

Dylan Martinc996b93effa0
diff --git a/products/desktop/apps/mobile/src/app/(tabs)/inbox.tsx b/products/desktop/apps/mobile/src/app/(tabs)/inbox.tsx
index 0de3634d706a..f8af16a2a018 100644
--- a/products/desktop/apps/mobile/src/app/(tabs)/inbox.tsx
+++ b/products/desktop/apps/mobile/src/app/(tabs)/inbox.tsx
@@ -26,7 +26,6 @@ import {
} from "@/features/inbox/stores/dismissedReportsStore";
import { useInboxFilterStore } from "@/features/inbox/stores/inboxFilterStore";
import { useInboxStore } from "@/features/inbox/stores/inboxStore";
-import { useIntegrations } from "@/features/tasks/hooks/useIntegrations";
import { ANALYTICS_EVENTS, useAnalytics } from "@/lib/analytics";
export default function InboxScreen() {
@@ -99,7 +98,6 @@ export default function InboxScreen() {
const setLastVisibleReportIds = useInboxStore(
(s) => s.setLastVisibleReportIds,
);
- const { repositoryOptions } = useIntegrations();
// Snapshot the visible-list IDs into the store so the detail screen can
// record rank/list_size on OPENED. Only the list view exposes a rank — the
@@ -202,11 +200,7 @@ export default function InboxScreen() {
/>
) : (
<View style={{ paddingTop: headerHeight }} className="flex-1">
- <TinderView
- reports={tinderReports}
- repositoryOptions={repositoryOptions}
- isLoading={isLoading}
- />
+ <TinderView reports={tinderReports} isLoading={isLoading} />
</View>
)}
diff --git a/products/desktop/apps/mobile/src/app/inbox/[...id].tsx b/products/desktop/apps/mobile/src/app/inbox/[...id].tsx
index 74bfb8e22789..462765cba986 100644
--- a/products/desktop/apps/mobile/src/app/inbox/[...id].tsx
+++ b/products/desktop/apps/mobile/src/app/inbox/[...id].tsx
@@ -1,5 +1,6 @@
import { Text } from "@components/text";
import { computeRefundEligibility } from "@posthog/core/inbox/refundEligibility";
+import { buildCreatePrReportPrompt } from "@posthog/core/inbox/reportActions";
import {
formatSignalReportSummaryMarkdown,
humanizeReportTitle,
@@ -42,8 +43,6 @@ import {
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useUserQuery } from "@/features/auth";
import { MarkdownText } from "@/features/chat/components/MarkdownText";
-import { getReportRepository } from "@/features/inbox/api";
-import { buildCreatePrReportPrompt } from "@/features/inbox/buildCreatePrReportPrompt";
import { ConventionalCommitTag } from "@/features/inbox/components/ConventionalCommitTag";
import { CreatePrFeedbackSheet } from "@/features/inbox/components/CreatePrFeedbackSheet";
import { DiscussReportSheet } from "@/features/inbox/components/DiscussReportSheet";
@@ -163,7 +162,6 @@ export default function ReportDetailScreen() {
const refundFlagEnabled = !!useFeatureFlag(SIGNALS_PR_REFUNDS_FLAG);
const { data: report, isLoading, error } = useInboxReport(reportId ?? null);
const { data: me } = useUserQuery();
- const [reportRepo, setReportRepo] = useState<string | null>(null);
const [dismissOpen, setDismissOpen] = useState(false);
const [discussOpen, setDiscussOpen] = useState(false);
const [createPrFeedbackOpen, setCreatePrFeedbackOpen] = useState(false);
@@ -243,19 +241,6 @@ export default function ReportDetailScreen() {
setSignalsExpanded(next);
}, [report, tracker, signalsExpanded]);
- useEffect(() => {
- if (!reportId) return;
- let cancelled = false;
- getReportRepository(reportId)
- .then((repo) => {
- if (!cancelled) setReportRepo(repo);
- })
- .catch(() => {});
- return () => {
- cancelled = true;
- };
- }, [reportId]);
-
// ── Derive artefact bits ────────────────────────────────────────────────
const artefacts = artefactsQuery.data?.results ?? [];
@@ -316,19 +301,19 @@ export default function ReportDetailScreen() {
...(feedback ? { feedback_text: feedback.slice(0, 500) } : {}),
});
const prompt = buildCreatePrReportPrompt({
- summary: report.summary,
+ reportId: report.id,
feedback,
});
router.push({
pathname: "/task",
params: {
prompt,
- ...(reportRepo ? { repo: reportRepo } : {}),
signalReport: report.id,
+ signalReportRelationship: "implementation",
},
});
},
- [report, router, reportRepo, tracker],
+ [report, router, tracker],
);
const handleBannerStart = useCallback(() => {
@@ -412,12 +397,13 @@ export default function ReportDetailScreen() {
pathname: "/task",
params: {
prompt,
- ...(reportRepo ? { repo: reportRepo } : {}),
signalReport: report.id,
+ signalReportRelationship: "discussion",
+ signalReportDiscussionQuestion: question,
},
});
},
- [report, router, reportRepo, posthog],
+ [report, router, posthog],
);
if (error) {
diff --git a/products/desktop/apps/mobile/src/app/review.tsx b/products/desktop/apps/mobile/src/app/review.tsx
index 03f0b20d6312..4ec6004a33dc 100644
--- a/products/desktop/apps/mobile/src/app/review.tsx
+++ b/products/desktop/apps/mobile/src/app/review.tsx
@@ -10,7 +10,6 @@ import {
useDismissedReportsStore,
} from "@/features/inbox/stores/dismissedReportsStore";
import { useInboxStore } from "@/features/inbox/stores/inboxStore";
-import { useIntegrations } from "@/features/tasks/hooks/useIntegrations";
import { useThemeColors } from "@/lib/theme";
export default function ReviewScreen() {
@@ -18,7 +17,6 @@ export default function ReviewScreen() {
const themeColors = useThemeColors();
const decided = useDismissedReportsStore(decidedIds);
const setCurrentIndex = useInboxStore((s) => s.setCurrentIndex);
- const { repositoryOptions } = useIntegrations();
const { reports, isLoading } = useInboxReports();
@@ -46,10 +44,7 @@ export default function ReviewScreen() {
<View className="flex-1 bg-background">
<FloatingBackButton />
<View style={{ paddingTop: insets.top + 56 }} className="flex-1">
- <TinderView
- reports={tinderReports}
- repositoryOptions={repositoryOptions}
- />
+ <TinderView reports={tinderReports} />
</View>
</View>
);
diff --git a/products/desktop/apps/mobile/src/app/task/index.tsx b/products/desktop/apps/mobile/src/app/task/index.tsx
index 73a2bf5ff66c..bc4daa564ae0 100644
--- a/products/desktop/apps/mobile/src/app/task/index.tsx
+++ b/products/desktop/apps/mobile/src/app/task/index.tsx
@@ -26,9 +26,10 @@ import {
PaperclipIcon,
StopIcon,
} from "phosphor-react-native";
-import { useCallback, useEffect, useState } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import {
ActivityIndicator,
+ Alert,
Pressable,
ScrollView,
TextInput,
@@ -70,10 +71,7 @@ import {
pendingTaskPromptStoreApi,
} from "@/features/tasks/stores/pendingTaskPromptStore";
import { useTaskStore } from "@/features/tasks/stores/taskStore";
-import type {
- CreateTaskOptions,
- RepositorySelection,
-} from "@/features/tasks/types";
+import type { RepositorySelection } from "@/features/tasks/types";
import { buildCloudTaskRunConfig } from "@/features/tasks/utils/cloudTaskRunConfig";
import {
findRepositoryOption,
@@ -97,10 +95,14 @@ export default function NewTaskScreen() {
prompt: initialPrompt,
repo: initialRepo,
signalReport,
+ signalReportRelationship,
+ signalReportDiscussionQuestion,
} = useLocalSearchParams<{
prompt?: string;
repo?: string;
signalReport?: string;
+ signalReportRelationship?: string;
+ signalReportDiscussionQuestion?: string;
}>();
const router = useRouter();
const themeColors = useThemeColors();
@@ -121,7 +123,7 @@ export default function NewTaskScreen() {
isRefreshingInBackground,
refetch,
getUserIntegrationId,
- } = useUserIntegrations();
+ } = useUserIntegrations({ enabled: !signalReport });
const containerStyle = useAnimatedStyle(() => {
const kbHeight = -keyboard.height.value;
@@ -172,6 +174,8 @@ export default function NewTaskScreen() {
[setLastRepository],
);
const [mode, setMode] = useState<ExecutionMode>(() => {
+ if (signalReport && signalReportRelationship === "discussion")
+ return "auto";
const prefs = usePreferencesStore.getState();
if (prefs.defaultInitialTaskMode === "last_used") {
const last = prefs.lastNewTaskMode;
@@ -211,6 +215,12 @@ export default function NewTaskScreen() {
if (next.reasoning !== reasoning) setReasoning(next.reasoning);
}, [adapter, hasLiveConfig, model, modelConfigOption, reasoning]);
const [creating, setCreating] = useState(false);
+ const creatingRef = useRef(false);
+ const reportTaskRef = useRef<{
+ reportId: string;
+ relationship: string;
+ id: string;
+ } | null>(null);
const [repoSheetOpen, setRepoSheetOpen] = useState(false);
const [attachments, setAttachments] = useState<PendingAttachment[]>([]);
const [attachmentSheetOpen, setAttachmentSheetOpen] = useState(false);
@@ -271,13 +281,21 @@ export default function NewTaskScreen() {
: "Select repository…";
const repositoryLoadBlocked =
!!repositoryWarning && repositoryOptions.length === 0;
+ const repositoryReady =
+ !!signalReport || isRepositorySelectionComplete(selection);
const handleCreateTask = useCallback(async () => {
const hasContent = !!prompt.trim() || attachments.length > 0;
- if (!hasContent || !isRepositorySelectionComplete(selection) || creating) {
+ if (
+ !hasContent ||
+ !repositoryReady ||
+ !isConfigReady ||
+ creatingRef.current
+ ) {
return;
}
+ creatingRef.current = true;
setCreating(true);
// Echo the prompt into the chat thread the moment the user taps send.
@@ -319,23 +337,40 @@ export default function NewTaskScreen() {
: `Attached ${attachments.length} files`);
const client = getPostHogApiClient();
- const task = await client.createTask({
+ const taskOptions = {
description: descriptionText,
title: descriptionText.slice(0, 100),
- repository: selection.repository ?? undefined,
- // User-scoped integration (matches desktop). `selection.integrationId`
- // is the GitHub installation id; map it back to the UserIntegration
- // UUID the API expects. The backend also auto-resolves this from the
- // repository for user-created tasks, so it's a best-effort hint.
- github_user_integration: getUserIntegrationId(selection.integrationId),
- ...(signalReport
- ? {
- origin_product: "signal_report",
- signal_report: signalReport,
- signal_report_task_relationship: "implementation",
- }
- : {}),
- } as CreateTaskOptions);
+ };
+ const relationship =
+ signalReportRelationship === "discussion"
+ ? "discussion"
+ : "implementation";
+ const existingReportTask = reportTaskRef.current;
+ const task = signalReport
+ ? existingReportTask?.reportId === signalReport &&
+ existingReportTask.relationship === relationship
+ ? existingReportTask
+ : await client.createSignalReportTask({
+ ...taskOptions,
+ reportId: signalReport,
+ relationship,
+ question: signalReportDiscussionQuestion,
+ })
+ : await client.createTask({
+ ...taskOptions,
+ repository: selection.repository ?? undefined,
+ github_user_integration: getUserIntegrationId(
+ selection.integrationId,
+ ),
+ });
+
+ if (signalReport) {
+ reportTaskRef.current = {
+ reportId: signalReport,
+ relationship,
+ id: task.id,
+ };
+ }
pendingTaskPromptStoreApi.move(pendingKey, task.id);
currentPendingKey = task.id;
@@ -385,13 +420,19 @@ export default function NewTaskScreen() {
} catch (creationError) {
log.error("Failed to create task", creationError);
pendingTaskPromptStoreApi.clear(currentPendingKey);
+ Alert.alert(
+ "Could not start task",
+ creationError instanceof Error
+ ? creationError.message
+ : "Check your connection and open the task list to check whether the task was created.",
+ );
} finally {
+ creatingRef.current = false;
setCreating(false);
}
}, [
attachments,
adapter,
- creating,
mode,
model,
prompt,
@@ -401,16 +442,16 @@ export default function NewTaskScreen() {
router,
selection,
signalReport,
+ signalReportRelationship,
+ signalReportDiscussionQuestion,
+ repositoryReady,
+ isConfigReady,
getUserIntegrationId,
setComposerConfig,
]);
const hasContent = !!prompt.trim() || attachments.length > 0;
- const canSubmit =
- isConfigReady &&
- hasContent &&
- isRepositorySelectionComplete(selection) &&
- !creating;
+ const canSubmit = isConfigReady && hasContent && repositoryReady && !creating;
const reasoningOptions = getReasoningEffortOptions(adapter, model) ?? [];
const showReasoningPill = reasoningOptions.length > 0;
@@ -418,8 +459,8 @@ export default function NewTaskScreen() {
// the GitHub installation id, not a PostHog integration id — the backend
// resolves the integration from the repository, so this only keys the warm.
useWarmTask({
- repository: selection.repository,
- githubIntegrationId: selection.integrationId,
+ repository: signalReport ? null : selection.repository,
+ githubIntegrationId: signalReport ? null : selection.integrationId,
composerIsEmpty: !hasContent || !isConfigReady,
runtimeAdapter: adapter,
model,
@@ -492,19 +533,21 @@ export default function NewTaskScreen() {
<Animated.View style={[{ flex: 1 }, containerStyle]}>
<View className="flex-1 justify-center px-4">
<View style={{ width: "100%", maxWidth: 600, alignSelf: "center" }}>
- <View className="mb-2">
- <RepositoryPickerInline
- open={repoSheetOpen}
- repositoryOptions={repositoryOptions}
- selected={selectedRepositoryOption}
- loading={isLoading && repositoryOptions.length === 0}
- isRefreshing={isRefreshingInBackground}
- onChange={(option) =>
- setSelection(toRepositorySelection(option))
- }
- onClose={() => setRepoSheetOpen(false)}
- />
- </View>
+ {!signalReport && (
+ <View className="mb-2">
+ <RepositoryPickerInline
+ open={repoSheetOpen}
+ repositoryOptions={repositoryOptions}
+ selected={selectedRepositoryOption}
+ loading={isLoading && repositoryOptions.length === 0}
+ isRefreshing={isRefreshingInBackground}
+ onChange={(option) =>
+ setSelection(toRepositorySelection(option))
+ }
+ onClose={() => setRepoSheetOpen(false)}
+ />
+ </View>
+ )}
{repositoryWarning ? (
<GitHubLoadNotice
@@ -514,43 +557,47 @@ export default function NewTaskScreen() {
/>
) : null}
- <View className="mb-2 flex-row items-center">
- <Pressable
- onPress={() => setRepoSheetOpen((prev) => !prev)}
- className={`flex-row items-center gap-2 rounded-md border py-1.5 pr-2.5 pl-2 active:bg-gray-2 ${
- repoSheetOpen
- ? "border-accent-7 bg-accent-3"
- : "border-gray-6 bg-card"
- }`}
- >
- <GithubLogo
- size={16}
- color={
- selectedRepositoryOption
- ? themeColors.gray[12]
- : themeColors.gray[10]
- }
- weight={selectedRepositoryOption ? "fill" : "regular"}
- />
- <Text
- className={`text-[13px] ${
- selectedRepositoryOption ? "text-gray-12" : "text-gray-10"
+ {!signalReport && (
+ <View className="mb-2 flex-row items-center">
+ <Pressable
+ onPress={() => setRepoSheetOpen((prev) => !prev)}
+ className={`flex-row items-center gap-2 rounded-md border py-1.5 pr-2.5 pl-2 active:bg-gray-2 ${
+ repoSheetOpen
+ ? "border-accent-7 bg-accent-3"
+ : "border-gray-6 bg-card"
}`}
- numberOfLines={1}
>
- {repositoryLabel}
- </Text>
- <CaretDown
- size={12}
- color={themeColors.gray[10]}
- style={{
- transform: [
- { rotate: repoSheetOpen ? "180deg" : "0deg" },
- ],
- }}
- />
- </Pressable>
- </View>
+ <GithubLogo
+ size={16}
+ color={
+ selectedRepositoryOption
+ ? themeColors.gray[12]
+ : themeColors.gray[10]
+ }
+ weight={selectedRepositoryOption ? "fill" : "regular"}
+ />
+ <Text
+ className={`text-[13px] ${
+ selectedRepositoryOption
+ ? "text-gray-12"
+ : "text-gray-10"
+ }`}
+ numberOfLines={1}
+ >
+ {repositoryLabel}
+ </Text>
+ <CaretDown
+ size={12}
+ color={themeColors.gray[10]}
+ style={{
+ transform: [
+ { rotate: repoSheetOpen ? "180deg" : "0deg" },
+ ],
+ }}
+ />
+ </Pressable>
+ </View>
+ )}
<View className="overflow-hidden rounded-lg border border-gray-6 bg-card">
<AttachmentsBar
diff --git a/products/desktop/apps/mobile/src/features/inbox/buildCreatePrReportPrompt.test.ts b/products/desktop/apps/mobile/src/features/inbox/buildCreatePrReportPrompt.test.ts
deleted file mode 100644
index 0ef32079a86a..000000000000
--- a/products/desktop/apps/mobile/src/features/inbox/buildCreatePrReportPrompt.test.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { describe, expect, it } from "vitest";
-import { buildCreatePrReportPrompt } from "./buildCreatePrReportPrompt";
-
-const BASE =
- "Act on this signal report. Investigate the root cause, implement the fix, and open a PR if appropriate.";
-const FEEDBACK_PREFIX =
- "Additional feedback from the user (take this into account, including any questions raised in the report thread):";
-
-describe("buildCreatePrReportPrompt", () => {
- it.each([
- {
- name: "returns the base prompt unchanged when no feedback is given",
- input: { summary: "A summary" },
- expected: `${BASE}\n\nA summary`,
- },
- {
- name: "appends a feedback section when feedback is provided",
- input: { summary: "A summary", feedback: "Use the staging database" },
- expected: `${BASE}\n\nA summary\n\n${FEEDBACK_PREFIX}\nUse the staging database`,
- },
- {
- name: "trims feedback before appending it",
- input: { summary: "A summary", feedback: " Use the staging database " },
- expected: `${BASE}\n\nA summary\n\n${FEEDBACK_PREFIX}\nUse the staging database`,
- },
- {
- name: "treats whitespace-only feedback as no feedback",
- input: { summary: "A summary", feedback: " " },
- expected: `${BASE}\n\nA summary`,
- },
- {
- name: "tolerates a missing summary",
- input: {},
- expected: `${BASE}\n\n`,
- },
- ])("$name", ({ input, expected }) => {
- expect(buildCreatePrReportPrompt(input)).toBe(expected);
- });
-});
diff --git a/products/desktop/apps/mobile/src/features/inbox/buildCreatePrReportPrompt.ts b/products/desktop/apps/mobile/src/features/inbox/buildCreatePrReportPrompt.ts
deleted file mode 100644
index 4334ff582546..000000000000
--- a/products/desktop/apps/mobile/src/features/inbox/buildCreatePrReportPrompt.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-interface BuildCreatePrReportPromptOptions {
- summary?: string | null;
- feedback?: string;
-}
-
-export function buildCreatePrReportPrompt({
- summary,
- feedback,
-}: BuildCreatePrReportPromptOptions): string {
- const base = `Act on this signal report. Investigate the root cause, implement the fix, and open a PR if appropriate.\n\n${summary ?? ""}`;
- const trimmed = feedback?.trim();
- if (!trimmed) return base;
- return `${base}\n\nAdditional feedback from the user (take this into account, including any questions raised in the report thread):\n${trimmed}`;
-}
diff --git a/products/desktop/apps/mobile/src/features/inbox/components/SwipeableReportCard.tsx b/products/desktop/apps/mobile/src/features/inbox/components/SwipeableReportCard.tsx
index bfcd5bc655e6..3c281d390e6e 100644
--- a/products/desktop/apps/mobile/src/features/inbox/components/SwipeableReportCard.tsx
+++ b/products/desktop/apps/mobile/src/features/inbox/components/SwipeableReportCard.tsx
@@ -47,7 +47,7 @@ const priorityColorMap: Record<
interface SwipeableReportCardProps {
report: SignalReport;
onDismiss: (reportId: string) => void;
- onAccept: (report: SignalReport) => void;
+ onAccept: (report: SignalReport) => Promise<boolean>;
onExpand: (report: SignalReport) => void;
isTopCard: boolean;
/** Vertical offset in px — cards further back sit lower. */
@@ -124,8 +124,9 @@ export function SwipeableReportCard({
toValue: 500,
duration: 200,
useNativeDriver: true,
- }).start(() => {
- p.onAccept(p.report);
+ }).start(async () => {
+ const accepted = await p.onAccept(p.report);
+ if (!accepted) translateX.setValue(0);
});
} else if (gesture.dx < -SWIPE_THRESHOLD) {
// Swipe left → dismiss
diff --git a/products/desktop/apps/mobile/src/features/inbox/components/TinderView.tsx b/products/desktop/apps/mobile/src/features/inbox/components/TinderView.tsx
index bb6f403cebf1..bba8843b91f0 100644
--- a/products/desktop/apps/mobile/src/features/inbox/components/TinderView.tsx
+++ b/products/desktop/apps/mobile/src/features/inbox/components/TinderView.tsx
@@ -1,4 +1,5 @@
import { Text } from "@components/text";
+import { buildCreatePrReportPrompt } from "@posthog/core/inbox/reportActions";
import {
formatSignalReportSummaryMarkdown,
humanizeReportTitle,
@@ -30,10 +31,6 @@ import { MarkdownText } from "@/features/chat/components/MarkdownText";
import { usePreferencesStore } from "@/features/preferences/stores/preferencesStore";
import { getModelConfigOption } from "@/features/tasks/composer/options";
import { useCloudTaskConfigOptions } from "@/features/tasks/hooks/useCloudTaskConfigOptions";
-import type {
- CreateTaskOptions,
- RepositoryOption,
-} from "@/features/tasks/types";
import {
ANALYTICS_EVENTS,
computeReportAgeHours,
@@ -132,15 +129,10 @@ function EmptyState() {
interface TinderViewProps {
reports: SignalReport[];
- repositoryOptions: RepositoryOption[];
isLoading?: boolean;
}
-export function TinderView({
- reports,
- repositoryOptions,
- isLoading,
-}: TinderViewProps) {
+export function TinderView({ reports, isLoading }: TinderViewProps) {
const themeColors = useThemeColors();
const router = useRouter();
const insets = useSafeAreaInsets();
@@ -184,6 +176,8 @@ export function TinderView({
null,
);
const [creating, setCreating] = useState(false);
+ const creatingRef = useRef(false);
+ const reportTaskIdsRef = useRef(new Map<string, string>());
const [error, setError] = useState<string | null>(null);
const [toast, setToast] = useState<{
taskId: string | null;
@@ -223,6 +217,8 @@ export function TinderView({
const handleAccept = useCallback(
async (report: SignalReport) => {
+ if (creatingRef.current || !isConfigReady) return false;
+ creatingRef.current = true;
setCreating(true);
setError(null);
showToastPending(report.title ?? "Untitled report");
@@ -234,31 +230,21 @@ export function TinderView({
try {
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
- // 1. Get the repo from the report artefacts
- const repo = await getReportRepository(report.id);
-
- // 2. Find matching repository option to get integrationId
- const match = repo
- ? repositoryOptions.find(
- (o) => o.repository.toLowerCase() === repo.toLowerCase(),
- )
- : null;
-
- // 3. Create the task
- const prompt = `Act on this signal report. Investigate the root cause, implement the fix, and open a PR if appropriate.\n\n${report.summary ?? ""}`;
+ const prompt = buildCreatePrReportPrompt({ reportId: report.id });
const client = getPostHogApiClient();
- const task = await client.createTask({
- description: prompt,
- title: prompt.slice(0, 255),
- repository: match?.repository ?? repo ?? undefined,
- github_integration: match?.integrationId ?? undefined,
- origin_product: "signal_report",
- signal_report: report.id,
- signal_report_task_relationship: "implementation",
- } as CreateTaskOptions);
-
- // 4. Run it
- await client.runTaskInCloud(task.id, undefined, {
+ let taskId = reportTaskIdsRef.current.get(report.id);
+ if (!taskId) {
+ const task = await client.createSignalReportTask({
+ description: prompt,
+ title: prompt.slice(0, 255),
+ reportId: report.id,
+ relationship: "implementation",
+ });
+ taskId = task.id;
+ reportTaskIdsRef.current.set(report.id, taskId);
+ }
+
+ await client.runTaskInCloud(taskId, undefined, {
pendingUserMessage: prompt,
adapter: "claude",
model,
@@ -270,20 +256,23 @@ export function TinderView({
acceptReport(report.id);
trackReportAction(report, "create_pr", acceptedRank, acceptedListSize);
- showToastDone(task.id, report.title ?? "Untitled report");
+ showToastDone(taskId, report.title ?? "Untitled report");
+ return true;
} catch (e) {
const message =
e instanceof Error ? e.message : "Failed to create task";
log.error("Accept failed", message);
setError(message);
setToast(null);
+ return false;
} finally {
+ creatingRef.current = false;
setCreating(false);
}
},
[
- repositoryOptions,
model,
+ isConfigReady,
showToastPending,
showToastDone,
acceptReport,
diff --git a/products/desktop/apps/mobile/src/features/inbox/reportTaskLaunch.test.tsx b/products/desktop/apps/mobile/src/features/inbox/reportTaskLaunch.test.tsx
new file mode 100644
index 000000000000..da3b7f335be5
--- /dev/null
+++ b/products/desktop/apps/mobile/src/features/inbox/reportTaskLaunch.test.tsx
@@ -0,0 +1,477 @@
+import { DEFAULT_GATEWAY_MODEL } from "@posthog/shared";
+import type { SignalReport } from "@posthog/shared/domain-types";
+import { createElement } from "react";
+import { Alert, Animated, Pressable } from "react-native";
+import { act, create, type ReactTestRenderer } from "react-test-renderer";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import ReportDetailScreen from "@/app/inbox/[...id]";
+import NewTaskScreen from "@/app/task/index";
+import { useTaskStore } from "@/features/tasks/stores/taskStore";
+import { CreatePrFeedbackSheet } from "./components/CreatePrFeedbackSheet";
+import { DiscussReportSheet } from "./components/DiscussReportSheet";
+import { SwipeableReportCard } from "./components/SwipeableReportCard";
+import { TinderView } from "./components/TinderView";
+import { useDismissedReportsStore } from "./stores/dismissedReportsStore";
+
+const mocks = vi.hoisted(() => ({
+ params: {} as Record<string, string>,
+ createReportTask: vi.fn(),
+ createTask: vi.fn(),
+ runTask: vi.fn(),
+ replace: vi.fn(),
+ push: vi.fn(),
+ integrations: vi.fn(),
+ configReady: true,
+}));
+
+vi.mock("react-native", () => {
+ const host = (name: string) => (props: Record<string, unknown>) =>
+ createElement(name, props);
+ return {
+ View: host("View"),
+ ScrollView: host("ScrollView"),
+ Pressable: host("Pressable"),
+ TextInput: host("TextInput"),
+ ActivityIndicator: host("ActivityIndicator"),
+ Modal: host("Modal"),
+ Platform: { OS: "ios" },
+ Alert: { alert: vi.fn() },
+ Animated: {
+ View: "AnimatedView",
+ Value: class {
+ value = 0;
+ setValue(value: number) {
+ this.value = value;
+ }
+ interpolate() {
+ return 0;
+ }
+ },
+ timing: (
+ value: { setValue: (value: number) => void },
+ config: { toValue: number },
+ ) => ({
+ start: (callback: () => Promise<void>) => {
+ value.setValue(config.toValue);
+ return callback();
+ },
+ }),
+ },
+ PanResponder: {
+ create: (handlers: Record<string, unknown>) => ({
+ panHandlers: handlers,
+ }),
+ },
+ };
+});
+vi.mock("@components/text", () => ({ Text: "Text" }));
+vi.mock("expo-router", () => ({
+ Stack: { Screen: () => null },
+ useLocalSearchParams: () => mocks.params,
+ useRouter: () => ({ replace: mocks.replace, push: mocks.push }),
+}));
+vi.mock("expo-linear-gradient", () => ({ LinearGradient: "Gradient" }));
+vi.mock("expo-haptics", () => ({
+ impactAsync: vi.fn(),
+ ImpactFeedbackStyle: { Light: "light", Medium: "medium" },
+}));
+vi.mock("react-native-keyboard-controller", () => ({
+ useKeyboardHandler: vi.fn(),
+ useReanimatedKeyboardAnimation: () => ({
+ height: { value: 0 },
+ progress: { value: 0 },
+ }),
+}));
+vi.mock("@/features/chat", () => ({
+ useVoiceRecording: () => ({ status: "idle" }),
+}));
+vi.mock("@/features/chat/components/MarkdownText", () => ({
+ MarkdownText: "Markdown",
+}));
+vi.mock("@/hooks/useScreenInsets", () => ({
+ useScreenInsets: () => ({ insets: { top: 0 }, bottom: () => 0 }),
+}));
+vi.mock("@/lib/theme", () => ({
+ useThemeColors: () => ({
+ gray: {},
+ accent: {},
+ status: {},
+ background: "#fff",
+ card: "#fff",
+ }),
+ toRgba: () => "#fff",
+}));
+vi.mock("@/lib/posthogApiClient", () => ({
+ getPostHogApiClient: () => ({
+ createSignalReportTask: mocks.createReportTask,
+ createTask: mocks.createTask,
+ runTaskInCloud: mocks.runTask,
+ }),
+}));
+vi.mock("@/lib/analytics", () => ({
+ useAnalytics: () => ({ track: vi.fn() }),
+ ANALYTICS_EVENTS: { INBOX_REPORT_ACTION: "report action" },
+ computeReportAgeHours: () => 1,
+}));
+vi.mock("./api", () => ({ getReportRepository: async () => null }));
+vi.mock("./components/ConventionalCommitTag", () => ({
+ ConventionalCommitTag: () => null,
+}));
+vi.mock("@/features/tasks/hooks/useWarmTask", () => ({ useWarmTask: vi.fn() }));
+vi.mock("@/features/tasks/hooks/useUserIntegrations", () => ({
+ useUserIntegrations: (options: { enabled: boolean }) => {
+ mocks.integrations(options);
+ return {
+ repositoryOptions: [],
+ hasGithubIntegration: options.enabled ? true : null,
+ isLoading: false,
+ getUserIntegrationId: vi.fn(),
+ };
+ },
+}));
+vi.mock("@/features/tasks/hooks/useCloudTaskConfigOptions", () => ({
+ useCloudTaskConfigOptions: () => ({
+ configOptions: [
+ { category: "model", currentValue: DEFAULT_GATEWAY_MODEL, options: [] },
+ ],
+ modelGroups: [],
+ hasLiveConfig: false,
+ isConfigReady: mocks.configReady,
+ }),
+}));
+vi.mock("@/features/tasks/composer/AgentConfigControls", () => ({
+ AgentConfigControls: () => null,
+}));
+vi.mock("@/features/tasks/composer/DotBackground", () => ({
+ DotBackground: () => null,
+}));
+vi.mock("@/features/tasks/composer/RepositoryPickerInline", () => ({
+ RepositoryPickerInline: "RepositoryPicker",
+}));
+vi.mock("@/features/tasks/components/GitHubConnectionPrompt", () => ({
+ GitHubConnectionPrompt: "ConnectGitHub",
+}));
+vi.mock("@/features/tasks/components/GitHubLoadNotice", () => ({
+ GitHubLoadNotice: "GitHubLoadNotice",
+}));
+vi.mock("@/features/tasks/composer/attachments/AttachmentSheet", () => ({
+ AttachmentSheet: () => null,
+}));
+vi.mock("@/features/tasks/composer/attachments/AttachmentsBar", () => ({
+ AttachmentsBar: () => null,
+}));
+vi.mock("@/features/tasks/composer/attachments/pickers", () => ({
+ captureFromCamera: vi.fn(),
+ pickDocument: vi.fn(),
+ pickPhotoFromLibrary: vi.fn(),
+}));
+vi.mock("@/features/tasks/composer/attachments/buildCloudPrompt", () => ({
+ buildCloudPromptBlocks: vi.fn(),
+}));
+
+const report: SignalReport = {
+ id: "report-1",
+ title: "Fix sample failure",
+ summary: "Check the evidence.",
+ status: "ready",
+ priority: "P2",
+ total_weight: 1,
+ signal_count: 1,
+ artefact_count: 0,
+ created_at: "2026-09-01T00:00:00Z",
+ updated_at: "2026-09-01T00:00:00Z",
+};
+
+let renderer: ReactTestRenderer;
+async function renderComposer(): Promise<void> {
+ await act(async () => {
+ renderer = create(createElement(NewTaskScreen));
+ });
+}
+function submitButton() {
+ return renderer.root.find(
+ (node) =>
+ node.type === Pressable &&
+ node.props.accessibilityLabel === "Create task",
+ );
+}
+async function renderTriage(): Promise<void> {
+ await act(async () => {
+ renderer = create(createElement(TinderView, { reports: [report] }));
+ });
+}
+function acceptCard(): Promise<boolean> {
+ return renderer.root.findByType(SwipeableReportCard).props.onAccept(report);
+}
+
+async function swipeRight(): Promise<void> {
+ const card = renderer.root
+ .findAllByType(Animated.View)
+ .find((node) => node.props.onPanResponderRelease);
+ if (!card) throw new Error("Swipe card not found");
+ const gesture = { dx: 150, dy: 0 };
+ card.props.onPanResponderGrant();
+ card.props.onPanResponderMove({}, gesture);
+ await card.props.onPanResponderRelease({}, gesture);
+}
+
+function cardOffset(): number {
+ return renderer.root
+ .findAllByType(Animated.View)
+ .find((node) => node.props.onPanResponderRelease)?.props.style.transform[0]
+ .translateX.value;
+}
+
+describe("Mobile report task launches", () => {
+ it.each(["implementation", "discussion"])(
+ "keeps the report detail %s intent when opening the composer",
+ async (relationship) => {
+ mocks.params = { id: report.id };
+ await act(async () => {
+ renderer = create(createElement(ReportDetailScreen));
+ });
+ await act(async () => {
+ if (relationship === "discussion") {
+ renderer.root.findByType(DiscussReportSheet).props.onSubmit({
+ prompt: "Discuss the evidence",
+ question: "Why did this happen?",
+ });
+ } else {
+ renderer.root
+ .findByType(CreatePrFeedbackSheet)
+ .props.onSubmit("Add regression coverage");
+ }
+ });
+ const route = mocks.push.mock.calls[0][0];
+ expect(route.pathname).toBe("/task");
+ expect(route.params).toEqual({
+ signalReport: report.id,
+ signalReportRelationship: relationship,
+ prompt:
+ relationship === "discussion"
+ ? "Discuss the evidence"
+ : expect.stringContaining(report.id),
+ ...(relationship === "discussion"
+ ? { signalReportDiscussionQuestion: "Why did this happen?" }
+ : {}),
+ });
+ if (relationship === "implementation") {
+ expect(route.params.prompt).toContain("Add regression coverage");
+ }
+ },
+ );
+ beforeEach(() => {
+ vi.clearAllMocks();
+ mocks.params = {
+ prompt: "Read the report evidence",
+ signalReport: report.id,
+ };
+ mocks.configReady = true;
+ mocks.createReportTask.mockResolvedValue({ id: "task-1" });
+ mocks.runTask.mockResolvedValue({ id: "run-1" });
+ useTaskStore.setState({
+ lastRepository: { integrationId: null, repository: null },
+ });
+ useDismissedReportsStore.getState().clearDismissed();
+ });
+ afterEach(() => {
+ if (renderer) act(() => renderer.unmount());
+ });
+
+ it.each(["implementation", "discussion"])(
+ "starts a report %s without a personal repository",
+ async (relationship) => {
+ mocks.params.signalReportRelationship = relationship;
+ mocks.params.signalReportDiscussionQuestion = "What caused this?";
+ await renderComposer();
+ expect(mocks.integrations).toHaveBeenCalledWith({ enabled: false });
+ expect(
+ renderer.root.findAll(
+ (node) => String(node.type) === "RepositoryPicker",
+ ),
+ ).toHaveLength(0);
+ expect(submitButton().props.disabled).toBe(false);
+ await act(async () => {
+ await submitButton().props.onPress();
+ });
+ expect(mocks.createReportTask).toHaveBeenCalledWith({
+ reportId: report.id,
+ relationship,
+ question: "What caused this?",
+ description: "Read the report evidence",
+ title: "Read the report evidence",
+ });
+ expect(mocks.createTask).not.toHaveBeenCalled();
+ expect(mocks.runTask).toHaveBeenCalledWith(
+ "task-1",
+ undefined,
+ expect.objectContaining({
+ runSource: "signal_report",
+ signalReportId: report.id,
+ ...(relationship === "discussion"
+ ? { initialPermissionMode: "auto" }
+ : {}),
+ }),
+ );
+ expect(mocks.replace).toHaveBeenCalledWith("/task/task-1");
+ },
+ );
+
+ it("still requires a repository for an ordinary task", async () => {
+ mocks.params = { prompt: "Fix a sample failure" };
+ await renderComposer();
+ expect(submitButton().props.disabled).toBe(true);
+ await act(async () => {
+ await submitButton().props.onPress();
+ });
+ expect(mocks.createTask).not.toHaveBeenCalled();
+ expect(mocks.createReportTask).not.toHaveBeenCalled();
+ });
+
+ it("does not submit twice before the composer rerenders", async () => {
+ await renderComposer();
+ const press = submitButton().props.onPress;
+ await act(async () => {
+ await Promise.all([press(), press()]);
+ });
+ expect(mocks.createReportTask).toHaveBeenCalledOnce();
+ expect(mocks.runTask).toHaveBeenCalledOnce();
+ });
+
+ it.each(["implementation", "discussion"])(
+ "retries the existing %s task after a startup error",
+ async (relationship) => {
+ mocks.params.signalReportRelationship = relationship;
+ mocks.runTask.mockRejectedValueOnce(new Error("Cloud start failed"));
+ await renderComposer();
+ await act(async () => {
+ await submitButton().props.onPress();
+ });
+ expect(Alert.alert).toHaveBeenCalledWith(
+ "Could not start task",
+ "Cloud start failed",
+ );
+ expect(mocks.replace).not.toHaveBeenCalled();
+ await act(async () => {
+ await submitButton().props.onPress();
+ });
+ expect(mocks.createReportTask).toHaveBeenCalledOnce();
+ expect(mocks.runTask).toHaveBeenCalledTimes(2);
+ expect(mocks.runTask.mock.calls.map(([taskId]) => taskId)).toEqual([
+ "task-1",
+ "task-1",
+ ]);
+ expect(mocks.replace).toHaveBeenCalledWith("/task/task-1");
+ },
+ );
+
+ it("starts one triage implementation and accepts it only after startup", async () => {
+ let finish!: () => void;
+ mocks.runTask.mockReturnValueOnce(
+ new Promise<void>((resolve) => {
+ finish = resolve;
+ }),
+ );
+ await renderTriage();
+ let pending!: Promise<boolean>;
+ await act(async () => {
+ pending = acceptCard();
+ });
+ expect(useDismissedReportsStore.getState().acceptedIds).toEqual([]);
+ await act(async () => {
+ await acceptCard();
+ finish();
+ await pending;
+ });
+ expect(mocks.createReportTask).toHaveBeenCalledOnce();
+ expect(mocks.createReportTask).toHaveBeenCalledWith({
+ reportId: report.id,
+ relationship: "implementation",
+ description: expect.stringContaining(report.id),
+ title: expect.any(String),
+ });
+ expect(mocks.runTask).toHaveBeenCalledOnce();
+ expect(useDismissedReportsStore.getState().acceptedIds).toEqual([
+ report.id,
+ ]);
+ });
+
+ it("resets a failed swipe and retries the existing triage task", async () => {
+ mocks.runTask.mockRejectedValueOnce(new Error("Cloud start failed"));
+ await renderTriage();
+ await act(async () => {
+ await swipeRight();
+ });
+ expect(useDismissedReportsStore.getState().acceptedIds).toEqual([]);
+ expect(JSON.stringify(renderer.toJSON())).toContain("Cloud start failed");
+ expect(cardOffset()).toBe(0);
+ await act(async () => {
+ await swipeRight();
+ });
+ expect(mocks.createReportTask).toHaveBeenCalledOnce();
+ expect(mocks.runTask).toHaveBeenCalledTimes(2);
+ expect(mocks.runTask.mock.calls.map(([taskId]) => taskId)).toEqual([
+ "task-1",
+ "task-1",
+ ]);
+ expect(useDismissedReportsStore.getState().acceptedIds).toEqual([
+ report.id,
+ ]);
+ });
+
+ it("does not launch a swipe before cloud configuration is ready", async () => {
+ mocks.configReady = false;
+ await renderTriage();
+ await act(async () => {
+ await swipeRight();
+ });
+ expect(mocks.createReportTask).not.toHaveBeenCalled();
+ expect(cardOffset()).toBe(0);
+ });
+});
+
+vi.mock("posthog-react-native", () => ({
+ useFeatureFlag: () => false,
+ usePostHog: () => ({ capture: vi.fn() }),
+}));
+vi.mock("@/features/auth", () => ({
+ useUserQuery: () => ({ data: { id: 1 } }),
+}));
+vi.mock("./hooks/useInboxReports", () => ({
+ useInboxReport: () => ({ data: report }),
+ useInboxReportArtefacts: () => ({ data: { results: [] } }),
+ useInboxReportSignals: () => ({ data: { results: [] } }),
+}));
+vi.mock("./hooks/useInboxEngagementTracker", () => ({
+ useInboxEngagementTracker: () => ({
+ signalAction: vi.fn(),
+ signalScroll: vi.fn(),
+ }),
+}));
+vi.mock("./components/CreatePrFeedbackSheet", () => ({
+ CreatePrFeedbackSheet: () => null,
+}));
+vi.mock("./components/DiscussReportSheet", () => ({
+ DiscussReportSheet: () => null,
+}));
+vi.mock("./components/DismissReportSheet", () => ({
+ DismissReportSheet: () => null,
+}));
+vi.mock("./components/RefundReportSheet", () => ({
+ RefundReportSheet: () => null,
+}));
+vi.mock("./components/ReportActivity", () => ({ ReportActivity: () => null }));
+vi.mock("./components/ReportFeedbackFooter", () => ({
+ ReportFeedbackFooter: () => null,
+}));
+vi.mock("./components/ReportVerdictBanner", () => ({
+ ReportVerdictBanner: () => null,
+}));
+vi.mock("./components/SignalCard", () => ({ SignalCard: () => null }));
+vi.mock("./components/SuggestedReviewers", () => ({
+ SuggestedReviewers: () => null,
+}));
+vi.mock("@/features/tasks/components/PrStatusBadge", () => ({
+ PrStatusBadge: () => null,
+}));
+vi.mock("@/lib/openExternalUrl", () => ({ openExternalUrl: vi.fn() }));
diff --git a/products/desktop/docs/SELF-DRIVING-REPORTS.md b/products/desktop/docs/SELF-DRIVING-REPORTS.md
index eae42eff3659..476b95f21051 100644
--- a/products/desktop/docs/SELF-DRIVING-REPORTS.md
+++ b/products/desktop/docs/SELF-DRIVING-REPORTS.md
@@ -43,6 +43,18 @@ Hover opens the user list without moving keyboard focus. Click the search field
The search starts empty and shows up to 20 options, including For you and Entire project.
Search by name or email across all users. The search field stays visible above the results.
+## Mobile report tasks
+
+Discuss starts a discussion task and forwards the question to the report's scout.
+Create PR starts an implementation task. Both actions use the report's repository and team GitHub integration, resolved by the server.
+The mobile report composer does not require a personal GitHub connection or offer a repository picker.
+If cloud startup fails after task creation, retrying in the same composer or triage view starts the existing task instead of creating another task.
+Triage resets the swiped card if configuration is not ready or task startup fails.
+An ordinary new task still requires a repository from the user's GitHub integration.
+
+The report detail and triage views use the same implementation prompt. The agent fetches the report and checks for an existing PR before starting new work.
+Triage advances only after the cloud run starts. A failed submission keeps the report available and shows the error.
+
## Storybook previews
The `Inbox/Reports` stories cover the sidebar, report list, report detail, and triage mode.
diff --git a/products/desktop/packages/api-client/src/posthog-client.test.ts b/products/desktop/packages/api-client/src/posthog-client.test.ts
index ed1df5bb6344..5c2112c47484 100644
--- a/products/desktop/packages/api-client/src/posthog-client.test.ts
+++ b/products/desktop/packages/api-client/src/posthog-client.test.ts
@@ -11,6 +11,47 @@ import {
} from "./posthog-client";
describe("PostHogAPIClient", () => {
+ it.each(["implementation", "discussion"] as const)(
+ "creates a report %s without client repository credentials",
+ async (relationship) => {
+ const fetch = vi
+ .fn()
+ .mockResolvedValue(
+ new Response(JSON.stringify({ id: "task-1" }), { status: 201 }),
+ );
+ const client = new PostHogAPIClient(
+ "https://app.posthog.test",
+ async () => "token",
+ async () => "token",
+ 42,
+ { fetch },
+ );
+
+ await client.createSignalReportTask({
+ reportId: "report-1",
+ relationship,
+ description: "Read the report evidence",
+ title: "Review report",
+ question: " What caused this? ",
+ });
+
+ expect(fetch).toHaveBeenCalledOnce();
+ const [url, request] = fetch.mock.calls[0];
+ expect((url as URL).pathname).toBe("/api/projects/42/tasks/");
+ expect(request.method).toBe("POST");
+ expect(JSON.parse(request.body)).toEqual({
+ description: "Read the report evidence",
+ title: "Review report",
+ origin_product: "signal_report",
+ signal_report: "report-1",
+ signal_report_task_relationship: relationship,
+ ...(relationship === "discussion"
+ ? { signal_report_discussion_question: "What caused this?" }
+ : {}),
+ });
+ },
+ );
+
describe("Desktop beta terms", () => {
it.each([
[
diff --git a/products/desktop/packages/api-client/src/posthog-client.ts b/products/desktop/packages/api-client/src/posthog-client.ts
index ef99eec16ecd..ae6134534fa3 100644
--- a/products/desktop/packages/api-client/src/posthog-client.ts
+++ b/products/desktop/packages/api-client/src/posthog-client.ts
@@ -3235,6 +3235,25 @@ export class PostHogAPIClient {
return normalizeTaskResponse(data, { teamId });
}
+ async createSignalReportTask(options: {
+ reportId: string;
+ relationship: "implementation" | "discussion";
+ description: string;
+ title?: string;
+ question?: string;
+ }): Promise<Task> {
+ return this.createTask({
+ description: options.description,
+ title: options.title,
+ origin_product: "signal_report",
+ signal_report: options.reportId,
+ signal_report_task_relationship: options.relationship,
+ ...(options.relationship === "discussion"
+ ? { signal_report_discussion_question: options.question?.trim() ?? "" }
+ : {}),
+ });
+ }
+
async updateTask(
taskId: string,
updates: Schemas.PatchedTaskWrite,