feat(21-04): add subscription error handling with toast feedback on all pages

- Replace silent onError: () => {} with sticky toast notification
- Toast uses fixed ID 'sub-error' to prevent duplicate notifications
- duration: Infinity keeps toast visible until dismissed
- Applied to initiatives/index.tsx, initiatives/$id.tsx, inbox.tsx
This commit is contained in:
Lukas May
2026-02-05 09:04:17 +01:00
parent 3d492d86a1
commit 4ae85da3f6
3 changed files with 26 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { AlertCircle } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/Skeleton";
import { toast } from "sonner";
import { trpc } from "@/lib/trpc";
import { InitiativeHeader } from "@/components/InitiativeHeader";
import { ProgressPanel } from "@/components/ProgressPanel";
@@ -218,13 +219,23 @@ function InitiativeDetailPage() {
void utils.listTasks.invalidate();
void utils.listPlans.invalidate();
},
onError: () => {},
onError: () => {
toast.error("Live updates disconnected. Refresh to reconnect.", {
id: "sub-error",
duration: Infinity,
});
},
});
trpc.onAgentUpdate.useSubscription(undefined, {
onData: () => {
void utils.listAgents.invalidate();
},
onError: () => {},
onError: () => {
toast.error("Live updates disconnected. Refresh to reconnect.", {
id: "sub-error",
duration: Infinity,
});
},
});
// State