From d3055ae06886d713873d08f0c419d91e4f42db64 Mon Sep 17 00:00:00 2001 From: ttommybot Date: Mon, 3 Aug 2026 13:52:18 +0800 Subject: [PATCH] fix: count skipped stages in parsing progress --- .../knowledge-processing-timeline.test.ts | 28 +++++++++++++++++++ .../knowledge-processing-timeline.vue | 12 +++++--- 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 frontend/src/components/knowledge-processing-timeline.test.ts diff --git a/frontend/src/components/knowledge-processing-timeline.test.ts b/frontend/src/components/knowledge-processing-timeline.test.ts new file mode 100644 index 00000000..7e1abf85 --- /dev/null +++ b/frontend/src/components/knowledge-processing-timeline.test.ts @@ -0,0 +1,28 @@ +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import { dirname, join } from 'node:path' +import test from 'node:test' +import { fileURLToPath } from 'node:url' + +const here = dirname(fileURLToPath(import.meta.url)) +const source = readFileSync(join(here, 'knowledge-processing-timeline.vue'), 'utf8') + +test('counts skipped stages when determining the current stage', () => { + const currentStageIndex = source.slice( + source.indexOf('const currentStageIndex'), + source.indexOf('function formatDuration'), + ) + + assert.match(currentStageIndex, /status === 'done' \|\| s\.status === 'skipped'/) + assert.match(currentStageIndex, /Math\.min\(traversed \+ 1, stages\.value\.length\)/) +}) + +test('counts skipped stages in the completed stage total', () => { + const stagesStatDisplay = source.slice( + source.indexOf('const stagesStatDisplay'), + source.indexOf('const postprocessTaskStats'), + ) + + assert.match(stagesStatDisplay, /status === 'done' \|\| s\.status === 'skipped'/) + assert.match(stagesStatDisplay, /value: `\$\{completedCount\}\/\$\{total\}`/) +}) diff --git a/frontend/src/components/knowledge-processing-timeline.vue b/frontend/src/components/knowledge-processing-timeline.vue index d406501d..2cf82b64 100644 --- a/frontend/src/components/knowledge-processing-timeline.vue +++ b/frontend/src/components/knowledge-processing-timeline.vue @@ -167,8 +167,10 @@ const currentStageLabel = computed(() => { const currentStageIndex = computed(() => { const idx = stages.value.findIndex((s) => s.status === 'running' || s.status === 'failed') if (idx >= 0) return idx + 1 - const done = stages.value.filter((s) => s.status === 'done').length - return Math.min(done + 1, stages.value.length) + const traversed = stages.value.filter( + (s) => s.status === 'done' || s.status === 'skipped', + ).length + return Math.min(traversed + 1, stages.value.length) }) function formatDuration(ms?: number): string { @@ -1182,7 +1184,9 @@ const showLastError = computed(() => const stagesStatDisplay = computed(() => { const total = stages.value.length - const doneCount = stages.value.filter((s) => s.status === 'done').length + const completedCount = stages.value.filter( + (s) => s.status === 'done' || s.status === 'skipped', + ).length const inProgress = stages.value.some( (s) => s.status === 'running' || s.status === 'failed' || s.status === 'pending', ) @@ -1194,7 +1198,7 @@ const stagesStatDisplay = computed(() => { } return { label: t('knowledgeStages.head.stagesDone'), - value: `${doneCount}/${total}`, + value: `${completedCount}/${total}`, } })