Repository navigation
Conversation
gkhngyk
left a comment
There was a problem hiding this comment.
Good approach — one shared dialog per list instead of one per row is the right call, and all four confirm() call sites are gone with no path left unconfirmed (deleteConversation, handleDelete and handleClear each have exactly one caller now).
One thing blocks merge.
cancel doesn't exist in these namespaces
All four dialogs call t('cancel'), but t is bound to agent, reports and settings — and cancel only lives in common:
namespaces with cancel: common, audit, content, competitors
namespaces without: agent, reports, settings, + 12 more
src/i18n/request.ts sets no getMessageFallback, so next-intl's default applies and each button renders the key path instead of the word: agent.cancel, reports.cancel, settings.cancel, with a MISSING_MESSAGE error in the console.
Three of the four files already bind a common translator a line or two away:
| File | Already in the file | This PR |
|---|---|---|
settings/api-keys-section.tsx |
tCommon('cancel') (L268) |
t('cancel') (L224) |
dashboard/reports/page.tsx |
tc('cancel') (L473) |
t('cancel') (L286) |
settings/agent-section.tsx |
tCommon bound at L53 |
t('cancel') (L220) |
dashboard/agent/page.tsx |
— | t('cancel') (L377), needs a useTranslations('common') |
yarn typecheck can't catch this: the project doesn't declare next-intl's IntlMessages augmentation, so message keys aren't checked at build time.
Also worth fixing
The Anthropic key warning lost its point. It read "Remove the Anthropic API key? Team members will lose access to the agent until a new key is saved."; settings.agent_removeKeyConfirm now says "The agent will no longer be able to use it." The key is organization-wide, so the team-impact sentence is the part that made it a warning — please keep it.
reports.delete duplicates common.delete. That file already binds tc, so tc('delete') covers it without a new key. (settings.remove and settings.revoke are fine — common has neither.)
Optional
- The destructive button is wrapped in
DialogClose, so the dialog dismisses before the request resolves. That makes thedisabled={clearing}anddisabled={deletingId === pendingConfirm}props you added unreachable, and a failed delete surfaces only as a toast.dashboard/competitors/page.tsx(L1403–1428) keeps its confirm dialog open with a spinner instead — worth matching. - In the agent dialog the title and the confirm button are the same string ("Delete conversation"). Reports gets this right: "Delete Report" as the title, "Delete" on the button.
agent/page.tsx: the Dialog import block landed belowconst AgentChart = dynamic(...), splitting the imports.Delete Report/Revoke API Key— most titles inen.jsonare sentence case ("Reset your password", "No competitors yet", "Remove {name}?").
gkhngyk
left a comment
There was a problem hiding this comment.
Everything from the last round is in — the four cancel lookups, the restored key-removal warning, the dropped reports.delete, the titles, the import placement. Thanks.
The fix introduced one new thing.
handleClear no longer resets confirmClear
In settings/agent-section.tsx the confirm button stopped being a DialogClose, so nothing sets confirmClear back to false any more — and handleClear doesn't either.
It's hidden right now because the dialog sits inside {configured && (…)}: a successful clear flips configured to false and unmounts the whole block, so the dialog disappears. But the state stays true.
- Remove the key → confirm → success.
confirmClearis stilltrue. - Paste a new key on the same page and hit Save.
handleSave→load()→configuredis true again → the block remounts →<Dialog open={confirmClear}>→ the "Remove key" confirmation opens by itself, right after the key was saved.
No reload involved, it's all client state. setConfirmClear(false) in handleClear's finally covers it — reports/page.tsx already does the equivalent with setPendingConfirm(null).
Non-blocking
The destructive button in dashboard/agent/page.tsx and settings/api-keys-section.tsx is still wrapped in DialogClose, so two of the four dialogs close instantly and two now wait with a spinner. Both behave correctly; worth settling on one if you want them uniform.
Fix the first one and this is good to merge.
gkhngyk
left a comment
There was a problem hiding this comment.
45cf84b closes it. setConfirmClear(false) in the finally is the right spot — it covers the failure path too, which matches how the dialog behaved before this PR.
Re-checked the whole thing at head:
- No native
confirm()oralert()left anywhere inweb/src— all four call sites converted. - All four Cancel buttons resolve through
common, and every new message key is referenced exactly once. No dead entries, andreports.deleteis gone in favour ofcommon.delete. - The two dialogs that still close via
DialogClosereset their state throughonOpenChange, so none of the four can be left holding a staleopen.
CI is green including the production build. Approving — thanks for staying with it through three rounds.
Summary
Replaced the browser's native
confirm()dialogs for destructive actions with the existingDialogpattern used across the dashboard.This updates confirmation flows for:
The new dialogs use the application's styling and translations, with explicit Cancel and destructive confirmation actions. Shared dialogs are used for list-based actions so we don't render one dialog per row.
Related issue
Closes #756
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsChecklist
feature/,fix/,chore/,docs/) — see https://github.com/ansvisor/ansvisor/blob/main/CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)