Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat: replace browser confirms with destructive dialogs (#795)

Bharadwajjjjjbbd58a511d50
diff --git a/web/messages/en.json b/web/messages/en.json
index 81f10cd5e..b5f2a73da 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -544,6 +544,7 @@
"generated": "Report generated",
"generateFailed": "Report generation failed. Please try again.",
"generating": "Generating…",
+ "deleteTitle": "Delete report",
"deleteConfirm": "Delete this report?",
"deleteFailed": "Failed to delete report",
"selectDates": "Pick a start and end date",
@@ -738,6 +739,11 @@
"contactUs": "Contact Us",
"integrations": "Integrations",
"agent": "Agent",
+ "revokeApiKey": "Revoke API key",
+ "revokeApiKeyConfirm": "Revoke this API key? Clients using it will lose access immediately.",
+ "revoke": "Revoke",
+ "agent_removeKeyConfirm": "Remove the Anthropic API key? Team members will lose access to the agent until a new key is saved.",
+ "remove": "Remove",
"apiKeys_description": "Long-lived tokens for the Ansvisor MCP server and other external clients. Keys are shown once at creation — store them somewhere safe.",
"apiKeys_mcpEndpoint": "MCP endpoint",
"apiKeys_mcpEndpointHint": "Paste this URL + a key below into Claude Desktop / Claude Code / Cursor. See the <link>MCP guide</link>.",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx
index d80156c13..045f0facf 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx
@@ -35,6 +35,15 @@ import {
ChevronDown,
KeyRound,
} from 'lucide-react';
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
interface ConversationRow {
id: string;
@@ -136,6 +145,8 @@ function AgentChat(props: {
messagesEndRef,
} = props;
const t = useTranslations('agent');
+ const tc = useTranslations('common');
+ const [pendingConfirm, setPendingConfirm] = useState<string | null>(null);
// Ref mirrors activeId for prepareSendMessagesRequest. Reading the
// state directly from the transport closure gives us a stale snapshot —
@@ -254,7 +265,6 @@ function AgentChat(props: {
}
async function deleteConversation(id: string) {
- if (!confirm(t('deleteConfirm'))) return;
const res = await fetch(`/api/agent/conversations/${id}`, { method: 'DELETE' });
if (!res.ok) {
const body = await res.json().catch(() => null);
@@ -346,7 +356,7 @@ function AgentChat(props: {
type="button"
onClick={(e) => {
e.stopPropagation();
- void deleteConversation(c.id);
+ setPendingConfirm(c.id);
}}
className="opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-opacity"
aria-label={t('deleteConversation')}
@@ -355,6 +365,37 @@ function AgentChat(props: {
</button>
</div>
))}
+ <Dialog
+ open={pendingConfirm !== null}
+ onOpenChange={(v) => !v && setPendingConfirm(null)}
+ >
+ <DialogContent className="sm:max-w-sm">
+ <DialogHeader>
+ <DialogTitle>{t('deleteConversation')}</DialogTitle>
+ <DialogDescription>{t('deleteConfirm')}</DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" />}>{tc('cancel')}</DialogClose>
+ <DialogClose
+ render={
+ <Button
+ variant="destructive"
+ onClick={(e) => {
+ e.stopPropagation();
+
+ if (pendingConfirm === null) {
+ return;
+ }
+ void deleteConversation(pendingConfirm);
+ }}
+ />
+ }
+ >
+ {tc('delete')}
+ </DialogClose>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
</div>
</aside>
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/reports/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/reports/page.tsx
index 11daa825e..e052b2280 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/reports/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/reports/page.tsx
@@ -14,6 +14,7 @@ import {
DialogContent,
DialogDescription,
DialogFooter,
+ DialogClose,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
@@ -80,6 +81,7 @@ export default function ReportsPage() {
const [dialogOpen, setDialogOpen] = useState(false);
const [generating, setGenerating] = useState(false);
const [deletingId, setDeletingId] = useState<string | null>(null);
+ const [pendingConfirm, setPendingConfirm] = useState<string | null>(null);
const [template, setTemplate] = useState<ReportTemplateId>('executive_summary');
const [preset, setPreset] = useState<DatePreset>('30d');
@@ -174,11 +176,11 @@ export default function ReportsPage() {
};
const handleDelete = async (id: string) => {
- if (!confirm(t('deleteConfirm'))) return;
setDeletingId(id);
try {
await deleteReport(id);
setReports((prev) => prev.filter((r) => r.id !== id));
+ setPendingConfirm(null);
} catch (err) {
console.error('Report delete error:', err);
toast.error(t('deleteFailed'));
@@ -216,61 +218,96 @@ export default function ReportsPage() {
<p className="text-sm text-muted-foreground">{t('emptyLibrary')}</p>
</div>
) : (
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>{t('columns.title')}</TableHead>
- <TableHead>{t('columns.period')}</TableHead>
- <TableHead>{t('columns.created')}</TableHead>
- <TableHead className="w-[140px] text-right">{t('columns.actions')}</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {reports.map((report) => (
- <TableRow key={report.id}>
- <TableCell>
- <span className="font-medium">{report.title}</span>
- {KNOWN_TEMPLATE_IDS.has(report.template) &&
- t.has(`templates.${report.template}.name`) && (
- <span className="mt-0.5 block text-xs text-muted-foreground">
- {t(`templates.${report.template}.name`)}
- </span>
- )}
- </TableCell>
- <TableCell className="text-muted-foreground">
- {formatDate(report.dateFrom)} — {formatDate(report.dateTo)}
- </TableCell>
- <TableCell className="text-muted-foreground">
- {formatDate(report.createdAt)}
- </TableCell>
- <TableCell className="text-right">
- <div className="flex items-center justify-end gap-1">
- <Button
- size="sm"
- variant="outline"
- onClick={() => router.push(`/dashboard/reports/${report.id}`)}
- >
- {tc('view')}
- </Button>
- <Button
- size="sm"
- variant="ghost"
- className="text-muted-foreground hover:text-destructive"
- disabled={deletingId === report.id}
- onClick={() => handleDelete(report.id)}
- >
- {deletingId === report.id ? (
- <Loader2 className="h-4 w-4 animate-spin" />
- ) : (
- <Trash2 className="h-4 w-4" />
- )}
- </Button>
- </div>
- </TableCell>
+ <>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>{t('columns.title')}</TableHead>
+ <TableHead>{t('columns.period')}</TableHead>
+ <TableHead>{t('columns.created')}</TableHead>
+ <TableHead className="w-[140px] text-right">{t('columns.actions')}</TableHead>
</TableRow>
- ))}
- </TableBody>
- </Table>
+ </TableHeader>
+ <TableBody>
+ {reports.map((report) => (
+ <TableRow key={report.id}>
+ <TableCell>
+ <span className="font-medium">{report.title}</span>
+ {KNOWN_TEMPLATE_IDS.has(report.template) &&
+ t.has(`templates.${report.template}.name`) && (
+ <span className="mt-0.5 block text-xs text-muted-foreground">
+ {t(`templates.${report.template}.name`)}
+ </span>
+ )}
+ </TableCell>
+ <TableCell className="text-muted-foreground">
+ {formatDate(report.dateFrom)} — {formatDate(report.dateTo)}
+ </TableCell>
+ <TableCell className="text-muted-foreground">
+ {formatDate(report.createdAt)}
+ </TableCell>
+ <TableCell className="text-right">
+ <div className="flex items-center justify-end gap-1">
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => router.push(`/dashboard/reports/${report.id}`)}
+ >
+ {tc('view')}
+ </Button>
+ <Button
+ size="sm"
+ variant="ghost"
+ className="text-muted-foreground hover:text-destructive"
+ disabled={deletingId === report.id}
+ onClick={() => setPendingConfirm(report.id)}
+ >
+ {deletingId === report.id ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
+ ) : (
+ <Trash2 className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ <Dialog
+ open={pendingConfirm !== null}
+ onOpenChange={(v) => !v && setPendingConfirm(null)}
+ >
+ <DialogContent className="sm:max-w-sm">
+ <DialogHeader>
+ <DialogTitle>{t('deleteTitle')}</DialogTitle>
+ <DialogDescription>{t('deleteConfirm')}</DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" />}>{tc('cancel')}</DialogClose>
+ <Button
+ type="button"
+ variant="destructive"
+ disabled={deletingId === pendingConfirm}
+ onClick={(e) => {
+ e.stopPropagation();
+
+ if (pendingConfirm === null) {
+ return;
+ }
+
+ void handleDelete(pendingConfirm);
+ }}
+ >
+ {deletingId === pendingConfirm && (
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ )}
+ {tc('delete')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </>
)}
</CardContent>
</Card>
diff --git a/web/src/components/settings/agent-section.tsx b/web/src/components/settings/agent-section.tsx
index f7fcd3bda..1cc115474 100644
--- a/web/src/components/settings/agent-section.tsx
+++ b/web/src/components/settings/agent-section.tsx
@@ -11,6 +11,15 @@ import { Skeleton } from '@/components/ui/skeleton';
import { Loader2, Lock, Sparkles, Trash2, CheckCircle2 } from 'lucide-react';
import { useTranslations } from 'next-intl';
import { useUserRole } from '@/hooks/use-user-role';
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
interface KeyState {
configured: boolean;
@@ -48,6 +57,7 @@ export function AgentSection() {
const [saving, setSaving] = useState(false);
const [clearing, setClearing] = useState(false);
const { canAdmin } = useUserRole();
+ const [confirmClear, setConfirmClear] = useState(false);
const load = useCallback(async () => {
setLoading(true);
@@ -95,13 +105,6 @@ export function AgentSection() {
};
const handleClear = async () => {
- if (
- !confirm(
- 'Remove the Anthropic API key? Team members will lose access to the agent until a new key is saved.',
- )
- ) {
- return;
- }
setClearing(true);
try {
const res = await fetch('/api/settings/anthropic-key', { method: 'DELETE' });
@@ -113,6 +116,7 @@ export function AgentSection() {
toast.error(err instanceof Error ? err.message : 'Failed to clear');
} finally {
setClearing(false);
+ setConfirmClear(false);
}
};
@@ -195,7 +199,7 @@ export function AgentSection() {
<Button
variant="outline"
size="sm"
- onClick={handleClear}
+ onClick={() => setConfirmClear(true)}
disabled={clearing}
className="text-destructive hover:text-destructive"
>
@@ -206,6 +210,33 @@ export function AgentSection() {
)}
{t('agent_removeKey')}
</Button>
+ <Dialog open={confirmClear} onOpenChange={setConfirmClear}>
+ <DialogContent className="sm:max-w-sm">
+ <DialogHeader>
+ <DialogTitle>{t('agent_removeKey')}</DialogTitle>
+ <DialogDescription>{t('agent_removeKeyConfirm')}</DialogDescription>
+ </DialogHeader>
+
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" />}>
+ {tCommon('cancel')}
+ </DialogClose>
+
+ <Button
+ type="button"
+ variant="destructive"
+ disabled={clearing}
+ onClick={(e) => {
+ e.stopPropagation();
+ void handleClear();
+ }}
+ >
+ {clearing && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
+ {t('remove')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
</div>
)}
</>
diff --git a/web/src/components/settings/api-keys-section.tsx b/web/src/components/settings/api-keys-section.tsx
index 2ff5be792..939d6e95d 100644
--- a/web/src/components/settings/api-keys-section.tsx
+++ b/web/src/components/settings/api-keys-section.tsx
@@ -55,6 +55,7 @@ export function ApiKeysSection() {
const [creating, setCreating] = useState(false);
const [revealedToken, setRevealedToken] = useState<string | null>(null);
const mcpEndpoint = getMcpEndpoint();
+ const [confirmRevoke, setConfirmRevoke] = useState<string | null>(null);
const load = useCallback(async () => {
setLoading(true);
@@ -100,9 +101,6 @@ export function ApiKeysSection() {
};
const handleRevoke = async (id: string) => {
- if (!confirm('Revoke this API key? Clients using it will lose access immediately.')) {
- return;
- }
try {
const res = await fetch(`/api/keys/${id}`, { method: 'DELETE' });
if (!res.ok) {
@@ -176,42 +174,77 @@ export function ApiKeysSection() {
) : keys.length === 0 ? (
<p className="text-sm text-muted-foreground py-6 text-center">{t('apiKeys_noKeys')}</p>
) : (
- <div className="divide-y rounded-md border">
- {keys.map((k) => {
- const revoked = !!k.revoked_at;
- return (
- <div key={k.id} className="flex items-center justify-between gap-4 p-3">
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <p className="text-sm font-medium truncate">{k.name}</p>
- {revoked && (
- <Badge variant="outline" className="text-[10px]">
- {t('apiKeys_revoked')}
- </Badge>
- )}
+ <>
+ <div className="divide-y rounded-md border">
+ {keys.map((k) => {
+ const revoked = !!k.revoked_at;
+ return (
+ <div key={k.id} className="flex items-center justify-between gap-4 p-3">
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <p className="text-sm font-medium truncate">{k.name}</p>
+ {revoked && (
+ <Badge variant="outline" className="text-[10px]">
+ {t('apiKeys_revoked')}
+ </Badge>
+ )}
+ </div>
+ <p className="text-xs text-muted-foreground font-mono">{k.prefix}…</p>
+ <p className="text-[11px] text-muted-foreground">
+ {t('apiKeys_created', {
+ date: formatDate(k.created_at),
+ lastUsed: formatDate(k.last_used_at),
+ })}
+ </p>
</div>
- <p className="text-xs text-muted-foreground font-mono">{k.prefix}…</p>
- <p className="text-[11px] text-muted-foreground">
- {t('apiKeys_created', {
- date: formatDate(k.created_at),
- lastUsed: formatDate(k.last_used_at),
- })}
- </p>
+ {!revoked && (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => setConfirmRevoke(k.id)}
+ className="text-destructive hover:text-destructive"
+ >
+ <Trash2 className="h-4 w-4" />
+ </Button>
+ )}
</div>
- {!revoked && (
- <Button
- variant="ghost"
- size="sm"
- onClick={() => handleRevoke(k.id)}
- className="text-destructive hover:text-destructive"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- )}
- </div>
- );
- })}
- </div>
+ );
+ })}
+ </div>
+ <Dialog
+ open={confirmRevoke !== null}
+ onOpenChange={(v) => !v && setConfirmRevoke(null)}
+ >
+ <DialogContent className="sm:max-w-sm">
+ <DialogHeader>
+ <DialogTitle>{t('revokeApiKey')}</DialogTitle>
+ <DialogDescription>{t('revokeApiKeyConfirm')}</DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" />}>
+ {tCommon('cancel')}
+ </DialogClose>
+ <DialogClose
+ render={
+ <Button
+ variant="destructive"
+ onClick={(e) => {
+ e.stopPropagation();
+
+ if (confirmRevoke === null) {
+ return;
+ }
+ void handleRevoke(confirmRevoke);
+ }}
+ />
+ }
+ >
+ {t('revoke')}
+ </DialogClose>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </>
)}
</CardContent>