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.
This commit is contained in:
程序员阿江(Relakkes) 2026-05-12 17:49:51 +08:00
parent 8d827510db
commit dbb8c95905
4 changed files with 0 additions and 35 deletions

View File

@ -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.',

View File

@ -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 })}
</button>
<button
type="button"
onClick={() => selectOlderThan(7)}
disabled={getSessionsOlderThan(filteredSessions, 7).length === 0}
className="rounded-md border border-[var(--color-border)] px-2 py-1.5 text-xs font-medium text-[var(--color-text-secondary)] transition-colors hover:bg-[var(--color-surface-hover)] disabled:opacity-50"
>
{t('sidebar.batchClearOlderThan7')}
</button>
<button
type="button"
onClick={() => selectOlderThan(30)}
disabled={getSessionsOlderThan(filteredSessions, 30).length === 0}
className="rounded-md border border-[var(--color-border)] px-2 py-1.5 text-xs font-medium text-[var(--color-text-secondary)] transition-colors hover:bg-[var(--color-surface-hover)] disabled:opacity-50"
>
{t('sidebar.batchClearOlderThan30')}
</button>
</div>
</div>
)}
@ -719,13 +697,6 @@ function groupByTime(sessions: SessionListItem[]): Map<TimeGroup, SessionListIte
return groups
}
function getSessionsOlderThan(sessions: SessionListItem[], days: number): string[] {
const threshold = Date.now() - days * 86400000
return sessions
.filter((session) => new Date(session.modifiedAt).getTime() < threshold)
.map((session) => session.id)
}
function NavItem({
active,
collapsed,

View File

@ -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.',

View File

@ -37,8 +37,6 @@ export const zh: Record<TranslationKey, string> = {
'sidebar.batchDeleteConfirm': '确定要删除 {count} 个会话吗?此操作不可撤销。',
'sidebar.batchDeleteConfirmBody': '以下会话将被删除:',
'sidebar.batchDeleteMore': '...还有 {count} 条',
'sidebar.batchClearOlderThan30': '清空 30 天前',
'sidebar.batchClearOlderThan7': '清空 7 天前',
'sidebar.batchExit': '退出批量管理',
'sidebar.batchDeleteSucceeded': '已删除 {count} 个会话。',
'sidebar.batchDeleteFailed': '有 {count} 个会话删除失败。',