The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(settings): remove unused LogoutAndClearActions component
Steven Enamakel3fbbc066aa73
diff --git a/app/src/components/settings/LogoutAndClearActions.tsx b/app/src/components/settings/LogoutAndClearActions.tsxindex e4be4fd9f8..387d736bca 100644--- a/app/src/components/settings/LogoutAndClearActions.tsx+++ b/app/src/components/settings/LogoutAndClearActions.tsx@@ -1,30 +1,46 @@import debug from 'debug';-import { useId, useState } from 'react';+import { LogOut, Trash2 } from 'lucide-react';+import { useState } from 'react';import { useT } from '../../lib/i18n/I18nContext';import { useCoreState } from '../../providers/CoreStateProvider';import { clearAllAppData } from '../../utils/clearAllAppData';-import Button from '../ui/Button';+import {+ Alert,+ AlertDescription,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogRoot,+ AlertDialogTitle,+ Button,+ Card,+ Field,+} from '../ui';import { Spinner } from '../ui/icons';-import { ModalShell } from '../ui/ModalShell';-import SettingsMenuItem from './components/SettingsMenuItem';const warnLog = debug('settings:account:warn');/**- * Destructive account actions: Log out, and Log out + clear all app data.- * Lives at the bottom of the Settings → Account page. Owns its own modal- * state and confirmation flow so the parent page is just a list + this row.+ * The bottom of Settings → Account: a Session card (routine, reversible log+ * out) and a separate Danger zone card for wiping local data. The two are kept+ * apart on purpose — same weight and colour one row apart made an irreversible+ * wipe read like a sign-out. The wipe sits behind an `AlertDialog`, which does+ * not dismiss on an outside click.*/const LogoutAndClearActions = () => {const { t } = useT();const { clearSession, snapshot } = useCoreState();- const [showLogoutAndClearModal, setShowLogoutAndClearModal] = useState(false);- const [isLoading, setIsLoading] = useState(false);+ const [confirmOpen, setConfirmOpen] = useState(false);+ const [isLoggingOut, setIsLoggingOut] = useState(false);+ const [isClearing, setIsClearing] = useState(false);const [error, setError] = useState<string | null>(null);- const modalTitleId = useId();const handleLogout = async () => {+ setError(null);+ setIsLoggingOut(true);try {await clearSession();} catch (err) {@@ -33,166 +49,118 @@ const LogoutAndClearActions = () => {const reason = err instanceof Error ? err.message : String(err);warnLog('logout_failed %o', { reason });setError(t('clearData.failedLogout'));+ } finally {+ setIsLoggingOut(false);}};- const handleLogoutAndClearData = async () => {+ const handleClearData = async () => {+ setIsClearing(true);+ setError(null);try {- setIsLoading(true);- setError(null);const currentUserId = snapshot.auth.userId ?? snapshot.currentUser?._id ?? null;await clearAllAppData({ clearSession, userId: currentUserId }); // restarts the app} catch (err) {const message = err instanceof Error ? err.message : String(err);setError(message || t('clearData.failed'));} finally {- setIsLoading(false);+ setIsClearing(false);}};- // Two actions, two glyphs. They shared one arrow-out icon, which is most of- // why an irreversible wipe and a routine sign-out read as the same control.- const signOutIcon = (- <svg className="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path- strokeLinecap="round"- strokeLinejoin="round"- strokeWidth={2}- d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"- />- </svg>- );-- const eraseIcon = (- <svg className="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path- strokeLinecap="round"- strokeLinejoin="round"- strokeWidth={2}- d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"- />- </svg>- );+ const closeConfirm = (open: boolean) => {+ if (isClearing) return;+ setConfirmOpen(open);+ if (!open) setError(null);+ };- // Inline error is only displayed below the row when the clear-data modal is- // closed — when the modal is open, it owns the error display. Without this- // surface, a `handleLogout` failure would set `error` but the user would- // never see it.- const showInlineError = error !== null && !showLogoutAndClearModal;+ const errorAlert = (testId?: string) =>+ error && (+ <Alert variant="destructive" density="compact" data-testid={testId}>+ <AlertDescription>{error}</AlertDescription>+ </Alert>+ );return (- <div>- {/* Log out is routine and reversible, so it reads as an ordinary row.- It was `dangerous` and amber, identical to the wipe below it. */}- <SettingsMenuItem- icon={signOutIcon}- title={t('settings.logOut')}- description={t('settings.logOutDesc')}- onClick={handleLogout}- testId="settings-nav-logout"- isFirst- isLast- />+ <>+ <Card title={t('settings.account.session')}>+ <Field+ label={t('settings.logOut')}+ description={t('settings.logOutDesc')}+ control={+ <Button+ variant="secondary"+ size="sm"+ leadingIcon={+ isLoggingOut ? <Spinner /> : <LogOut className="h-3.5 w-3.5" aria-hidden />+ }+ disabled={isLoggingOut}+ onClick={() => void handleLogout()}+ data-testid="settings-nav-logout">+ {t('settings.logOut')}+ </Button>+ }+ />+ {/* The confirm dialog owns error display while it is open. */}+ {!confirmOpen && error && <div className="px-4 py-3">{errorAlert('logout-error')}</div>}+ </Card>- {/* Clearing app data is not a peer of logging out, so it stops being a- row in the same menu. Separating it is the fix: the two were the same- amber, the same weight and the same icon, one row apart, and amber is- this app's WARNING ramp -- coral is the destructive one. Placement,- ramp, glyph and an explicit consequence line now all say the same- thing, and the action sits behind a confirm. */}- <section- className="mt-5 rounded-xl border border-coral-500/30 bg-coral-500/[0.06] p-4"+ <Card+ title={t('settings.account.dangerZone')}+ className="border-coral-500/30"data-testid="account-destructive-zone">- <div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">- <div className="max-w-[52ch]">- <h3 className="font-title text-sm font-semibold text-content">- {t('settings.clearAppData')}- </h3>- <p className="mt-1 text-xs leading-relaxed text-content-muted">- {t('settings.clearAppDataDesc')}- </p>- <p className="mt-1 text-xs font-medium text-coral-600 dark:text-coral-300">- {t('settings.clearAppDataIrreversible')}- </p>- </div>- <Button- variant="secondary"- tone="danger"- size="sm"- leadingIcon={eraseIcon}- onClick={() => setShowLogoutAndClearModal(true)}- data-testid="settings-nav-logout-and-clear"- className="shrink-0">- {t('settings.clearAppDataAction')}- </Button>- </div>- </section>-- {showInlineError && (- <div- role="alert"- data-testid="logout-error"- className="mt-3 mx-1 p-3 rounded-lg bg-coral-100 dark:bg-coral-500/20 border border-coral-500/20">- <p className="text-coral-600 dark:text-coral-300 text-sm">{error}</p>- </div>- )}-- {showLogoutAndClearModal && (- <ModalShell- title={t('clearData.title')}- titleId={modalTitleId}- icon={eraseIcon}- onClose={() => {- setShowLogoutAndClearModal(false);- setError(null);- }}- contentClassName="px-6 py-5"- closePolicy={isLoading ? { escape: false, backdrop: false, button: false } : undefined}- footer={- <div className="flex gap-3">- <Button- variant="secondary"- onClick={() => {- setShowLogoutAndClearModal(false);- setError(null);- }}- disabled={isLoading}- className="flex-1">- {t('common.cancel')}- </Button>- {/* Was an amber wash painted over `variant="tertiary"`, which- bypassed the danger tone entirely and used the warning ramp- for the most destructive confirm in the app. */}- <Button- variant="primary"- tone="danger"- onClick={handleLogoutAndClearData}- disabled={isLoading}- leadingIcon={isLoading ? <Spinner /> : undefined}- className="flex-1">- {isLoading ? t('clearData.clearing') : t('clearData.title')}- </Button>- </div>- }>- <div className="text-content-secondary text-sm leading-relaxed">- <p>{t('clearData.warning')}</p>- <ul className="list-disc pl-5 mt-2 space-y-1">- <li>{t('clearData.bulletSettings')}</li>- <li>{t('clearData.bulletCache')}</li>- <li>{t('clearData.bulletWorkspace')}</li>- <li>{t('clearData.bulletOther')}</li>- </ul>- <p className="mt-3">{t('clearData.irreversible')}</p>- </div>+ <Field+ label={t('settings.clearAppData')}+ description={`${t('settings.clearAppDataDesc')} ${t('settings.clearAppDataIrreversible')}`}+ control={+ <Button+ variant="secondary"+ tone="danger"+ size="sm"+ leadingIcon={<Trash2 className="h-3.5 w-3.5" aria-hidden />}+ onClick={() => setConfirmOpen(true)}+ data-testid="settings-nav-logout-and-clear">+ {t('settings.clearAppDataAction')}+ </Button>+ }+ />+ </Card>- {error && (- <div className="mt-3 p-3 rounded-lg bg-coral-100 dark:bg-coral-500/20 border border-coral-500/20">- <p className="text-coral-600 dark:text-coral-300 text-sm">{error}</p>+ <AlertDialogRoot open={confirmOpen} onOpenChange={closeConfirm}>+ <AlertDialogContent className="max-w-md">+ <AlertDialogTitle>{t('clearData.title')}</AlertDialogTitle>+ <AlertDialogDescription asChild>+ <div className="space-y-3 leading-relaxed">+ <p>{t('clearData.warning')}</p>+ <ul className="list-disc space-y-1 pl-5">+ <li>{t('clearData.bulletSettings')}</li>+ <li>{t('clearData.bulletCache')}</li>+ <li>{t('clearData.bulletWorkspace')}</li>+ <li>{t('clearData.bulletOther')}</li>+ </ul>+ <p className="font-medium text-coral-600 dark:text-coral-300">+ {t('clearData.irreversible')}+ </p></div>- )}- </ModalShell>- )}- </div>+ </AlertDialogDescription>+ {error && <div className="mt-4">{errorAlert()}</div>}+ <AlertDialogFooter>+ <AlertDialogCancel disabled={isClearing}>{t('common.cancel')}</AlertDialogCancel>+ <AlertDialogAction+ disabled={isClearing}+ onClick={event => {+ // Keep the dialog open while clearing so progress and any+ // failure stay visible; success restarts the app.+ event.preventDefault();+ void handleClearData();+ }}>+ {isClearing && <Spinner />}+ {isClearing ? t('clearData.clearing') : t('clearData.title')}+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialogRoot>+ </>);};