diff --git a/frontend/src/pages/flows/flow.tsx b/frontend/src/pages/flows/flow.tsx index e6fac13a..a43fb718 100644 --- a/frontend/src/pages/flows/flow.tsx +++ b/frontend/src/pages/flows/flow.tsx @@ -79,7 +79,7 @@ function Flow() { const { isDesktop, isMobile } = useBreakpoint(); const navigate = useNavigate(); - const { flowData, flowError, flowId, isLoading: isFlowLoading } = useFlow(); + const { flowData, flowId, isLoading: isFlowLoading } = useFlow(); const { deleteFlow, finishFlow } = useFlows(); const { isFavoriteFlow, toggleFavoriteFlow } = useFavorites(); @@ -108,10 +108,13 @@ function Flow() { const [renameFlowMutation, { loading: isRenameLoading }] = useMutation(RenameFlowDocument); useEffect(() => { - if (flowError || (!isFlowLoading && !flowData?.flow)) { + // errorPolicy:'all' surfaces a partial error while the flow itself + // loaded; leave only when the flow is genuinely absent, not on any error + // — else a failed sibling log query bounces the user off a working flow. + if (!isFlowLoading && !flowData?.flow) { navigate(routes.flows, { replace: true }); } - }, [flowError, flowData, isFlowLoading, navigate]); + }, [flowData, isFlowLoading, navigate]); const handleFlowRenameSave = useCallback(async () => { const newTitle = editingInputRef.current?.value.trim(); diff --git a/frontend/src/providers/flow-provider.tsx b/frontend/src/providers/flow-provider.tsx index c2b27327..00a1a4b5 100644 --- a/frontend/src/providers/flow-provider.tsx +++ b/frontend/src/providers/flow-provider.tsx @@ -170,12 +170,11 @@ export function FlowProvider({ children }: FlowProviderProps) { const flowStatus = useMemo(() => flowData?.flow?.status, [flowData?.flow?.status]); - // A single Postgres "no rows in result set" surfaces here every time a sibling - // query/subscription retries against an invalid flow id; without a stable - // toast id Sonner would stack 8 copies of the same message before the page - // redirects. Surface a friendly message and drop the raw SQL detail entirely. + // errorPolicy:'all' surfaces a partial error while the flow loaded, so gate + // on `!flow` or a partial failure toasts over a flow that rendered fine. The + // stable id keeps the invalid-id "no rows" retries from stacking. useEffect(() => { - if (flowError) { + if (flowError && !flowData?.flow) { const raw = flowError.message ?? ''; const isNotFound = /no rows in result set|not found/i.test(raw); toast.error(isNotFound ? 'Flow not found' : 'Failed to load flow', { @@ -184,7 +183,7 @@ export function FlowProvider({ children }: FlowProviderProps) { }); Log.error('Error loading flow:', flowError); } - }, [flowError]); + }, [flowError, flowData]); const submitAutomationMessage = useCallback( async (values: FlowFormValues) => {