From 04180f8f2021f3265a621007e587ffdfbf9fcd41 Mon Sep 17 00:00:00 2001 From: kev1n77 Date: Mon, 7 Sep 2026 11:16:43 +0800 Subject: [PATCH] fix(web-ui): improve session archive feedback and cleanup --- .../NavPanel/sections/sessions/SessionsSection.tsx | 3 ++- .../services/flow-chat-manager/SessionModule.test.ts | 7 +++++-- .../flow_chat/services/flow-chat-manager/SessionModule.ts | 7 +++++++ src/web-ui/src/locales/en-US/common.json | 2 +- src/web-ui/src/locales/zh-CN/common.json | 2 +- src/web-ui/src/locales/zh-TW/common.json | 2 +- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/web-ui/src/app/components/NavPanel/sections/sessions/SessionsSection.tsx b/src/web-ui/src/app/components/NavPanel/sections/sessions/SessionsSection.tsx index 49dec99df5..0d2bf74454 100644 --- a/src/web-ui/src/app/components/NavPanel/sections/sessions/SessionsSection.tsx +++ b/src/web-ui/src/app/components/NavPanel/sections/sessions/SessionsSection.tsx @@ -1304,11 +1304,12 @@ const SessionsSection: React.FC = ({ try { await flowChatManager.archiveChatSession(sessionId); window.dispatchEvent(new CustomEvent('openbitfun:session-archived')); + notificationService.success(t('nav.sessions.archivedAll', { count: 1 }), { duration: 3000 }); } catch (err) { log.error('Failed to archive session', err); } }, - [] + [t] ); const handleCopySessionId = useCallback( diff --git a/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.test.ts b/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.test.ts index 16fdc6e17d..dde4782e77 100644 --- a/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.test.ts +++ b/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.test.ts @@ -1207,7 +1207,10 @@ describe('SessionModule historical session coordination', () => { expect(persistenceMocks.cleanupSaveState).toHaveBeenCalledWith(context, 'active-1'); }); - it('cancels a speculative history-open transition when deleting its target', async () => { + it.each([ + ['deleting', deleteChatSession], + ['archiving', archiveChatSession], + ] as const)('cancels a speculative history-open transition when %s its target', async (_action, removeSession) => { const historicalSession = createSession({ sessionId: 'history-delete', isHistorical: true, @@ -1223,7 +1226,7 @@ describe('SessionModule historical session coordination', () => { sessionId: historicalSession.sessionId, }); - await deleteChatSession(context, historicalSession.sessionId); + await removeSession(context, historicalSession.sessionId); expect(getHistorySessionOpenTransitionSnapshot()).toBeNull(); }); diff --git a/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.ts b/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.ts index 9d3188b7aa..f3c18bb402 100644 --- a/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.ts +++ b/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.ts @@ -898,6 +898,13 @@ export async function archiveChatSession( && removedSessionIdSet.has(stateBeforeArchive.activeSessionId) ); + // Match deletion: a removed session must not leave a pending history-open + // shield or navigation intent behind while the archive request settles. + removedSessionIds.forEach(removedSessionId => { + clearRecentHistorySessionOpenIntent(removedSessionId); + clearHistorySessionOpenTransition(removedSessionId); + }); + await driverForSession(sessionId, session).archiveSession(context, sessionId, { removedSessionIds, removedActiveSession, diff --git a/src/web-ui/src/locales/en-US/common.json b/src/web-ui/src/locales/en-US/common.json index e5f8bc0548..d52b2413eb 100644 --- a/src/web-ui/src/locales/en-US/common.json +++ b/src/web-ui/src/locales/en-US/common.json @@ -404,7 +404,7 @@ "restore": "Restore", "restoreSucceeded": "Restored “{{name}}” in {{workspace}}.", "restoreRefreshFailed": "The session was restored, but the session list could not refresh. Refresh the workspace manually.", - "archivedAll": "{{count}} sessions archived", + "archivedAll": "Archived {{count}} sessions. View them in Settings → Archived Sessions.", "restoreFailed": "Failed to restore session", "deleteArchivedFailed": "Failed to delete session", "deleteAllArchivedFailed": "Failed to delete all archived sessions", diff --git a/src/web-ui/src/locales/zh-CN/common.json b/src/web-ui/src/locales/zh-CN/common.json index e4a58ef1ae..36c9eda037 100644 --- a/src/web-ui/src/locales/zh-CN/common.json +++ b/src/web-ui/src/locales/zh-CN/common.json @@ -404,7 +404,7 @@ "restore": "恢复", "restoreSucceeded": "已恢复“{{name}}”({{workspace}})。", "restoreRefreshFailed": "会话已恢复,但会话列表刷新失败;请手动刷新工作区。", - "archivedAll": "已归档 {{count}} 个会话", + "archivedAll": "已归档 {{count}} 个会话,可在设置 → 已归档会话中查看。", "restoreFailed": "恢复会话失败", "deleteArchivedFailed": "删除会话失败", "deleteAllArchivedFailed": "删除全部已归档会话失败", diff --git a/src/web-ui/src/locales/zh-TW/common.json b/src/web-ui/src/locales/zh-TW/common.json index 17941c27da..4abd2424df 100644 --- a/src/web-ui/src/locales/zh-TW/common.json +++ b/src/web-ui/src/locales/zh-TW/common.json @@ -404,7 +404,7 @@ "restore": "恢復", "restoreSucceeded": "已恢復「{{name}}」({{workspace}})。", "restoreRefreshFailed": "會話已恢復,但會話列表重新整理失敗;請手動重新整理工作區。", - "archivedAll": "已歸檔 {{count}} 個會話", + "archivedAll": "已歸檔 {{count}} 個會話,可在設定 → 已歸檔會話中檢視。", "restoreFailed": "恢復會話失敗", "deleteArchivedFailed": "刪除會話失敗", "deleteAllArchivedFailed": "刪除全部已歸檔會話失敗",