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

@@ -23,7 +23,12 @@ function InboxPage() {
void utils.listWaitingAgents.invalidate();
void utils.listMessages.invalidate();
},
onError: () => {},
onError: () => {
toast.error("Live updates disconnected. Refresh to reconnect.", {
id: "sub-error",
duration: Infinity,
});
},
});
// Data fetching

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

View File

@@ -2,6 +2,7 @@ import { useState } from "react";
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { Plus } from "lucide-react";
import { Button } from "@/components/ui/button";
import { toast } from "sonner";
import { trpc } from "@/lib/trpc";
import { InitiativeList } from "@/components/InitiativeList";
import { CreateInitiativeDialog } from "@/components/CreateInitiativeDialog";
@@ -31,7 +32,12 @@ function DashboardPage() {
void utils.listInitiatives.invalidate();
void utils.listPhases.invalidate();
},
onError: () => {},
onError: () => {
toast.error("Live updates disconnected. Refresh to reconnect.", {
id: "sub-error",
duration: Infinity,
});
},
});
return (