: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): clarify existing report task errors (#88895)
Dylan Martinbc16bdd9ae55
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/inboxCloudTaskErrors.test.ts b/products/desktop/packages/ui/src/features/inbox/hooks/inboxCloudTaskErrors.test.tsnew file mode 100644index 000000000000..fc8989debb87--- /dev/null+++ b/products/desktop/packages/ui/src/features/inbox/hooks/inboxCloudTaskErrors.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from "vitest";+import { isSignalReportTaskCapError } from "./inboxCloudTaskErrors";++describe("isSignalReportTaskCapError", () => {+ it("recognizes the task cap in the serialized API error", () => {+ expect(+ isSignalReportTaskCapError(+ 'Failed request: [429] {"type":"rate_limit","code":"signal_report_task_cap","error":"A PR task already exists"}',+ ),+ ).toBe(true);+ });++ it("does not treat other rate limits as the report task cap", () => {+ expect(+ isSignalReportTaskCapError(+ 'Failed request: [429] {"type":"rate_limit","code":"throttled"}',+ ),+ ).toBe(false);+ });+});diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/inboxCloudTaskErrors.ts b/products/desktop/packages/ui/src/features/inbox/hooks/inboxCloudTaskErrors.tsnew file mode 100644index 000000000000..6ff4f5fee59b--- /dev/null+++ b/products/desktop/packages/ui/src/features/inbox/hooks/inboxCloudTaskErrors.ts@@ -0,0 +1,10 @@+export function isSignalReportTaskCapError(error: unknown): boolean {+ const message =+ typeof error === "string"+ ? error+ : error instanceof Error+ ? error.message+ : JSON.stringify(error);++ return message?.includes('"code":"signal_report_task_cap"') ?? false;+}diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useCreatePrReport.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useCreatePrReport.tsindex 96b815995760..3bf05b98b1ff 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useCreatePrReport.ts+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useCreatePrReport.ts@@ -126,6 +126,8 @@ export function useCreatePrReport({signedOut: "Sign in to create a PR",missingModel:"Couldn't resolve a default model. Open the task page once and pick a model, then try again.",+ existingImplementationTask:+ "This report already has an implementation task. Open it from the activity section to continue.",},buildInput,analyticsExtras,diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxCloudTaskRunner.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxCloudTaskRunner.tsindex cc225f919de2..6e09f3c291dc 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxCloudTaskRunner.ts+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxCloudTaskRunner.ts@@ -19,7 +19,9 @@ import {import type { Task } from "@posthog/shared/domain-types";import { useAuthStateValue } from "@posthog/ui/features/auth/store";import { showOfflineToast } from "@posthog/ui/features/connectivity/connectivityToast";+import { isSignalReportTaskCapError } from "@posthog/ui/features/inbox/hooks/inboxCloudTaskErrors";import { resolveDefaultModel } from "@posthog/ui/features/inbox/hooks/resolveDefaultModel";+import { reportKeys } from "@posthog/ui/features/inbox/hooks/useInboxReports";import { useUserRepositoryIntegration } from "@posthog/ui/features/integrations/useIntegrations";import { toastError } from "@posthog/ui/features/notifications/errorDetails";import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";@@ -46,6 +48,8 @@ export interface InboxCloudTaskCopy {signedOut: string;/** Error description when no model can be resolved. */missingModel: string;+ /** Error description when this report already has an implementation task. */+ existingImplementationTask?: string;/*** Title for the success toast shown when `redirectOnSuccess` is false and the* runner stays in place instead of navigating to the task. Defaults to@@ -270,7 +274,25 @@ export function useInboxCloudTaskRunner({toast.dismiss(toastId);// Usage-limit blocks already show the upgrade modal; don't double-toast.if (!isUsageLimitResult(result)) {- toastError(copy.errorTitle, result.error);+ if (+ reportId &&+ copy.existingImplementationTask &&+ isSignalReportTaskCapError(result.error)+ ) {+ await Promise.all([+ queryClient.invalidateQueries({+ queryKey: ["inbox", "report-tasks", reportId],+ }),+ queryClient.invalidateQueries({+ queryKey: reportKeys.artefacts(reportId),+ }),+ ]);+ toast.error(copy.errorTitle, {+ description: copy.existingImplementationTask,+ });+ } else {+ toastError(copy.errorTitle, result.error);+ }log.error("Cloud-task creation failed", {failedStep: result.failedStep,error: result.error,