From 266f6e1a599d2dee9f36ed985142785d104f68eb Mon Sep 17 00:00:00 2001 From: ekko <152005280+EKKOLearnAI@users.noreply.github.com> Date: Wed, 6 May 2026 16:15:42 +0800 Subject: [PATCH] feat: Add batch delete functionality for chat sessions (#480) * feat: add batch delete functionality for chat sessions Backend: - Add batchRemove controller to handle bulk session deletion - Add POST /api/hermes/sessions/batch-delete endpoint - Support both local session store and CLI deletion - Return detailed results (deleted, failed, errors) Frontend: - Add batch selection mode with checkboxes in SessionListItem - Add batch selection toggle and select all button - Add batch delete button with confirmation - Update ChatPanel to manage selected session IDs - Add batchDeleteSessions API function i18n: - Add batch delete translations for all 8 languages - Simplify "Web UI/API Server Sessions" to "Sessions" Co-Authored-By: Claude Sonnet 4.6 * fix: vertically align buttons in session list header Add inline-flex and center alignment to all buttons in session-list-actions to ensure proper vertical centering with the title text. Co-Authored-By: Claude Sonnet 4.6 * fix: ensure proper vertical alignment in session list header - Set fixed height of 22px for session-list-actions - Add min-height and height to all buttons - Add line-height to session-list-title for text baseline alignment - Add min-height: 0 to session-list-header to prevent flex stretch This ensures the title and all action buttons are perfectly vertically centered. Co-Authored-By: Claude Sonnet 4.6 * fix: call loadSessions after batch delete instead of looping deleteSession The previous implementation was calling chatStore.deleteSession(id) in a loop after batch delete API succeeded, which triggered individual delete API calls for each session - causing n API requests instead of 1. Now we simply call loadSessions() to refresh the session list from the server after successful batch deletion, ensuring: - Only 1 API request for batch delete - UI stays in sync with server state - No duplicate API calls Co-Authored-By: Claude Sonnet 4.6 * refactor: improve update mechanism reliability Major improvements to the update system: **Path Resolution:** - Remove unreliable dirname(process.execPath) assumption - Use npm from PATH environment variable - Dynamically get global prefix via `npm prefix -g` - Calculate CLI path based on actual global install location **Windows Support:** - Remove complex cmd.exe wrapper logic - Directly call npm.cmd (works on all Windows setups) - Simplified quote handling **Error Handling:** - Add fallback error message (err.stderr || err.message || String(err)) - Add default success message when output is empty - Wrap spawnRestart in try-finally to ensure cleanup **Timing:** - Increase timeout from 120s to 10min (slow network support) - Increase restart delay from 2s to 3s (safer margin) **Code Quality:** - Remove unused functions (getNodeBinDir, getWindowsShell, quoteForWindowsCommand) - Use constants instead of magic numbers (10 * 60 * 1000) - More maintainable and cross-platform compatible This fixes issues where updates would fail due to incorrect npm/CLI paths on systems with non-standard Node.js installations. Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- packages/client/src/api/hermes/sessions.ts | 15 ++ .../src/components/hermes/chat/ChatPanel.vue | 180 +++++++++++++++++- .../hermes/chat/SessionListItem.vue | 12 +- packages/client/src/i18n/locales/de.ts | 8 +- packages/client/src/i18n/locales/en.ts | 8 +- packages/client/src/i18n/locales/es.ts | 8 +- packages/client/src/i18n/locales/fr.ts | 8 +- packages/client/src/i18n/locales/ja.ts | 8 +- packages/client/src/i18n/locales/ko.ts | 8 +- packages/client/src/i18n/locales/pt.ts | 8 +- packages/client/src/i18n/locales/zh.ts | 10 +- .../server/src/controllers/hermes/sessions.ts | 48 +++++ packages/server/src/controllers/update.ts | 69 ++++--- packages/server/src/routes/hermes/sessions.ts | 1 + 14 files changed, 342 insertions(+), 49 deletions(-) diff --git a/packages/client/src/api/hermes/sessions.ts b/packages/client/src/api/hermes/sessions.ts index e122a409..ffb27d12 100644 --- a/packages/client/src/api/hermes/sessions.ts +++ b/packages/client/src/api/hermes/sessions.ts @@ -108,6 +108,21 @@ export async function deleteSession(id: string): Promise { } } +export async function batchDeleteSessions(ids: string[]): Promise<{ deleted: number; failed: number; errors: Array<{ id: string; error: string }> }> { + try { + const res = await request<{ deleted: number; failed: number; errors: Array<{ id: string; error: string }> }>( + '/api/hermes/sessions/batch-delete', + { + method: 'POST', + body: JSON.stringify({ ids }), + } + ) + return res + } catch (err: any) { + throw err + } +} + export async function renameSession(id: string, title: string): Promise { try { await request(`/api/hermes/sessions/${id}/rename`, { diff --git a/packages/client/src/components/hermes/chat/ChatPanel.vue b/packages/client/src/components/hermes/chat/ChatPanel.vue index 1d3c992f..afd71f49 100644 --- a/packages/client/src/components/hermes/chat/ChatPanel.vue +++ b/packages/client/src/components/hermes/chat/ChatPanel.vue @@ -1,5 +1,5 @@