From 924ff1b6fcf4f67ba43f1c204dc8cf1fe8ee23c0 Mon Sep 17 00:00:00 2001 From: tisonhuang Date: Wed, 4 Mar 2026 18:34:15 +0800 Subject: [PATCH] feat(export): narrow chat window and refine progress settle --- electron/main.ts | 4 ++-- src/pages/ExportPage.tsx | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index a8ceee0..d8e2d4b 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -708,9 +708,9 @@ function createSessionChatWindow(sessionId: string) { const isDark = nativeTheme.shouldUseDarkColors const win = new BrowserWindow({ - width: 980, + width: 600, height: 820, - minWidth: 560, + minWidth: 420, minHeight: 560, icon: iconPath, webPreferences: { diff --git a/src/pages/ExportPage.tsx b/src/pages/ExportPage.tsx index 3a2c69a..ada1741 100644 --- a/src/pages/ExportPage.tsx +++ b/src/pages/ExportPage.tsx @@ -123,6 +123,7 @@ interface ExportTask { id: string title: string status: TaskStatus + settledSessionIds?: string[] createdAt: number startedAt?: number finishedAt?: number @@ -2277,6 +2278,7 @@ function ExportPage() { updateTask(next.id, task => ({ ...task, status: 'running', + settledSessionIds: [], startedAt: Date.now(), finishedAt: undefined, error: undefined, @@ -2286,6 +2288,7 @@ function ExportPage() { })) progressUnsubscribeRef.current?.() + const settledSessionIdsFromProgress = new Set() if (next.payload.scope === 'sns') { progressUnsubscribeRef.current = window.electronAPI.sns.onExportProgress((payload) => { updateTask(next.id, task => { @@ -2306,10 +2309,34 @@ function ExportPage() { }) } else { progressUnsubscribeRef.current = window.electronAPI.export.onProgress((payload: ExportProgress) => { + const now = Date.now() + const currentSessionId = String(payload.currentSessionId || '').trim() + if (payload.phase === 'complete' && currentSessionId && !settledSessionIdsFromProgress.has(currentSessionId)) { + settledSessionIdsFromProgress.add(currentSessionId) + const phaseLabel = String(payload.phaseLabel || '') + const isFailed = phaseLabel.includes('失败') + if (!isFailed) { + const contentTypes = next.payload.contentType + ? [next.payload.contentType] + : (next.payload.options ? inferContentTypesFromOptions(next.payload.options) : []) + markSessionExported([currentSessionId], now) + if (contentTypes.length > 0) { + markContentExported([currentSessionId], contentTypes, now) + } + } + } + updateTask(next.id, task => { if (task.status !== 'running') return task - const now = Date.now() const performance = applyProgressToTaskPerformance(task, payload, now) + const settledSessionIds = task.settledSessionIds || [] + const nextSettledSessionIds = ( + payload.phase === 'complete' && + currentSessionId && + !settledSessionIds.includes(currentSessionId) + ) + ? [...settledSessionIds, currentSessionId] + : settledSessionIds return { ...task, progress: { @@ -2321,6 +2348,7 @@ function ExportPage() { phaseProgress: payload.phaseProgress || 0, phaseTotal: payload.phaseTotal || 0 }, + settledSessionIds: nextSettledSessionIds, performance } }) @@ -2470,6 +2498,7 @@ function ExportPage() { id: createTaskId(), title, status: 'queued', + settledSessionIds: [], createdAt: Date.now(), payload: { sessionIds: exportDialog.sessionIds, @@ -2586,7 +2615,9 @@ function ExportPage() { const set = new Set() for (const task of tasks) { if (task.status !== 'running') continue + const settled = new Set(task.settledSessionIds || []) for (const id of task.payload.sessionIds) { + if (settled.has(id)) continue set.add(id) } }