2.5 KiB
2.5 KiB
Plan 21-01 Summary: Error Boundary & Toast Notifications
Result: COMPLETE
Duration: ~3 min Commits: 2
What was done
-
Created ErrorBoundary component (
packages/web/src/components/ErrorBoundary.tsx)- React class component with
getDerivedStateFromErrorandcomponentDidCatch - Renders centered error card: red AlertCircle icon, "Something went wrong" heading, error message in muted text, Reload button
- Styled with existing Tailwind classes matching the app's error state patterns
- React class component with
-
Created Sonner toast wrapper (
packages/web/src/components/ui/sonner.tsx)- Thin wrapper exporting
Toastercomponent from sonner - Configured with
position="bottom-right"andrichColors
- Thin wrapper exporting
-
Wired into root route (
packages/web/src/routes/__root.tsx)<ErrorBoundary>wraps<Outlet />inside AppLayout so route-level render errors are caught without destroying the nav shell<Toaster />rendered as sibling to AppLayout for app-wide toast availabilitynotFoundComponentupdated with "Back to Dashboard" Button/Link pointing to /initiatives
-
Wired toast notifications into all mutation flows
SpawnArchitectDropdown.tsx:toast.success("Architect spawned")on success,toast.error("Failed to spawn architect")on errorActionMenu.tsx:toast.success("Initiative archived")on success,toast.error("Failed to archive initiative")on errorCreateInitiativeDialog.tsx:toast.success("Initiative created")on success (inline error kept for form validation)inbox.tsx:toast.success/toast.errorfor bothresumeAgentandrespondToMessagemutations
Decisions
- 21-01: ErrorBoundary wraps Outlet only (not entire AppLayout) so nav shell survives render errors
- 21-01: Toaster outside AppLayout as sibling — available even if layout breaks
- 21-01: notFoundComponent uses shadcn Button with asChild + Link (consistent with component library)
- 21-01: CreateInitiativeDialog keeps inline form error in addition to toast (inline error shows specific validation message)
- 21-01: One success and one error toast per mutation — no toasts for query failures (those have inline error states)
Verification
npx tsc --noEmit -p packages/web/tsconfig.app.json— passesnpm run --workspace=packages/web build— succeeds- ErrorBoundary component exists and is wired into root route
- Toaster component rendered in root route
- All mutation callbacks use toast instead of (or in addition to) console.error