diff --git a/frontend/src/components/knowledge-processing-timeline.vue b/frontend/src/components/knowledge-processing-timeline.vue index e9c89079..ae4c5237 100644 --- a/frontend/src/components/knowledge-processing-timeline.vue +++ b/frontend/src/components/knowledge-processing-timeline.vue @@ -11,6 +11,7 @@ import { type KnowledgeTraceNode, } from '@/utils/knowledgeTrace' import { resolveTimelineHeaderStatus } from '@/utils/knowledgeProcessingStatus' +import { shownStall, stalledMinutes, STALLED_POLL_INTERVAL_MS } from '@/utils/knowledgeProcessingStall' import { axisGridStepPct, buildAxisTicks, computeTraceAxis } from '@/utils/traceAxis' import type { KnowledgeProcessOverrides } from '@/types/knowledgeProcess' @@ -32,6 +33,10 @@ interface SpansResponse { current_stage?: string trace: SpanNode last_error?: LastError | null + // Latest row or span write; only sent while the parse is in flight. + last_activity_at?: string + // Server verdict once quiet past the stall hint: 'queued' or 'stalled'. + stall_state?: string } // IMPORTANT: Vue 3 coerces missing Boolean props to `false`, NOT @@ -484,6 +489,21 @@ async function onManualRefresh() { const cancelling = ref(false) +// Minutes the latest attempt has gone without progress; 0 unless it looks +// stuck. Historical attempts are never "stalled". +const stalledMin = computed(() => { + const d = data.value + if (!d || d.attempt !== (d.latest_attempt || d.attempt)) return 0 + return stalledMinutes(d, nowTick.value) +}) + +const stalledStageLabel = computed(() => { + const stage = data.value?.current_stage + return stage && (STAGES as readonly string[]).includes(stage) + ? t(`knowledgeStages.stage.${stage}`) + : '' +}) + // Mirrors the backend CancelKnowledgeParse gate (pending / processing / // finalizing). Uses the freshest status we have: live span data first, // the parent's hint before the first fetch lands. @@ -572,6 +592,8 @@ onMounted(() => { if (unmounted) return if (fetchInFlight) return if (!shouldPollNow()) return + // Nothing is moving on a stalled trace; check back less often. + if (stalledMin.value > 0 && Date.now() - lastFetchedAt.value < STALLED_POLL_INTERVAL_MS) return fetchSpans() }, POLL_INTERVAL_MS) } @@ -1324,6 +1346,16 @@ const headStats = computed(() => { mono: true, }) } + const lastActivity = parseTime(data.value.last_activity_at) + if (lastActivity !== null && isLive.value) { + out.push({ + key: 'progress', + label: t('knowledgeStages.head.lastProgress'), + value: formatRelativeTime(lastActivity), + mono: false, + note: stalledMin.value > 0, + }) + } if (lastFetchedAt.value && isLive.value) { let updated = formatRelativeTime(lastFetchedAt.value) if (!lastFetchOk.value) { @@ -1615,6 +1647,40 @@ const processConfigLines = computed(() => { +
+ +
+
{{ t('knowledgeStages.stall.queuedTitle', { minutes: stalledMin }) }}
+
{{ t('knowledgeStages.stall.queuedHint') }}
+
+
+
+ +
+
{{ t('knowledgeStages.stall.title', { minutes: stalledMin }) }}
+
+ {{ stalledStageLabel + ? t('knowledgeStages.stall.hintAtStage', { stage: stalledStageLabel }) + : t('knowledgeStages.stall.hint') }} +
+
+ + + +
+