From dbb8c95905adec873177fa4952c5db52fc564b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Tue, 12 May 2026 17:49:51 +0800 Subject: [PATCH] Simplify batch cleanup to explicit selection only The age-based quick cleanup buttons overlapped poorly with the sidebar time groups and created ambiguity around what would be deleted. Keeping batch mode focused on all/selected sessions makes the destructive path easier to understand while preserving the existing confirmation and server deletion behavior. Constraint: Desktop batch deletion should stay routed through the existing selected-session confirmation flow. Rejected: Rename the age-based cleanup buttons | still leaves a low-value destructive shortcut in the primary batch panel. Confidence: high Scope-risk: narrow Directive: Add future destructive cleanup shortcuts only when their target set is unambiguous in the current filtered session list. Tested: cd desktop && bun run test src/components/layout/Sidebar.test.tsx Tested: bun run check:desktop Tested: git diff --check Not-tested: Manual desktop click-through after removing the buttons. --- .../src/components/layout/Sidebar.test.tsx | 2 -- desktop/src/components/layout/Sidebar.tsx | 29 ------------------- desktop/src/i18n/locales/en.ts | 2 -- desktop/src/i18n/locales/zh.ts | 2 -- 4 files changed, 35 deletions(-) diff --git a/desktop/src/components/layout/Sidebar.test.tsx b/desktop/src/components/layout/Sidebar.test.tsx index 9e831ba0..791d7064 100644 --- a/desktop/src/components/layout/Sidebar.test.tsx +++ b/desktop/src/components/layout/Sidebar.test.tsx @@ -37,8 +37,6 @@ vi.mock('../../i18n', () => ({ 'sidebar.batchDeleteConfirm': 'Delete {count} sessions? This cannot be undone.', 'sidebar.batchDeleteConfirmBody': 'The following sessions will be deleted:', 'sidebar.batchDeleteMore': '...and {count} more', - 'sidebar.batchClearOlderThan30': 'Clear >30d', - 'sidebar.batchClearOlderThan7': 'Clear >7d', 'sidebar.batchExit': 'Cancel batch mode', 'sidebar.batchDeleteSucceeded': 'Deleted {count} sessions.', 'sidebar.batchDeleteFailed': '{count} sessions could not be deleted.', diff --git a/desktop/src/components/layout/Sidebar.tsx b/desktop/src/components/layout/Sidebar.tsx index b370a785..4df8aa2b 100644 --- a/desktop/src/components/layout/Sidebar.tsx +++ b/desktop/src/components/layout/Sidebar.tsx @@ -186,12 +186,6 @@ export function Sidebar({ isMobile = false, onRequestClose }: SidebarProps) { } }, [deselectSessions, selectSessions, selectedSessionIds]) - const selectOlderThan = useCallback((days: number) => { - const ids = getSessionsOlderThan(filteredSessions, days) - selectSessions(ids) - requestBatchDelete(ids) - }, [filteredSessions, requestBatchDelete, selectSessions]) - const handleStartRename = useCallback((id: string, currentTitle: string) => { setContextMenu(null) setRenamingId(id) @@ -445,22 +439,6 @@ export function Sidebar({ isMobile = false, onRequestClose }: SidebarProps) { > {t('sidebar.batchDeleteSelected', { count: selectedCount })} - - )} @@ -719,13 +697,6 @@ function groupByTime(sessions: SessionListItem[]): Map new Date(session.modifiedAt).getTime() < threshold) - .map((session) => session.id) -} - function NavItem({ active, collapsed, diff --git a/desktop/src/i18n/locales/en.ts b/desktop/src/i18n/locales/en.ts index 4828ae45..69907aaf 100644 --- a/desktop/src/i18n/locales/en.ts +++ b/desktop/src/i18n/locales/en.ts @@ -35,8 +35,6 @@ export const en = { 'sidebar.batchDeleteConfirm': 'Delete {count} sessions? This cannot be undone.', 'sidebar.batchDeleteConfirmBody': 'The following sessions will be deleted:', 'sidebar.batchDeleteMore': '...and {count} more', - 'sidebar.batchClearOlderThan30': 'Clear >30d', - 'sidebar.batchClearOlderThan7': 'Clear >7d', 'sidebar.batchExit': 'Cancel batch mode', 'sidebar.batchDeleteSucceeded': 'Deleted {count} sessions.', 'sidebar.batchDeleteFailed': '{count} sessions could not be deleted.', diff --git a/desktop/src/i18n/locales/zh.ts b/desktop/src/i18n/locales/zh.ts index 989ce016..a1d97761 100644 --- a/desktop/src/i18n/locales/zh.ts +++ b/desktop/src/i18n/locales/zh.ts @@ -37,8 +37,6 @@ export const zh: Record = { 'sidebar.batchDeleteConfirm': '确定要删除 {count} 个会话吗?此操作不可撤销。', 'sidebar.batchDeleteConfirmBody': '以下会话将被删除:', 'sidebar.batchDeleteMore': '...还有 {count} 条', - 'sidebar.batchClearOlderThan30': '清空 30 天前', - 'sidebar.batchClearOlderThan7': '清空 7 天前', 'sidebar.batchExit': '退出批量管理', 'sidebar.batchDeleteSucceeded': '已删除 {count} 个会话。', 'sidebar.batchDeleteFailed': '有 {count} 个会话删除失败。',