diff --git a/apps/web/src/components/MemorySection.tsx b/apps/web/src/components/MemorySection.tsx index 5284a439b3..fc19a6dc45 100644 --- a/apps/web/src/components/MemorySection.tsx +++ b/apps/web/src/components/MemorySection.tsx @@ -1364,6 +1364,7 @@ export function MemorySection({ }, [indexDraft, fireFlash]); const onDeleteExtraction = useCallback(async (id: string) => { + if (!window.confirm(t('settings.memoryExtractionDeleteConfirm'))) return; // Optimistic removal: drop the row immediately so the click feels // instant. The SSE 'deleted' event will arrive moments later and is // a no-op against an already-removed id; if the request fails we @@ -1373,7 +1374,7 @@ export function MemorySection({ if (!ok) { void reloadExtractions(); } - }, [reloadExtractions]); + }, [reloadExtractions, t]); const onClearExtractions = useCallback(async () => { if (!window.confirm(t('settings.memoryExtractionsClearConfirm'))) return; diff --git a/apps/web/src/i18n/locales/en.ts b/apps/web/src/i18n/locales/en.ts index e386d8a490..19f390120e 100644 --- a/apps/web/src/i18n/locales/en.ts +++ b/apps/web/src/i18n/locales/en.ts @@ -2148,6 +2148,8 @@ export const en: Dict = { 'settings.memoryExtractionWritten': 'written', 'settings.memoryExtractionDuration': 'in', 'settings.memoryExtractionDelete': 'Delete', + 'settings.memoryExtractionDeleteConfirm': + 'Delete this extraction record? This cannot be undone.', 'settings.memoryExtractionsClear': 'Clear', 'settings.memoryExtractionsClearTitle': 'Clear all extraction history', 'settings.memoryExtractionsClearConfirm': diff --git a/apps/web/src/i18n/locales/zh-CN.ts b/apps/web/src/i18n/locales/zh-CN.ts index 917825ef7e..0e171ed9fb 100644 --- a/apps/web/src/i18n/locales/zh-CN.ts +++ b/apps/web/src/i18n/locales/zh-CN.ts @@ -2114,6 +2114,7 @@ export const zhCN: Dict = { 'settings.memoryExtractionWritten': '写入', 'settings.memoryExtractionDuration': '耗时', 'settings.memoryExtractionDelete': '删除', + 'settings.memoryExtractionDeleteConfirm': '确定要删除此抽取记录吗?此操作无法撤销。', 'settings.memoryExtractionsClear': '清空', 'settings.memoryExtractionsClearTitle': '清空整个抽取历史', 'settings.memoryExtractionsClearConfirm': '确定要清空整个抽取历史吗?此操作无法撤销。', diff --git a/apps/web/src/i18n/types.ts b/apps/web/src/i18n/types.ts index a4e16005dc..a7e93f85b2 100644 --- a/apps/web/src/i18n/types.ts +++ b/apps/web/src/i18n/types.ts @@ -564,6 +564,7 @@ export interface Dict { 'settings.memoryExtractionWritten': string; 'settings.memoryExtractionDuration': string; 'settings.memoryExtractionDelete': string; + 'settings.memoryExtractionDeleteConfirm': string; 'settings.memoryExtractionsClear': string; 'settings.memoryExtractionsClearTitle': string; 'settings.memoryExtractionsClearConfirm': string; diff --git a/apps/web/tests/components/MemorySection.test.tsx b/apps/web/tests/components/MemorySection.test.tsx index f9acaec506..1b9a229bfc 100644 --- a/apps/web/tests/components/MemorySection.test.tsx +++ b/apps/web/tests/components/MemorySection.test.tsx @@ -1475,6 +1475,11 @@ describe('MemorySection', () => { .closest('.library-card') as HTMLElement; fireEvent.click(within(row).getByRole('button', { name: 'Delete' })); + // Confirm the deletion in the dialog + const dialog = await screen.findByRole('dialog'); + const confirmButton = within(dialog).getByRole('button', { name: 'Delete' }); + fireEvent.click(confirmButton); + await waitFor(() => { expect(screen.queryByText('Remember I prefer dark mode')).toBeNull(); });