diff --git a/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue b/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue index 74b40d94..c89fd288 100644 --- a/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue +++ b/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue @@ -91,9 +91,9 @@ - + - +
- store.rawMaterials.some(r => r.processingStatus === 'processing') + store.rawMaterials.some(r => r.processingStatus === 'processing' || r.processingStatus === 'pending') ) function applyProgressEvent(payload: any) { @@ -224,7 +224,8 @@ function openSse(kbId: number) { raw.progressTotal = data.totalPages } } - // 完成事件后,再做一次轻量 list 拉取确保其他字段(pageCount 等)同步 + // Clear stale job entry so JobStageBar hides + delete rawJobs[data.rawId] if (store.currentKB) store.fetchRawMaterials(store.currentKB.id) } catch { /* ignore */ } }) @@ -233,6 +234,8 @@ function openSse(kbId: number) { const data = JSON.parse(ev.data) const raw = store.rawMaterials.find(r => r.id === data.rawId) if (raw) raw.processingStatus = 'failed' + // Clear stale job entry + delete rawJobs[data.rawId] if (store.currentKB) store.fetchRawMaterials(store.currentKB.id) } catch { /* ignore */ } }) @@ -350,8 +353,21 @@ async function handleAddText() { async function reprocess(rawId: number) { if (!store.currentKB) return - await wikiApi.reprocessRaw(store.currentKB.id, rawId) - await store.fetchRawMaterials(store.currentKB.id) + const kbId = store.currentKB.id + await wikiApi.reprocessRaw(kbId, rawId) + // Immediately mark local state as processing so SSE connects and progress bar shows + const raw = store.rawMaterials.find(r => r.id === rawId) + if (raw) { + raw.processingStatus = 'processing' + raw.progressDone = 0 + raw.progressTotal = 0 + } + // Clear stale job entry + delete rawJobs[rawId] + await store.fetchRawMaterials(kbId) + // Delayed re-fetch to catch final status if processing finishes before SSE connects + setTimeout(() => { store.fetchRawMaterials(kbId) }, 5000) + setTimeout(() => { store.fetchRawMaterials(kbId) }, 15000) } async function deleteRaw(rawId: number) { @@ -362,8 +378,14 @@ async function deleteRaw(rawId: number) { async function processAll() { if (!store.currentKB) return - await wikiApi.processKB(store.currentKB.id) - await store.fetchRawMaterials(store.currentKB.id) + const kbId = store.currentKB.id + await wikiApi.processKB(kbId) + // Mark all pending materials as processing so SSE connects + store.rawMaterials + .filter(r => r.processingStatus === 'pending') + .forEach(r => { r.processingStatus = 'processing'; r.progressDone = 0; r.progressTotal = 0 }) + await store.fetchRawMaterials(kbId) + setTimeout(() => { store.fetchRawMaterials(kbId) }, 5000) } async function handleScanDir() {