Skip to content

An open-source, faster Devin alternative

TypeScript

fix(web): humanize error toasts + move Checkpoints filter into the header

Igor Zalutski757adc688181
diff --git a/web/.gitignore b/web/.gitignore
index 06e60381..a00693dd 100644
--- a/web/.gitignore
+++ b/web/.gitignore
@@ -1,3 +1,6 @@
node_modules
dist
*.tsbuildinfo
+
+# impeccable critique snapshots (local backlog)
+.impeccable/
diff --git a/web/src/lib/errors.ts b/web/src/lib/errors.ts
new file mode 100644
index 00000000..3d1aaa37
--- /dev/null
+++ b/web/src/lib/errors.ts
@@ -0,0 +1,12 @@
+import { toast } from 'sonner'
+
+/**
+ * Show a clear, human error toast and send the raw error to the console for
+ * debugging. Keeps raw messages, HTTP codes, and stack detail out of the UI —
+ * the toast says what failed in plain language; `console.error` keeps the
+ * detail for developers.
+ */
+export function notifyError(message: string, error?: unknown): void {
+ if (error !== undefined) console.error(message, error)
+ toast.error(message)
+}
diff --git a/web/src/pages/APIKeys.tsx b/web/src/pages/APIKeys.tsx
index b51fab68..409f1479 100644
--- a/web/src/pages/APIKeys.tsx
+++ b/web/src/pages/APIKeys.tsx
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { toast } from 'sonner'
import { CircleCheck, KeyRound, Plus, X } from 'lucide-react'
+import { notifyError } from '@/lib/errors'
import {
createAPIKey,
deleteAPIKey,
@@ -45,18 +45,12 @@ export default function APIKeys() {
setNewKeyName('')
queryClient.invalidateQueries({ queryKey: ['api-keys'] })
},
- onError: (error) =>
- toast.error(
- `Couldn't create key: ${error instanceof Error ? error.message : String(error)}`,
- ),
+ onError: (error) => notifyError("Couldn't create the API key.", error),
})
const deleteMutation = useMutation({
mutationFn: (id: string) => deleteAPIKey(id),
- onError: (error) =>
- toast.error(
- `Revoke failed: ${error instanceof Error ? error.message : String(error)}`,
- ),
+ onError: (error) => notifyError("Couldn't revoke the key.", error),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['api-keys'] }),
})
diff --git a/web/src/pages/Billing.tsx b/web/src/pages/Billing.tsx
index 37342acf..1a3f72bb 100644
--- a/web/src/pages/Billing.tsx
+++ b/web/src/pages/Billing.tsx
@@ -2,6 +2,7 @@ import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { toast } from 'sonner'
import { CircleAlert, CircleCheck } from 'lucide-react'
+import { notifyError } from '@/lib/errors'
import {
autumnSubscribeConcurrency,
autumnTopup,
@@ -79,16 +80,14 @@ function PlanTab() {
onSuccess: (data) => {
window.location.href = data.url
},
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : 'Setup failed'),
+ onError: (e) => notifyError("Couldn't start checkout.", e),
})
const portalMutation = useMutation({
mutationFn: billingPortal,
onSuccess: (data) => {
window.location.href = data.url
},
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : "Couldn't open portal"),
+ onError: (e) => notifyError("Couldn't open the billing portal.", e),
})
const redeemMutation = useMutation({
mutationFn: () => redeemPromoCode(promoCode),
@@ -99,8 +98,7 @@ function PlanTab() {
`$${(data.creditAppliedCents / 100).toFixed(2)} credit applied`,
)
},
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : 'Invalid promo code'),
+ onError: (e) => notifyError("Couldn't redeem that promo code.", e),
})
if (isLoading) return <Skeleton className="h-64 max-w-2xl" />
@@ -268,8 +266,7 @@ function PrepaidPlan() {
setConfirmTopup(false)
onPurchase(d)
},
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : 'Top-up failed'),
+ onError: (e) => notifyError("Couldn't complete the top-up.", e),
})
const planMutation = useMutation({
mutationFn: (plan: string) => autumnSubscribeConcurrency(plan),
@@ -277,8 +274,7 @@ function PrepaidPlan() {
setConfirmPlanId(null)
onPurchase(d)
},
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : 'Subscription failed'),
+ onError: (e) => notifyError("Couldn't update your subscription.", e),
})
if (isLoading) return <Skeleton className="h-64 max-w-2xl" />
@@ -460,7 +456,7 @@ function AutoTopupCard({
setSaved(true)
setTimeout(() => setSaved(false), 3000)
},
- onError: (e) => toast.error(e instanceof Error ? e.message : 'Save failed'),
+ onError: (e) => notifyError("Couldn't save auto-top-up settings.", e),
})
// Saving only charges when enabling WITHOUT a card on file. Gate that one path.
diff --git a/web/src/pages/Checkpoints.tsx b/web/src/pages/Checkpoints.tsx
index 11115f62..7c3929ac 100644
--- a/web/src/pages/Checkpoints.tsx
+++ b/web/src/pages/Checkpoints.tsx
@@ -1,7 +1,7 @@
import { useMemo, useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { toast } from 'sonner'
import { Layers, CircleAlert } from 'lucide-react'
+import { notifyError } from '@/lib/errors'
import {
deleteCheckpointDashboard,
getCheckpoints,
@@ -12,7 +12,6 @@ import { Panel } from '@/components/panel'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { Checkbox } from '@/components/ui/checkbox'
-import { Label } from '@/components/ui/label'
import { StatusBadge } from '@/components/status-badge'
import { EmptyState } from '@/components/empty-state'
import { ConfirmDialog } from '@/components/confirm-dialog'
@@ -46,10 +45,7 @@ export default function Checkpoints() {
const deleteMutation = useMutation({
mutationFn: (id: string) => deleteCheckpointDashboard(id),
- onError: (error) =>
- toast.error(
- `Delete failed: ${error instanceof Error ? error.message : String(error)}`,
- ),
+ onError: (error) => notifyError("Couldn't delete the checkpoint.", error),
onSettled: () =>
queryClient.invalidateQueries({ queryKey: ['checkpoints'] }),
})
@@ -167,22 +163,21 @@ export default function Checkpoints() {
<PageHeader
title="Checkpoints"
description="Sandbox snapshots across your organization"
+ actions={
+ <label
+ htmlFor="show-failed"
+ className="text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-2 text-sm transition-colors"
+ >
+ <Checkbox
+ id="show-failed"
+ checked={showFailed}
+ onCheckedChange={(v) => setShowFailed(v === true)}
+ />
+ Show failed
+ </label>
+ }
/>
- <div className="mb-3 flex items-center gap-2">
- <Checkbox
- id="show-failed"
- checked={showFailed}
- onCheckedChange={(v) => setShowFailed(v === true)}
- />
- <Label
- htmlFor="show-failed"
- className="text-muted-foreground cursor-pointer text-sm font-normal"
- >
- Show failed checkpoints
- </Label>
- </div>
-
<Panel className="overflow-hidden">
<ResourceTable
columns={columns}
diff --git a/web/src/pages/SessionDetail.tsx b/web/src/pages/SessionDetail.tsx
index 0706f851..cb932aae 100644
--- a/web/src/pages/SessionDetail.tsx
+++ b/web/src/pages/SessionDetail.tsx
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { Link, useNavigate, useParams } from 'react-router-dom'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { toast } from 'sonner'
+import { notifyError } from '@/lib/errors'
import {
ArrowLeft,
List,
@@ -101,28 +101,19 @@ export default function SessionDetail() {
)
setShowTerminal(false)
},
- onError: (e) =>
- toast.error(
- `Delete failed: ${e instanceof Error ? e.message : String(e)}`,
- ),
+ onError: (e) => notifyError("Couldn't delete the sandbox.", e),
onSettled: invalidate,
})
const rebootMutation = useMutation({
mutationFn: () => rebootSession(sandboxId!),
- onError: (e) =>
- toast.error(
- `Reboot failed: ${e instanceof Error ? e.message : String(e)}`,
- ),
+ onError: (e) => notifyError("Couldn't reboot the sandbox.", e),
onSettled: invalidate,
})
const powerCycleMutation = useMutation({
mutationFn: () => powerCycleSession(sandboxId!),
- onError: (e) =>
- toast.error(
- `Power-cycle failed: ${e instanceof Error ? e.message : String(e)}`,
- ),
+ onError: (e) => notifyError("Couldn't power-cycle the sandbox.", e),
onSettled: invalidate,
})
diff --git a/web/src/pages/Sessions.tsx b/web/src/pages/Sessions.tsx
index 248bdbaa..8902fdc5 100644
--- a/web/src/pages/Sessions.tsx
+++ b/web/src/pages/Sessions.tsx
@@ -1,8 +1,8 @@
import { useMemo, useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { Link } from 'react-router-dom'
-import { toast } from 'sonner'
import { Boxes } from 'lucide-react'
+import { notifyError } from '@/lib/errors'
import { deleteSession, getSessions, type Session } from '@/api/client'
import { PageHeader } from '@/components/page-header'
import { Panel } from '@/components/panel'
@@ -55,11 +55,7 @@ export default function Sessions() {
),
)
},
- onError: (error) => {
- toast.error(
- `Delete failed: ${error instanceof Error ? error.message : String(error)}`,
- )
- },
+ onError: (error) => notifyError("Couldn't delete the sandbox.", error),
onSettled: () => {
queryClient.invalidateQueries({ queryKey: ['sessions'] })
},
diff --git a/web/src/pages/Settings.tsx b/web/src/pages/Settings.tsx
index f37034d5..31019c01 100644
--- a/web/src/pages/Settings.tsx
+++ b/web/src/pages/Settings.tsx
@@ -1,6 +1,6 @@
import { useState, type ReactNode } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { toast } from 'sonner'
+import { notifyError } from '@/lib/errors'
import {
deleteCustomDomain,
getInvitations,
@@ -83,7 +83,7 @@ export default function Settings() {
setSaved(true)
setTimeout(() => setSaved(false), 2000)
},
- onError: (e) => toast.error(e instanceof Error ? e.message : 'Save failed'),
+ onError: (e) => notifyError("Couldn't save organization settings.", e),
})
const setDomainMutation = useMutation({
@@ -92,21 +92,18 @@ export default function Settings() {
queryClient.invalidateQueries({ queryKey: ['org'] })
setDomainInput('')
},
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : "Couldn't set domain"),
+ onError: (e) => notifyError("Couldn't set the custom domain.", e),
})
const deleteDomainMutation = useMutation({
mutationFn: () => deleteCustomDomain(),
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : 'Remove failed'),
+ onError: (e) => notifyError("Couldn't remove the custom domain.", e),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['org'] }),
})
const refreshDomainMutation = useMutation({
mutationFn: () => refreshCustomDomain(),
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : 'Refresh failed'),
+ onError: (e) => notifyError("Couldn't refresh domain status.", e),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['org'] }),
})
@@ -345,14 +342,12 @@ function TeamMembers() {
setInviteEmail('')
setShowInvite(false)
},
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : "Couldn't send invite"),
+ onError: (e) => notifyError("Couldn't send the invitation.", e),
})
const removeMutation = useMutation({
mutationFn: (membershipId: string) => removeMember(membershipId),
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : 'Remove failed'),
+ onError: (e) => notifyError("Couldn't remove the member.", e),
onSettled: () =>
queryClient.invalidateQueries({ queryKey: ['org-members'] }),
})
@@ -463,8 +458,7 @@ function PendingInvitations() {
const revokeMutation = useMutation({
mutationFn: (id: string) => revokeInvitation(id),
- onError: (e) =>
- toast.error(e instanceof Error ? e.message : 'Revoke failed'),
+ onError: (e) => notifyError("Couldn't revoke the invitation.", e),
onSettled: () =>
queryClient.invalidateQueries({ queryKey: ['org-invitations'] }),
})
diff --git a/web/src/pages/Templates.tsx b/web/src/pages/Templates.tsx
index 2598d2be..e5b8e505 100644
--- a/web/src/pages/Templates.tsx
+++ b/web/src/pages/Templates.tsx
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { toast } from 'sonner'
import { Package } from 'lucide-react'
+import { notifyError } from '@/lib/errors'
import { deleteImage, getImages, type ImageCacheItem } from '@/api/client'
import { PageHeader } from '@/components/page-header'
import { Panel } from '@/components/panel'
@@ -49,10 +49,7 @@ export default function Templates() {
const deleteMutation = useMutation({
mutationFn: (id: string) => deleteImage(id),
- onError: (error) =>
- toast.error(
- `Delete failed: ${error instanceof Error ? error.message : String(error)}`,
- ),
+ onError: (error) => notifyError("Couldn't delete the template.", error),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['images'] }),
})