Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Show a default error toast for failed mutations (EVE-276) (#682)
Carter Smith6ad142eb9256
diff --git a/src/client/components/Sidebar.tsx b/src/client/components/Sidebar.tsxindex 0f87002b..8bb403b2 100644--- a/src/client/components/Sidebar.tsx+++ b/src/client/components/Sidebar.tsx@@ -2,6 +2,7 @@ import { Link, useLocation, useNavigate } from "@tanstack/react-router";import type { LinkOptions } from "@tanstack/react-router";import { useQuery } from "@tanstack/react-query";import { useEffect, useState, type ComponentType } from "react";+import { toast } from "sonner";import {ArrowLeftRight,Check,@@ -24,6 +25,7 @@ import { ProjectSwitcher } from "@/client/features/projects/ProjectSwitcher";import { SamSidebarPanel } from "@/client/features/sam/SamSidebarPanel";import { ThemePreferenceMenuItems } from "@/client/components/ThemePreferenceMenuItems";import { closeDropdown } from "@/client/lib/dropdown";+import { getStandardErrorMessage } from "@/client/lib/error-messages";import { signOutAndRedirect, useSession } from "@/lib/auth-client";import { isHostedClientAuthMode } from "@/lib/auth-mode";import { BILLING_ROUTE } from "@/shared/billing";@@ -254,7 +256,8 @@ function SidebarFooter({ onNavigate }: { onNavigate?: () => void }) {// Full reload: every cached query and the project-scoped URL belong to// the previous organization.window.location.assign("/");- } catch {+ } catch (error) {+ toast.error(getStandardErrorMessage(error));setIsSwitching(false);}}diff --git a/src/client/features/audit/launch/useLaunchController.ts b/src/client/features/audit/launch/useLaunchController.tsindex 61522f77..2e609500 100644--- a/src/client/features/audit/launch/useLaunchController.ts+++ b/src/client/features/audit/launch/useLaunchController.ts@@ -117,6 +117,7 @@ function useLaunchMutations({ projectId }: { projectId: string }) {queryClient.invalidateQueries({ queryKey: ["audit-history", projectId] });const startMutation = useMutation({+ meta: { errorToast: false },mutationFn: (data: {projectId: string;startUrl: string;diff --git a/src/client/features/audit/results/ShopifyCrawlWarning.tsx b/src/client/features/audit/results/ShopifyCrawlWarning.tsxindex b9ef7b45..6cb3a60d 100644--- a/src/client/features/audit/results/ShopifyCrawlWarning.tsx+++ b/src/client/features/audit/results/ShopifyCrawlWarning.tsx@@ -1,7 +1,6 @@import { useIsMutating, useMutation, useQuery } from "@tanstack/react-query";import { Link, useNavigate } from "@tanstack/react-router";import { ShieldAlert, ShieldCheck } from "lucide-react";-import { toast } from "sonner";import {CrawlerAccessForm,crawlerCredentialsQueryKey,@@ -9,7 +8,6 @@ import {} from "@/client/features/crawler-access/CrawlerAccessForm";import type { AuditResultsData } from "@/client/features/audit/results/types";import { extractHostname } from "@/client/features/audit/shared";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { startAudit } from "@/serverFunctions/audit";import { listCrawlerCredentials } from "@/serverFunctions/crawlerAccess";import {@@ -81,8 +79,6 @@ export function ShopifyCrawlWarning({search: { auditId: result.auditId, tab: "issues" },});},- onError: (error) =>- toast.error(getStandardErrorMessage(error, "Failed to start audit")),});const rerunButton = (diff --git a/src/client/features/crawler-access/CrawlerAccessForm.tsx b/src/client/features/crawler-access/CrawlerAccessForm.tsxindex 77236d84..1b5ac6e8 100644--- a/src/client/features/crawler-access/CrawlerAccessForm.tsx+++ b/src/client/features/crawler-access/CrawlerAccessForm.tsx@@ -1,7 +1,6 @@import { useMutation, useQueryClient } from "@tanstack/react-query";import { useState } from "react";import { toast } from "sonner";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { saveCrawlerCredential } from "@/serverFunctions/crawlerAccess";import {isCrawlerAccessExpired,@@ -47,8 +46,6 @@ export function CrawlerAccessForm({toast.success(`Crawler access saved for ${saved.host}`);onSaved?.();},- onError: (error) =>- toast.error(getStandardErrorMessage(error, "We couldn't save that")),});const isExpired = isCrawlerAccessExpired(diff --git a/src/client/features/dashboard/DashboardOnboarding.tsx b/src/client/features/dashboard/DashboardOnboarding.tsxindex b8d5c038..ec64c3d7 100644--- a/src/client/features/dashboard/DashboardOnboarding.tsx+++ b/src/client/features/dashboard/DashboardOnboarding.tsx@@ -1,9 +1,7 @@import { useState } from "react";import { useMutation, useQueryClient } from "@tanstack/react-query";import { Check, ChevronRight, RotateCcw } from "lucide-react";-import { toast } from "sonner";import { isHostedClientAuthMode } from "@/lib/auth-mode";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { captureClientEvent } from "@/client/lib/posthog";import { getGoogleLinkError } from "@/client/features/integrations/googleLinkError";import { setDashboardStepDismissed } from "@/serverFunctions/dashboard";@@ -41,13 +39,6 @@ export function DashboardOnboarding({setSelected(dismissed ? null : step);captureClientEvent("dashboard:setup_step_defer", { step, dismissed });},- onError: (error) =>- toast.error(- getStandardErrorMessage(- error,- "Couldn’t save your preference. Try again.",- ),- ),});const steps = setupSteps.filter((step) => step.id !== "team" || isHostedClientAuthMode(),diff --git a/src/client/features/dashboard/DashboardSetupAction.tsx b/src/client/features/dashboard/DashboardSetupAction.tsxindex a0f46954..7dc9924a 100644--- a/src/client/features/dashboard/DashboardSetupAction.tsx+++ b/src/client/features/dashboard/DashboardSetupAction.tsx@@ -56,7 +56,6 @@ export function DashboardSetupAction({onComplete();void navigate({ to: "/p/$projectId/domain", params: { projectId } });},- onError: (error) => toast.error(getStandardErrorMessage(error)),});if (step === "domain")return project ? (@@ -238,13 +237,6 @@ function WebsiteForm({toast.success("Website saved");onComplete();},- onError: (error) =>- toast.error(- getStandardErrorMessage(- error,- "Couldn’t save your website. Try again.",- ),- ),});const form = useForm({defaultValues: {diff --git a/src/client/features/dashboard/WorkspaceMergeBanner.tsx b/src/client/features/dashboard/WorkspaceMergeBanner.tsxindex fe5f37ba..42fda3b1 100644--- a/src/client/features/dashboard/WorkspaceMergeBanner.tsx+++ b/src/client/features/dashboard/WorkspaceMergeBanner.tsx@@ -1,6 +1,5 @@import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { toast } from "sonner";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { isHostedClientAuthMode } from "@/lib/auth-mode";import {getWorkspaceMergeStatus,@@ -30,13 +29,6 @@ export function WorkspaceMergeBanner() {// refetch everything rather than enumerating keys.void queryClient.invalidateQueries();},- onError: (error) =>- toast.error(- getStandardErrorMessage(- error,- "Couldn't migrate the organizations. Try again.",- ),- ),});if (!statusQuery.data || statusQuery.data.legacyWorkspaceCount === 0) {diff --git a/src/client/features/domain/domainActions.ts b/src/client/features/domain/domainActions.tsindex a3e00bf7..f8bc39ba 100644--- a/src/client/features/domain/domainActions.ts+++ b/src/client/features/domain/domainActions.ts@@ -1,5 +1,4 @@import { toast } from "sonner";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { captureClientEvent } from "@/client/lib/posthog";import type { KeywordRow } from "@/client/features/domain/types";@@ -17,7 +16,6 @@ type SaveMutation = (payload: {type SaveOptions = {onSuccess?: () => void;- onError?: (error: unknown) => void;};export function saveSelectedKeywords({@@ -61,9 +59,6 @@ export function saveSelectedKeywords({});toast.success(`Saved ${selectedKeywords.size} keywords`);},- onError: (error: unknown) => {- toast.error(getStandardErrorMessage(error, "Save failed."));- },},);}diff --git a/src/client/features/ga4/GoogleAnalyticsConnectionCard.tsx b/src/client/features/ga4/GoogleAnalyticsConnectionCard.tsxindex 833f21cd..4cdf0237 100644--- a/src/client/features/ga4/GoogleAnalyticsConnectionCard.tsx+++ b/src/client/features/ga4/GoogleAnalyticsConnectionCard.tsx@@ -89,6 +89,7 @@ export function GoogleAnalyticsConnectionCard({});};const setPropertyMutation = useMutation({+ meta: { errorToast: false },mutationFn: (selected: Ga4PropertySelection) =>setGa4Property({ data: { projectId, ...selected } }),onSuccess: (saved) => {@@ -104,6 +105,7 @@ export function GoogleAnalyticsConnectionCard({},});const disconnectMutation = useMutation({+ meta: { errorToast: false },mutationFn: () => disconnectGa4({ data: { projectId } }),onSuccess: () => {toast.success("Google Analytics disconnected from this project");diff --git a/src/client/features/gsc/SearchConsoleConnectionCard.tsx b/src/client/features/gsc/SearchConsoleConnectionCard.tsxindex 256c0acc..2a0fa8ce 100644--- a/src/client/features/gsc/SearchConsoleConnectionCard.tsx+++ b/src/client/features/gsc/SearchConsoleConnectionCard.tsx@@ -85,6 +85,7 @@ export function SearchConsoleConnectionCard({}, [accounts, selection, picking, connected]);const setSiteMutation = useMutation({+ meta: { errorToast: false },mutationFn: (selected: GscSiteSelection) =>setGscSite({ data: { projectId, ...selected } }),onSuccess: (saved) => {@@ -117,6 +118,7 @@ export function SearchConsoleConnectionCard({});const disconnectMutation = useMutation({+ meta: { errorToast: false },mutationFn: () => disconnectGsc({ data: { projectId } }),onSuccess: () => {toast.success("Search Console disconnected from this project");diff --git a/src/client/features/integrations/GoogleAccountRemovalDialog.tsx b/src/client/features/integrations/GoogleAccountRemovalDialog.tsxindex 21ca7f79..99698dbd 100644--- a/src/client/features/integrations/GoogleAccountRemovalDialog.tsx+++ b/src/client/features/integrations/GoogleAccountRemovalDialog.tsx@@ -1,4 +1,5 @@import { useEffect, useId, useRef } from "react";+import { toast } from "sonner";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { getStandardErrorMessage } from "@/client/lib/error-messages";import {@@ -30,6 +31,7 @@ export function GoogleAccountRemovalDialog({gcTime: 0,});const removal = useMutation({+ meta: { errorToast: false },mutationFn: () =>removeGoogleAccount({ data: { provider, accountId, confirmed: true } }),onSuccess: async () => {@@ -53,6 +55,7 @@ export function GoogleAccountRemovalDialog({await Promise.all(keys.map((key) => queryClient.invalidateQueries({ queryKey: [key] })),);+ toast.success("Google account removed");onRemoved();},});diff --git a/src/client/features/keywords/state/keywordControllerActions.ts b/src/client/features/keywords/state/keywordControllerActions.tsindex 04aad54b..069fef2f 100644--- a/src/client/features/keywords/state/keywordControllerActions.ts+++ b/src/client/features/keywords/state/keywordControllerActions.ts@@ -1,7 +1,6 @@import { useMemo } from "react";import { toast } from "sonner";import { buildCsv, type CsvValue, downloadCsv } from "@/client/lib/csv";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { captureClientEvent } from "@/client/lib/posthog";import type { KeywordResearchRow } from "@/types/keywords";import type { SaveKeywordsInput } from "@/types/schemas/keywords";@@ -40,10 +39,7 @@ type SaveExportActionParams = {input: KeywordResearchControllerInput;saveKeywordsMutate: (variables: SaveKeywordsInput,- options: {- onSuccess: () => void;- onError: (error: unknown) => void;- },+ options: { onSuccess: () => void },) => void;setShowSaveDialog: (show: boolean) => void;};@@ -140,9 +136,6 @@ export function useSaveAndExportActions(params: SaveExportActionParams) {toast.success(`Saved ${selectedRows.size} keywords`);setShowSaveDialog(false);},- onError: (error: unknown) => {- toast.error(getStandardErrorMessage(error, "Save failed."));- },},);};diff --git a/src/client/features/lighthouse/issues/LighthouseIssuesScreen.tsx b/src/client/features/lighthouse/issues/LighthouseIssuesScreen.tsxindex 7e94bed4..342a3845 100644--- a/src/client/features/lighthouse/issues/LighthouseIssuesScreen.tsx+++ b/src/client/features/lighthouse/issues/LighthouseIssuesScreen.tsx@@ -42,6 +42,7 @@ export function LighthouseIssuesScreen(props: LighthouseIssuesScreenProps) {});const exportMutation = useMutation({+ meta: { errorToast: false },mutationFn: (data: ExportPayload,): Promise<{ filename: string; content: string }> =>diff --git a/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx b/src/client/features/onboarding/SearchConsoleOnboardingStep.tsxindex f3e0ee02..3ccd8e55 100644--- a/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx+++ b/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx@@ -1,7 +1,6 @@import * as React from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { ArrowLeft, ArrowRight, Check } from "lucide-react";-import { toast } from "sonner";import { GoogleGlyph } from "@/client/features/gsc/GoogleGlyph";import { GoogleLinkErrorAlert } from "@/client/features/integrations/GoogleLinkErrorAlert";import { SelfHostedSetupWarning } from "@/client/features/gsc/SelfHostedSetupWarning";@@ -13,7 +12,6 @@ import {startGoogleLink,useGoogleLinkPending,} from "@/client/features/integrations/startGoogleLink";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { captureClientEvent } from "@/client/lib/posthog";import {getGscConnection,@@ -122,7 +120,6 @@ function GscConnect({void queryClient.invalidateQueries({ queryKey: ["projects"] });onNext();},- onError: (error) => toast.error(getStandardErrorMessage(error)),});const handleConnect = () => {diff --git a/src/client/features/projects/CreateProjectModal.tsx b/src/client/features/projects/CreateProjectModal.tsxindex ee92c009..5f1bab02 100644--- a/src/client/features/projects/CreateProjectModal.tsx+++ b/src/client/features/projects/CreateProjectModal.tsx@@ -3,7 +3,6 @@ import { useNavigate } from "@tanstack/react-router";import { useMutation, useQueryClient } from "@tanstack/react-query";import { toast } from "sonner";import { Modal } from "@/client/components/Modal";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { setLastProjectId } from "@/client/lib/active-project";import {DEFAULT_LOCATION_CODE,@@ -45,8 +44,6 @@ export function CreateProjectModal({ onClose }: { onClose: () => void }) {params: { projectId: created.id },});},- onError: (error) =>- toast.error(getStandardErrorMessage(error, "Failed to create project")),});const isPending = createMutation.isPending;diff --git a/src/client/features/projects/ProjectGeneralSettings.tsx b/src/client/features/projects/ProjectGeneralSettings.tsxindex d3d8cbc6..85ebec72 100644--- a/src/client/features/projects/ProjectGeneralSettings.tsx+++ b/src/client/features/projects/ProjectGeneralSettings.tsx@@ -3,7 +3,6 @@ import { useNavigate } from "@tanstack/react-router";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { toast } from "sonner";import { ProjectMarketFields } from "@/client/features/projects/ProjectMarketFields";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import {clearLastProjectId,getLastProjectId,@@ -63,8 +62,6 @@ function GeneralSection({ project }: { project: ProjectSummary }) {await queryClient.invalidateQueries({ queryKey: ["projects"] });toast.success("Project updated");},- onError: (error) =>- toast.error(getStandardErrorMessage(error, "Failed to update project")),});const isDirty =@@ -154,8 +151,6 @@ function DangerSection({// Re-resolve to a remaining project via the landing redirect.void navigate({ to: "/" });},- onError: (error) =>- toast.error(getStandardErrorMessage(error, "Failed to archive project")),});return (diff --git a/src/client/features/projects/project-context/shared.tsx b/src/client/features/projects/project-context/shared.tsxindex 32f8db3a..33e5196f 100644--- a/src/client/features/projects/project-context/shared.tsx+++ b/src/client/features/projects/project-context/shared.tsx@@ -3,7 +3,6 @@ import { useState, type ReactNode } from "react";import { useMutation, useQueryClient } from "@tanstack/react-query";import { Trash2 } from "lucide-react";import { toast } from "sonner";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { updateProjectContext } from "@/serverFunctions/projectContext";import type { getProjectContext } from "@/serverFunctions/projectContext";import type {@@ -38,8 +37,6 @@ export function useContextUpdate(projectId: string) {queryClient.setQueryData(queryKey, context);toast.success("Project context updated");},- onError: (error) =>- toast.error(getStandardErrorMessage(error, "Couldn't save your changes")),// The page instantiates this mutation per section, so two concurrent// patches can settle out of order and the slower (earlier-snapshotted)// response can land in the cache last; a settle-time refetch convergesdiff --git a/src/client/features/rank-tracking/AddKeywordsPanel.tsx b/src/client/features/rank-tracking/AddKeywordsPanel.tsxindex b3bf5fac..b797c0aa 100644--- a/src/client/features/rank-tracking/AddKeywordsPanel.tsx+++ b/src/client/features/rank-tracking/AddKeywordsPanel.tsx@@ -3,7 +3,6 @@ import { toast } from "sonner";import { useMutation } from "@tanstack/react-query";import { addTrackingKeywords } from "@/serverFunctions/rank-tracking";import { MAX_TRACKED_KEYWORD_LENGTH } from "@/shared/rank-tracking";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { Loader2 } from "lucide-react";export function AddKeywordsPanel({@@ -32,9 +31,6 @@ export function AddKeywordsPanel({setKeywordInput("");onSuccess(result);},- onError: (error) => {- toast.error(getStandardErrorMessage(error, "Failed to add keywords"));- },});const isPending = mutation.isPending;return (diff --git a/src/client/features/rank-tracking/KeywordSuggestionStep.tsx b/src/client/features/rank-tracking/KeywordSuggestionStep.tsxindex 4f92593c..a6af07c4 100644--- a/src/client/features/rank-tracking/KeywordSuggestionStep.tsx+++ b/src/client/features/rank-tracking/KeywordSuggestionStep.tsx@@ -10,7 +10,6 @@ import { toast } from "sonner";import { getDomainKeywordSuggestions } from "@/serverFunctions/domain";import { addTrackingKeywords } from "@/serverFunctions/rank-tracking";import { isLabsLocationCode } from "@/client/features/keywords/locations";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import {AppDataTable,makeSelectionColumn,@@ -213,9 +212,6 @@ export function KeywordSuggestionStep({toast.success(`Added ${result.added} keywords for tracking`);onDone(configId);},- onError: (error) => {- toast.error(getStandardErrorMessage(error, "Failed to add keywords"));- },});const handleAdd = () => {diff --git a/src/client/features/rank-tracking/RankTrackingTable.tsx b/src/client/features/rank-tracking/RankTrackingTable.tsxindex b82a27a7..b7c5bb8a 100644--- a/src/client/features/rank-tracking/RankTrackingTable.tsx+++ b/src/client/features/rank-tracking/RankTrackingTable.tsx@@ -17,7 +17,6 @@ import { exportTableToSheets } from "@/client/lib/exportToSheets";import { captureClientEvent } from "@/client/lib/posthog";import { useMutation, useQueryClient } from "@tanstack/react-query";import { removeTrackingKeywords } from "@/serverFunctions/rank-tracking";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import type { RankTrackingRow } from "@/types/schemas/rank-tracking";import { useRankTrackingColumns } from "./RankTrackingColumns";import { buildRankTrackingExport } from "./RankTrackingTableParts";@@ -142,9 +141,6 @@ export function RankTrackingTable({`${result.removed} keyword${result.removed !== 1 ? "s" : ""} removed`,);},- onError: (error) => {- toast.error(getStandardErrorMessage(error, "Failed to remove keywords"));- },});if (resultsLoading) {diff --git a/src/client/features/rank-tracking/useMetricsRefresh.ts b/src/client/features/rank-tracking/useMetricsRefresh.tsindex 09618199..a08c3216 100644--- a/src/client/features/rank-tracking/useMetricsRefresh.ts+++ b/src/client/features/rank-tracking/useMetricsRefresh.ts@@ -15,9 +15,6 @@ export function useMetricsRefresh(projectId: string, configId: string) {});toast.success(`Metrics updated for ${result.updated} keywords`);},- onError: () => {- toast.error("Failed to refresh keyword metrics");- },});return { refresh: mutation.mutate, isRefreshing: mutation.isPending };}diff --git a/src/client/features/rank-tracking/useRankCheckTrigger.ts b/src/client/features/rank-tracking/useRankCheckTrigger.tsindex 1c641abf..7f212ca5 100644--- a/src/client/features/rank-tracking/useRankCheckTrigger.ts+++ b/src/client/features/rank-tracking/useRankCheckTrigger.ts@@ -1,6 +1,5 @@import { useMutation, useQueryClient } from "@tanstack/react-query";import { toast } from "sonner";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { captureClientEvent } from "@/client/lib/posthog";import { triggerRankCheck } from "@/serverFunctions/rank-tracking";@@ -39,9 +38,6 @@ export function useRankCheckTrigger({captureClientEvent("rank_tracking:check_trigger");toast.success("Rank check started");},- onError: (error) => {- toast.error(getStandardErrorMessage(error, "Failed to start rank check"));- },});const startCheck = (opts: { keywordIds?: string[] }) => {diff --git a/src/client/features/rank-tracking/useSaveConfigMutations.ts b/src/client/features/rank-tracking/useSaveConfigMutations.tsindex 51c8e6dc..0d094ce9 100644--- a/src/client/features/rank-tracking/useSaveConfigMutations.ts+++ b/src/client/features/rank-tracking/useSaveConfigMutations.ts@@ -4,7 +4,6 @@ import {createRankTrackingConfig,updateRankTrackingConfig,} from "@/serverFunctions/rank-tracking";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { captureClientEvent } from "@/client/lib/posthog";import type {RankCheckScheduleTime,@@ -55,9 +54,6 @@ export function useSaveConfigMutations(input: {toast.success("Domain added for rank tracking");onCreated(result.id);},- onError: (error) => {- toast.error(getStandardErrorMessage(error, "Failed to save config"));- },});const updateMutation = useMutation({@@ -79,9 +75,6 @@ export function useSaveConfigMutations(input: {toast.success("Configuration updated");onUpdated();},- onError: (error) => {- toast.error(getStandardErrorMessage(error, "Failed to update config"));- },});return { createMutation, updateMutation };diff --git a/src/client/features/reports/ReportTemplateForm.tsx b/src/client/features/reports/ReportTemplateForm.tsxindex 95ef412e..52fe4f8f 100644--- a/src/client/features/reports/ReportTemplateForm.tsx+++ b/src/client/features/reports/ReportTemplateForm.tsx@@ -1,6 +1,7 @@import { useForm } from "@tanstack/react-form";import { useMutation } from "@tanstack/react-query";import { Loader2 } from "lucide-react";+import { toast } from "sonner";import { z } from "zod";import { Modal } from "@/client/components/Modal";import { getStandardErrorMessage } from "@/client/lib/error-messages";@@ -42,6 +43,7 @@ export function ReportTemplateForm({onSaved: () => void;}) {const saveMutation = useMutation({+ meta: { errorToast: false },// A refusal (duplicate name, the cap) comes back as `{ ok: false }` rather// than an error, because thrown errors reach the client stripped to their// code. Rethrowing it here gives the form one error branch.@@ -58,6 +60,7 @@ export function ReportTemplateForm({is_update: !result.created,source: "app",});+ toast.success(result.created ? "Template created" : "Template saved");onSaved();},});diff --git a/src/client/features/reports/shared.tsx b/src/client/features/reports/shared.tsxindex 65c38163..cdf7a2d1 100644--- a/src/client/features/reports/shared.tsx+++ b/src/client/features/reports/shared.tsx@@ -59,11 +59,6 @@ export function useDeleteReport(projectId: string, onDeleted?: () => void) {});onDeleted?.();},- onError: (error: Error) => {- toast.error(- getStandardErrorMessage(error, "Failed to delete the report"),- );- },});}@@ -113,6 +108,7 @@ export function ShareReportModal({// shows the new link without waiting for a refetch; the list is invalidated// because its rows carry the same metadata.const mutation = useMutation({+ meta: { errorToast: false },mutationFn: (shared: boolean) =>shared? shareReport({ data: { projectId, reportId } })diff --git a/src/client/features/sam/SamConversation.tsx b/src/client/features/sam/SamConversation.tsxindex 7d885674..de0eafcd 100644--- a/src/client/features/sam/SamConversation.tsx+++ b/src/client/features/sam/SamConversation.tsx@@ -5,6 +5,7 @@ import { useAgentChat } from "@cloudflare/think/react";import { useEffect, useRef } from "react";import { RotateCcw } from "lucide-react";import { findLast } from "remeda";+import { toast } from "sonner";import { ChatComposer } from "@/client/features/sam/ChatComposer";import { invalidateSamSessions } from "@/client/features/sam/samQueries";import { captureClientEvent } from "@/client/lib/posthog";@@ -94,8 +95,11 @@ export function SamConversation({method: "POST",headers: { "content-type": "application/json" },body: JSON.stringify({ messageId }),- });- if (!response.ok) return false;+ }).catch(() => null);+ if (!response?.ok) {+ toast.error("Couldn't change the conversation. Try again.");+ return false;+ }const fresh = await fetch(`/agents/sam-chat/${sessionId}/get-messages`,).then((res) => (res.ok ? res.json() : null));diff --git a/src/client/features/search-performance/SearchPerformanceParts.tsx b/src/client/features/search-performance/SearchPerformanceParts.tsxindex e3eee895..93d3bf96 100644--- a/src/client/features/search-performance/SearchPerformanceParts.tsx+++ b/src/client/features/search-performance/SearchPerformanceParts.tsx@@ -27,7 +27,6 @@ import {normalizeExportValue,type CsvValue,} from "@/client/lib/csv";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { exportTableToSheets } from "@/client/lib/exportToSheets";import { captureClientEvent } from "@/client/lib/posthog";import {@@ -312,9 +311,6 @@ export function StrikingDistanceTable({);setRowSelection({});},- onError: (error) => {- toast.error(getStandardErrorMessage(error, "Could not save keywords"));- },});if (rows.length === 0) {diff --git a/src/client/features/settings/ApiKeySettings.tsx b/src/client/features/settings/ApiKeySettings.tsxindex 1448ded9..87ceeccd 100644--- a/src/client/features/settings/ApiKeySettings.tsx+++ b/src/client/features/settings/ApiKeySettings.tsx@@ -4,7 +4,6 @@ import { useState } from "react";import { toast } from "sonner";import { PortalMenu } from "@/client/components/PortalMenu";import { CopyButton } from "@/client/features/ai-mcp/SetupControls";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { captureClientEvent } from "@/client/lib/posthog";import { authClient } from "@/lib/auth-client";@@ -53,9 +52,6 @@ export function ApiKeySettings() {captureClientEvent("mcp:api_key_created");void queryClient.invalidateQueries({ queryKey: ["apiKeys"] });},- onError: (error) => {- toast.error(getStandardErrorMessage(error));- },});const revokeMutation = useMutation({@@ -70,9 +66,6 @@ export function ApiKeySettings() {toast.success("API key revoked");void queryClient.invalidateQueries({ queryKey: ["apiKeys"] });},- onError: (error) => {- toast.error(getStandardErrorMessage(error));- },});const apiKeys = apiKeysQuery.data ?? [];diff --git a/src/client/features/settings/CrawlerAccessSettings.tsx b/src/client/features/settings/CrawlerAccessSettings.tsxindex 72c7bb8f..956ef392 100644--- a/src/client/features/settings/CrawlerAccessSettings.tsx+++ b/src/client/features/settings/CrawlerAccessSettings.tsx@@ -6,7 +6,6 @@ import {CrawlerAccessForm,crawlerCredentialsQueryKey,} from "@/client/features/crawler-access/CrawlerAccessForm";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import {deleteCrawlerCredential,listCrawlerCredentials,@@ -38,8 +37,6 @@ export function CrawlerAccessSettings({ projectId }: { projectId: string }) {});toast.success("Crawler access removed");},- onError: (error) =>- toast.error(getStandardErrorMessage(error, "We couldn't remove that")),});const credentials = credentialsQuery.data ?? [];diff --git a/src/client/features/team/TeamSettings.tsx b/src/client/features/team/TeamSettings.tsxindex 46d7b163..ecd89491 100644--- a/src/client/features/team/TeamSettings.tsx+++ b/src/client/features/team/TeamSettings.tsx@@ -59,9 +59,6 @@ export function TeamSettings() {toast.success("Member removed");void refreshTeam();},- onError: (error: Error) => {- toast.error(error.message || "We couldn't remove that member.");- },});const cancelInvitationMutation = useMutation({@@ -80,9 +77,6 @@ export function TeamSettings() {toast.success("Invitation canceled");void refreshTeam();},- onError: (error: Error) => {- toast.error(error.message || "We couldn't cancel that invitation.");- },});const role = orgContextQuery.data?.role ?? "member";diff --git a/src/client/tanstack-db/queryClient.test.ts b/src/client/tanstack-db/queryClient.test.tsnew file mode 100644index 00000000..eac5eea2--- /dev/null+++ b/src/client/tanstack-db/queryClient.test.ts@@ -0,0 +1,33 @@+import { describe, expect, it, vi } from "vitest";+import { toast } from "sonner";+import { queryClient } from "@/client/tanstack-db/queryClient";++vi.mock("sonner", () => ({ toast: { error: vi.fn() } }));++function runFailingMutation(+ options: { onError?: () => void; meta?: { errorToast?: false } } = {},+) {+ return queryClient+ .getMutationCache()+ .build(queryClient, {+ mutationFn: () => Promise.reject(new Error("RATE_LIMITED")),+ ...options,+ })+ .execute(undefined)+ .catch(() => undefined);+}++describe("default mutation error toast", () => {+ it("shows the standard message for a mutation without its own handling", async () => {+ await runFailingMutation();+ expect(toast.error).toHaveBeenCalledWith(+ "Too many requests. Please wait and try again.",+ );+ });++ it("stays quiet when the mutation has its own onError or opts out", async () => {+ await runFailingMutation({ onError: () => undefined });+ await runFailingMutation({ meta: { errorToast: false } });+ expect(toast.error).not.toHaveBeenCalled();+ });+});diff --git a/src/client/tanstack-db/queryClient.ts b/src/client/tanstack-db/queryClient.tsindex 4d89cd84..0abd1ab3 100644--- a/src/client/tanstack-db/queryClient.ts+++ b/src/client/tanstack-db/queryClient.ts@@ -1,6 +1,27 @@-import { QueryClient } from "@tanstack/query-core";+import { MutationCache, QueryClient } from "@tanstack/query-core";+import { toast } from "sonner";+import { getStandardErrorMessage } from "@/client/lib/error-messages";++declare module "@tanstack/query-core" {+ interface Register {+ mutationMeta: {+ // Set when the component shows the error itself (inline or in a catch).+ errorToast?: false;+ };+ }+}export const queryClient = new QueryClient({+ // Every failed mutation shows a toast unless it has its own onError or opts+ // out through meta, so no failure is silent.+ mutationCache: new MutationCache({+ onError: (error, _variables, _context, mutation) => {+ if (mutation.options.onError || mutation.meta?.errorToast === false) {+ return;+ }+ toast.error(getStandardErrorMessage(error));+ },+ }),defaultOptions: {queries: {gcTime: 1000 * 60 * 60,diff --git a/src/routes/_app/projects.tsx b/src/routes/_app/projects.tsxindex e62f1373..8a593a6e 100644--- a/src/routes/_app/projects.tsx+++ b/src/routes/_app/projects.tsx@@ -8,7 +8,6 @@ import {getProjects,restoreProject,} from "@/serverFunctions/projects";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { getLastProjectId } from "@/client/lib/active-project";import { CreateProjectModal } from "@/client/features/projects/CreateProjectModal";@@ -113,8 +112,6 @@ function ArchivedProjects() {await queryClient.invalidateQueries({ queryKey: ["projects"] });toast.success("Project restored");},- onError: (error) =>- toast.error(getStandardErrorMessage(error, "Failed to restore project")),});if (archived.length === 0) return null;diff --git a/src/routes/_app/support.tsx b/src/routes/_app/support.tsxindex a3bdce72..58aecd98 100644--- a/src/routes/_app/support.tsx+++ b/src/routes/_app/support.tsx@@ -15,7 +15,12 @@ function SupportPage() {const [copied, setCopied] = useState(false);const handleCopy = async () => {- await navigator.clipboard.writeText(SUPPORT_EMAIL);+ try {+ await navigator.clipboard.writeText(SUPPORT_EMAIL);+ } catch {+ toast.error("Could not copy to clipboard");+ return;+ }toast.success("Email copied to clipboard");setCopied(true);setTimeout(() => setCopied(false), 2000);diff --git a/src/routes/_authenticated.onboarding.index.tsx b/src/routes/_authenticated.onboarding.index.tsxindex cdb82333..8e6d7974 100644--- a/src/routes/_authenticated.onboarding.index.tsx+++ b/src/routes/_authenticated.onboarding.index.tsx@@ -1,8 +1,6 @@import { useMutation, useQuery } from "@tanstack/react-query";import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";import { useState } from "react";-import { toast } from "sonner";-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { OnboardingAccountMenu } from "@/client/features/onboarding/OnboardingAccountMenu";import { PostSignupOnboarding } from "@/client/features/onboarding/PostSignupOnboarding";import {@@ -79,14 +77,6 @@ function OnboardingFlow({saveOnboardingAnswers({data: buildOnboardingPayload(answers, step, extra),}),- onError: (error) => {- toast.error(- getStandardErrorMessage(- error,- "Couldn’t save your answers. Please try again.",- ),- );- },});const goToStep = (next: number) =>diff --git a/src/routes/_project/p/$projectId/reports/templates.tsx b/src/routes/_project/p/$projectId/reports/templates.tsxindex 1a9cc3ea..5279f521 100644--- a/src/routes/_project/p/$projectId/reports/templates.tsx+++ b/src/routes/_project/p/$projectId/reports/templates.tsx@@ -60,11 +60,6 @@ function ReportTemplatesPage() {setPendingDelete(null);invalidate();},- onError: (error: Error) => {- toast.error(- getStandardErrorMessage(error, "Failed to delete the template"),- );- },});return (diff --git a/src/routes/_project/p/$projectId/saved.tsx b/src/routes/_project/p/$projectId/saved.tsxindex 7156d3fb..3ae621d5 100644--- a/src/routes/_project/p/$projectId/saved.tsx+++ b/src/routes/_project/p/$projectId/saved.tsx@@ -191,9 +191,6 @@ function SavedKeywordsPage() {`Updated tags for ${result.taggedCount} keyword${result.taggedCount !== 1 ? "s" : ""}`,);},- onError: (error) => {- toast.error(getStandardErrorMessage(error, "Could not update tags"));- },});const refreshMetricsMutation = useMutation({@@ -204,11 +201,6 @@ function SavedKeywordsPage() {`Updated stats for ${result.updated} keyword${result.updated !== 1 ? "s" : ""}`,);},- onError: (error) => {- toast.error(- getStandardErrorMessage(error, "Could not update keyword stats."),- );- },});const tagManage = useTagManage(projectId);@@ -314,12 +306,15 @@ function SavedKeywordsPage() {selectedCount={selectedCount}exportingSelection={exporter.exportingSelection}onCopy={() => {- void navigator.clipboard.writeText(- selectedRows.map((row) => row.keyword).join("\n"),- );- toast.success(- `${selectedCount} keyword${selectedCount !== 1 ? "s" : ""} copied`,- );+ navigator.clipboard+ .writeText(selectedRows.map((row) => row.keyword).join("\n"))+ .then(+ () =>+ toast.success(+ `${selectedCount} keyword${selectedCount !== 1 ? "s" : ""} copied`,+ ),+ () => toast.error("Could not copy to clipboard"),+ );}}onOpenTags={() => setShowTagModal(true)}onExportCsv={() => exporter.exportSelectionCsv(selectedRows)}