feat: Add remove account button to health page UI

This commit is contained in:
Lukas May
2026-03-03 12:08:48 +01:00
parent 86c6ad8be1
commit 2f2ad6eb95
2 changed files with 39 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import { CheckCircle2, XCircle, AlertTriangle } from "lucide-react";
import { CheckCircle2, XCircle, AlertTriangle, Trash2 } from "lucide-react";
import { Card, CardContent } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
function formatResetTime(isoDate: string): string {
const now = Date.now();
@@ -92,7 +93,13 @@ export type AccountData = {
activeAgentCount: number;
};
export function AccountCard({ account }: { account: AccountData }) {
export function AccountCard({
account,
onDelete,
}: {
account: AccountData;
onDelete?: (e: React.MouseEvent) => void;
}) {
const hasWarning = account.credentialsValid && !account.isExhausted && account.error;
const statusIcon = !account.credentialsValid ? (
@@ -140,6 +147,16 @@ export function AccountCard({ account }: { account: AccountData }) {
<span>{statusText}</span>
</div>
</div>
{onDelete && (
<Button
variant="ghost"
size="icon"
className="shrink-0 text-muted-foreground hover:text-destructive"
onClick={onDelete}
>
<Trash2 className="h-4 w-4" />
</Button>
)}
</div>
{/* Usage bars */}

View File

@@ -5,6 +5,7 @@ import {
RefreshCw,
Server,
} from 'lucide-react'
import { toast } from 'sonner'
import { trpc } from '@/lib/trpc'
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'
import { Button } from '@/components/ui/button'
@@ -30,9 +31,19 @@ function formatUptime(seconds: number): string {
}
function HealthCheckPage() {
const utils = trpc.useUtils()
const healthQuery = trpc.systemHealthCheck.useQuery(undefined, {
refetchInterval: 30_000,
})
const removeAccount = trpc.removeAccount.useMutation({
onSuccess: () => {
void utils.systemHealthCheck.invalidate()
toast.success('Account removed')
},
onError: (err) => {
toast.error(`Failed to remove account: ${err.message}`)
},
})
const { data, isLoading, isError, error, refetch } = healthQuery
@@ -128,7 +139,15 @@ function HealthCheckPage() {
</Card>
) : (
accounts.map((account) => (
<AccountCard key={account.id} account={account} />
<AccountCard
key={account.id}
account={account}
onDelete={(e) => {
if (e.shiftKey || window.confirm(`Remove account "${account.email}"?`)) {
removeAccount.mutate({ id: account.id })
}
}}
/>
))
)}
</div>