feat: add knowledge parse cancellation with finalizing post-process state
Lets users stop an in-flight document parse to free up LLM / worker
resources without losing the chunks and index already written. The
core insight is that the previous parse_status=completed flipped as
soon as primary chunks landed, while the most expensive subtasks
(graph extract = N LLM calls per chunk, plus summary, question
generation) were still running in the background — so "completed"
wasn't actually terminal from a resource standpoint.
State machine
pending -> processing -> finalizing -> completed
|
+-> cancelled (any of the three
in-flight states)
+-> failed
+-> deleting
`finalizing` is the new post-process fan-out window. parse_status
only promotes to `completed` once pending_subtasks_count (a new
column tracking summary + question + per-chunk graph extract)
drains to zero via atomic FinalizeSubtask. Wiki ingest is
intentionally excluded from the counter — it's a KB-scoped
debounced batch and would otherwise pin parse_status in
`finalizing` for the wiki batch window.
Backend
- New ParseStatusFinalizing + pending_subtasks_count column with
migration 000056.
- knowledgeRepository.SetFinalizing transitions processing -> finalizing
conditionally so a racing cancel cannot be clobbered.
- knowledgeRepository.FinalizeSubtask atomically decrements the
counter and self-promotes the row to completed when it hits zero.
- KnowledgePostProcess restructured to compute expected subtask
count up front, flip to finalizing (or completed when no
enrichment is enabled), and only then fan out subtasks. Subtask
handlers (summary, question, graph extract) defer-decrement on
terminal exit using the existing isFinalAsynqAttempt convention.
- New POST /api/v1/knowledge/{id}/cancel-parse handler accepting
pending / processing / finalizing. Marks the row cancelled,
zeroes the counter, best-effort dequeues asynq tasks via a new
TaskInspector abstraction (asynq-mode walks pending/scheduled/
retry queues; Lite-mode noop), and scrubs wiki ingest pending op.
- SpanTracker.AbortAttempt flat-sweeps every still-running span
for the attempt via a new repo.CancelAllOpenSpans helper so the
trace viewer's striped bars all flip to cancelled, even leaf
generations whose parent stage already EndSpan'd (multimodal
fan-out pattern). knowledge_post_process closes its postSpan
via SkipSpan on the cancel/deleting entry guard so a worker
that opens a span AFTER the cancel sweep doesn't leak it.
- Housekeeping and resetPendingTasks sweep finalizing rows
identically to processing so a crash/restart can't strand them.
- DeleteKnowledge/DeleteKnowledgeList proactively dequeue
downstream tasks via the same TaskInspector path.
- ChunkExtractService gets a cancel entry guard so the most
expensive enrichment (graph extract) bails immediately when the
parent knowledge is aborted.
Frontend
- New cancelKnowledgeParse API client + "Stop parsing" entry in
both list view and card view more menus, gated on
pending/processing/finalizing.
- Polling predicate refactored to a shared isParseInFlight helper
that recognises `finalizing` (previously the doc list silently
stopped polling once parse_status flipped from processing).
- Knowledge processing timeline: isPolling includes finalizing,
new isHardTerminal short-circuits LIVE for cancelled/failed/
completed so stranded child spans cannot pin LIVE on.
- DocumentListView.computeStatus distinguishes finalizing
("增强中") from completed and shows the previous "生成摘要中"
copy when summary_status is still pending under finalizing.
Added cancelled badge as well.
- i18n: statusFinalizing / statusCancelled / cancelParse* keys
across zh-CN, en-US, ko-KR, ru-RU.
Docs / SDK
- docs/api/knowledge.md: documents the new finalizing state,
cancel-parse semantics, and which statuses accept cancel.
- client (Go SDK): CancelKnowledgeParse with docstring listing
the cancellable statuses.
This commit is contained in:
@@ -223,6 +223,10 @@ export function reparseKnowledge(id: string) {
|
||||
return post(`/api/v1/knowledge/${id}/reparse`);
|
||||
}
|
||||
|
||||
export function cancelKnowledgeParse(id: string) {
|
||||
return post(`/api/v1/knowledge/${id}/cancel-parse`);
|
||||
}
|
||||
|
||||
export function getKnowledgeSpans(id: string, attempt?: number) {
|
||||
const qs = attempt ? `?attempt=${attempt}` : '';
|
||||
return get(`/api/v1/knowledge/${id}/spans${qs}`);
|
||||
|
||||
@@ -194,7 +194,18 @@ function formatRelativeTime(ts: number): string {
|
||||
}
|
||||
|
||||
function isPolling(status?: string): boolean {
|
||||
return status === 'pending' || status === 'processing'
|
||||
// finalizing is the post-process fan-out window — subspans
|
||||
// (summary / question / graph.chunk[*]) are still actively producing
|
||||
// events, so we must keep polling and drawing LIVE.
|
||||
return status === 'pending' || status === 'processing' || status === 'finalizing'
|
||||
}
|
||||
|
||||
// Hard-terminal statuses override traceActive: even if child spans were
|
||||
// left in 'running' state (e.g. a cancel raced ahead of a worker's
|
||||
// FailSpan), the parse pipeline is definitively done for this attempt
|
||||
// and we should stop polling instead of refreshing forever.
|
||||
function isHardTerminal(status?: string): boolean {
|
||||
return status === 'cancelled' || status === 'failed' || status === 'completed'
|
||||
}
|
||||
|
||||
// True if any node in the trace is still running/pending. Crucial for
|
||||
@@ -224,8 +235,14 @@ const traceActive = computed<boolean>(() => spanTreeActive(data.value?.trace))
|
||||
// parseStatus hint so the UI shows LIVE immediately.
|
||||
const isLive = computed<boolean>(() => {
|
||||
if (data.value) {
|
||||
// Hard-terminal parse_status wins over a stale traceActive: cancel
|
||||
// and irrecoverable failure can leave child spans stranded as
|
||||
// 'running' (worker process died, cancel raced FailSpan, etc.),
|
||||
// and we must NOT keep polling forever on those.
|
||||
if (isHardTerminal(data.value.parse_status)) return false
|
||||
return isPolling(data.value.parse_status) || traceActive.value
|
||||
}
|
||||
if (isHardTerminal(props.parseStatus)) return false
|
||||
return isPolling(props.parseStatus)
|
||||
})
|
||||
|
||||
|
||||
@@ -268,6 +268,10 @@ export default {
|
||||
rebuildSubmitted: 'Rebuild task submitted',
|
||||
rebuildFailed: 'Rebuild failed. Please try again later',
|
||||
rebuildInProgress: 'This document is currently being parsed. Please try again later',
|
||||
cancelParse: 'Stop parsing',
|
||||
cancelParseConfirmBody: 'Stop parsing "{title}"? Already-written chunks are kept and can be re-parsed later via "Rebuild"; pending enrichment subtasks (summary / Q&A / knowledge graph) will be dropped immediately.',
|
||||
cancelParseSubmitted: 'Parsing stopped',
|
||||
cancelParseFailed: 'Failed to stop, please try again later',
|
||||
draft: 'Draft',
|
||||
draftTip: 'Temporarily saved and not included in retrieval',
|
||||
untitledDocument: 'Untitled Document',
|
||||
@@ -317,8 +321,10 @@ export default {
|
||||
batchDeleteFailed: 'Batch delete failed',
|
||||
statusCompleted: 'Completed',
|
||||
statusProcessing: 'Processing',
|
||||
statusFinalizing: 'Finalizing',
|
||||
statusPending: 'Pending',
|
||||
statusFailed: 'Failed',
|
||||
statusCancelled: 'Cancelled',
|
||||
statusDraft: 'Draft',
|
||||
selectKnowledgeBaseFirst: 'Please select a knowledge base first',
|
||||
sessionCreationFailed: 'Failed to create chat session',
|
||||
|
||||
@@ -209,6 +209,10 @@ export default {
|
||||
rebuildSubmitted: "재구축 작업이 제출되었습니다",
|
||||
rebuildFailed: "재구축 실패, 나중에 다시 시도해주세요",
|
||||
rebuildInProgress: "현재 문서가 파싱 중입니다. 나중에 다시 시도해주세요",
|
||||
cancelParse: "파싱 중지",
|
||||
cancelParseConfirmBody: '"{title}"의 파싱을 중지하시겠습니까? 이미 저장된 청크는 유지되며 "다시 빌드"를 통해 다시 파싱할 수 있습니다. 보강 단계(요약 / Q&A / 지식 그래프)의 대기 중인 하위 작업은 즉시 취소됩니다.',
|
||||
cancelParseSubmitted: "파싱이 중지되었습니다",
|
||||
cancelParseFailed: "중지에 실패했습니다. 나중에 다시 시도해주세요",
|
||||
characters: "자",
|
||||
segment: "조각",
|
||||
chunkCount: "총 {count}개 조각",
|
||||
@@ -321,8 +325,10 @@ export default {
|
||||
batchDeleteFailed: "일괄 삭제 실패",
|
||||
statusCompleted: "완료",
|
||||
statusProcessing: "처리 중",
|
||||
statusFinalizing: "마무리 중",
|
||||
statusPending: "대기 중",
|
||||
statusFailed: "실패",
|
||||
statusCancelled: "취소됨",
|
||||
statusDraft: "초안",
|
||||
selectKnowledgeBaseFirst: "먼저 지식베이스를 선택하세요",
|
||||
sessionCreationFailed: "세션 생성 실패",
|
||||
|
||||
@@ -247,8 +247,10 @@ export default {
|
||||
batchDeleteFailed: 'Ошибка пакетного удаления',
|
||||
statusCompleted: 'Завершено',
|
||||
statusProcessing: 'Обработка',
|
||||
statusFinalizing: 'Завершение',
|
||||
statusPending: 'Ожидание',
|
||||
statusFailed: 'Ошибка',
|
||||
statusCancelled: 'Отменено',
|
||||
statusDraft: 'Черновик',
|
||||
selectKnowledgeBaseFirst: 'Пожалуйста, сначала выберите базу знаний',
|
||||
sessionCreationFailed: 'Не удалось создать диалог',
|
||||
@@ -356,7 +358,11 @@ export default {
|
||||
rebuildConfirm: 'Подтвердить пересборку документа "{fileName}"? Существующие фрагменты будут удалены и документ будет повторно проанализирован.',
|
||||
rebuildSubmitted: 'Задача пересборки отправлена',
|
||||
rebuildFailed: 'Ошибка пересборки, попробуйте позже',
|
||||
rebuildInProgress: 'Документ сейчас анализируется, попробуйте позже'
|
||||
rebuildInProgress: 'Документ сейчас анализируется, попробуйте позже',
|
||||
cancelParse: 'Остановить разбор',
|
||||
cancelParseConfirmBody: 'Остановить разбор «{title}»? Уже записанные фрагменты сохранятся, и их можно будет разобрать заново через «Пересобрать». Ожидающие подзадачи обогащения (резюме / вопросы и ответы / граф знаний) будут немедленно отменены.',
|
||||
cancelParseSubmitted: 'Разбор остановлен',
|
||||
cancelParseFailed: 'Не удалось остановить, попробуйте позже'
|
||||
},
|
||||
knowledgeStages: {
|
||||
title: 'Конвейер обработки',
|
||||
|
||||
@@ -269,6 +269,10 @@ export default {
|
||||
rebuildSubmitted: "重建任务已提交",
|
||||
rebuildFailed: "重建失败,请稍后再试",
|
||||
rebuildInProgress: "当前文档正在解析中,请稍后重试",
|
||||
cancelParse: "停止解析",
|
||||
cancelParseConfirmBody: '确认停止解析"{title}"?已写入的分块会保留,可稍后通过"重建"重新触发;增强阶段(摘要 / 问答 / 知识图谱)的待执行子任务会被立即丢弃。',
|
||||
cancelParseSubmitted: "已停止解析",
|
||||
cancelParseFailed: "停止失败,请稍后再试",
|
||||
draft: "草稿",
|
||||
draftTip: "暂存内容,未参与检索",
|
||||
untitledDocument: "未命名文档",
|
||||
@@ -318,8 +322,10 @@ export default {
|
||||
batchDeleteFailed: "批量删除失败",
|
||||
statusCompleted: "已完成",
|
||||
statusProcessing: "解析中",
|
||||
statusFinalizing: "增强中",
|
||||
statusPending: "等待中",
|
||||
statusFailed: "失败",
|
||||
statusCancelled: "已取消",
|
||||
statusDraft: "草稿",
|
||||
selectKnowledgeBaseFirst: "请先选择知识库",
|
||||
sessionCreationFailed: "创建会话失败",
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
createKnowledgeFromURL,
|
||||
listKnowledgeBases,
|
||||
reparseKnowledge,
|
||||
cancelKnowledgeParse,
|
||||
batchDeleteKnowledge,
|
||||
getKnowledgeSpans,
|
||||
} from "@/api/knowledge-base/index";
|
||||
@@ -305,9 +306,16 @@ function clearTraceAvailabilityCache() {
|
||||
traceProbeInflight.clear();
|
||||
}
|
||||
|
||||
// Parse phases where the backend pipeline is still actively running
|
||||
// (primary parse OR post-process fan-out). Trace data exists and the
|
||||
// UI should treat the row as "in flight" rather than terminal.
|
||||
function isParseInFlight(status?: string): boolean {
|
||||
return status === 'pending' || status === 'processing' || status === 'finalizing';
|
||||
}
|
||||
|
||||
function isTraceMenuVisible(item: KnowledgeCard): boolean {
|
||||
if (!item?.id) return false;
|
||||
if (item.parse_status === 'pending' || item.parse_status === 'processing') {
|
||||
if (isParseInFlight(item.parse_status)) {
|
||||
return true;
|
||||
}
|
||||
return traceAvailableById[item.id] === true;
|
||||
@@ -316,7 +324,7 @@ function isTraceMenuVisible(item: KnowledgeCard): boolean {
|
||||
async function probeTraceAvailable(item: KnowledgeCard) {
|
||||
const id = item.id;
|
||||
if (!id || traceProbeInflight.has(id)) return;
|
||||
if (item.parse_status === 'pending' || item.parse_status === 'processing') {
|
||||
if (isParseInFlight(item.parse_status)) {
|
||||
traceAvailableById[id] = true;
|
||||
return;
|
||||
}
|
||||
@@ -1031,12 +1039,7 @@ watch(() => cardList.value, (newValue) => {
|
||||
|
||||
let analyzeList = [];
|
||||
// Filter items that need polling: parsing in progress OR summary generation in progress
|
||||
analyzeList = newValue.filter(item => {
|
||||
const isParsing = item.parse_status == 'pending' || item.parse_status == 'processing';
|
||||
const isSummaryPending = item.parse_status == 'completed' &&
|
||||
(item.summary_status == 'pending' || item.summary_status == 'processing');
|
||||
return isParsing || isSummaryPending;
|
||||
})
|
||||
analyzeList = newValue.filter(needsStatusPolling);
|
||||
if (timeout !== null) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
@@ -1064,6 +1067,18 @@ type KnowledgeCard = {
|
||||
error_message?: string;
|
||||
tag_id?: string;
|
||||
};
|
||||
// needsStatusPolling decides whether a card row is still "in flight"
|
||||
// enough that the doc list should keep refreshing it. Keep in sync with
|
||||
// the backend lifecycle: pending / processing are the primary parse
|
||||
// phase, finalizing is the post-process fan-out (summary / question /
|
||||
// graph extract still running), and a `completed` row whose summary
|
||||
// hasn't landed yet keeps polling so the description fills in.
|
||||
const needsStatusPolling = (item: KnowledgeCard) => {
|
||||
if (isParseInFlight(item.parse_status)) return true;
|
||||
return item.parse_status == 'completed' &&
|
||||
(item.summary_status == 'pending' || item.summary_status == 'processing');
|
||||
};
|
||||
|
||||
const updateStatus = (analyzeList: KnowledgeCard[]) => {
|
||||
if (timeout !== null) {
|
||||
clearTimeout(timeout);
|
||||
@@ -1099,23 +1114,13 @@ const updateStatus = (analyzeList: KnowledgeCard[]) => {
|
||||
// If there are no changes, the watch won't trigger, so we must manually poll again
|
||||
// Even if there are changes, we can manually poll again just to be safe.
|
||||
// The watch will clear this timeout if it triggers.
|
||||
const stillPending = cardList.value.filter(item => {
|
||||
const isParsing = item.parse_status == 'pending' || item.parse_status == 'processing';
|
||||
const isSummaryPending = item.parse_status == 'completed' &&
|
||||
(item.summary_status == 'pending' || item.summary_status == 'processing');
|
||||
return isParsing || isSummaryPending;
|
||||
});
|
||||
const stillPending = cardList.value.filter(needsStatusPolling);
|
||||
if (stillPending.length > 0) {
|
||||
updateStatus(stillPending);
|
||||
}
|
||||
}).catch((_err) => {
|
||||
// 错误处理
|
||||
const stillPending = cardList.value.filter(item => {
|
||||
const isParsing = item.parse_status == 'pending' || item.parse_status == 'processing';
|
||||
const isSummaryPending = item.parse_status == 'completed' &&
|
||||
(item.summary_status == 'pending' || item.summary_status == 'processing');
|
||||
return isParsing || isSummaryPending;
|
||||
});
|
||||
const stillPending = cardList.value.filter(needsStatusPolling);
|
||||
if (stillPending.length > 0) {
|
||||
updateStatus(stillPending);
|
||||
}
|
||||
@@ -1773,7 +1778,7 @@ const handleKnowledgeReparse = (index: number, item: KnowledgeCard) => {
|
||||
MessagePlugin.warning(t('knowledgeEditor.messages.missingId'));
|
||||
return;
|
||||
}
|
||||
if (item.parse_status === 'pending' || item.parse_status === 'processing') {
|
||||
if (isParseInFlight(item.parse_status)) {
|
||||
MessagePlugin.info(t('knowledgeBase.rebuildInProgress'));
|
||||
return;
|
||||
}
|
||||
@@ -1959,14 +1964,36 @@ const confirmBatchDelete = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// Cancel an in-progress parse. Mirrors the backend gate: only the
|
||||
// pending / processing / finalizing states accept cancel. Uses the
|
||||
// native confirm dialog to match the existing delete-tag pattern in
|
||||
// this view and avoid a heavier dialog dependency.
|
||||
const handleKnowledgeCancelParse = async (item: KnowledgeCard) => {
|
||||
if (!item?.id) return;
|
||||
const confirmed = window.confirm(
|
||||
t('knowledgeBase.cancelParseConfirmBody', { title: item.title || item.id }) as string,
|
||||
);
|
||||
if (!confirmed) return;
|
||||
try {
|
||||
await cancelKnowledgeParse(item.id);
|
||||
MessagePlugin.success(t('knowledgeBase.cancelParseSubmitted'));
|
||||
// Refresh so the row reflects parse_status=cancelled and the
|
||||
// menu drops the cancel entry on the next open.
|
||||
loadKnowledgeFiles(kbId.value);
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('knowledgeBase.cancelParseFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
// Bridge list-view actions back to existing per-card handlers.
|
||||
const handleListAction = (
|
||||
action: 'edit' | 'reparse' | 'move' | 'delete',
|
||||
action: 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'delete',
|
||||
item: KnowledgeCard,
|
||||
) => {
|
||||
const idx = (cardList.value || []).findIndex((i: KnowledgeCard) => i.id === item.id);
|
||||
if (action === 'edit') return handleManualEdit(idx, item);
|
||||
if (action === 'reparse') return handleKnowledgeReparse(idx, item);
|
||||
if (action === 'cancel-parse') return handleKnowledgeCancelParse(item);
|
||||
if (action === 'move') return handleMoveKnowledge(item);
|
||||
if (action === 'delete') return delCard(idx, item);
|
||||
};
|
||||
@@ -2356,6 +2383,14 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<t-icon class="icon" name="refresh" />
|
||||
<span>{{ t('knowledgeBase.rebuildDocument') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="isParseInFlight(item.parse_status)"
|
||||
class="card-menu-item danger"
|
||||
@click.stop="handleKnowledgeCancelParse(item)"
|
||||
>
|
||||
<t-icon class="icon" name="close-circle" />
|
||||
<span>{{ t('knowledgeBase.cancelParse') }}</span>
|
||||
</div>
|
||||
<div v-if="canMutateKnowledge" class="card-menu-item"
|
||||
@click.stop="handleMoveKnowledge(item)">
|
||||
<t-icon class="icon" name="swap" />
|
||||
@@ -2440,6 +2475,14 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<t-icon name="loading" class="card-analyze-loading"></t-icon>
|
||||
<span class="card-analyze-txt">{{ t('knowledgeBase.parsingInProgress') }}</span>
|
||||
</div>
|
||||
<div v-else-if="item.parse_status === 'finalizing'" class="card-analyze">
|
||||
<t-icon name="loading" class="card-analyze-loading"></t-icon>
|
||||
<span class="card-analyze-txt">{{
|
||||
(item.summary_status === 'pending' || item.summary_status === 'processing')
|
||||
? t('knowledgeBase.generatingSummary')
|
||||
: t('knowledgeBase.statusFinalizing')
|
||||
}}</span>
|
||||
</div>
|
||||
<div v-else-if="item.parse_status === 'failed'" class="card-analyze failure">
|
||||
<t-icon name="close-circle" class="card-analyze-loading failure"></t-icon>
|
||||
<span class="card-analyze-txt failure">{{ t('knowledgeBase.parsingFailed') }}</span>
|
||||
@@ -2511,7 +2554,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<template v-if="hoveredCardItem">
|
||||
<div class="card-popover-title">{{ hoveredCardItem.file_name }}</div>
|
||||
<div
|
||||
v-if="hoveredCardItem.parse_status === 'processing' || hoveredCardItem.parse_status === 'pending'"
|
||||
v-if="isParseInFlight(hoveredCardItem.parse_status)"
|
||||
class="card-popover-status parsing">
|
||||
<KnowledgeProcessingTimeline :knowledge-id="hoveredCardItem.id"
|
||||
:parse-status="hoveredCardItem.parse_status" :auto-poll="false" :compact="true" />
|
||||
|
||||
@@ -37,7 +37,7 @@ const emit = defineEmits<{
|
||||
(e: 'open', item: KnowledgeItem): void;
|
||||
(e: 'toggle-row', id: string, checked: boolean, shiftKey: boolean): void;
|
||||
(e: 'toggle-all', checked: boolean): void;
|
||||
(e: 'action', action: 'edit' | 'reparse' | 'move' | 'delete', item: KnowledgeItem): void;
|
||||
(e: 'action', action: 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'delete', item: KnowledgeItem): void;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -89,12 +89,30 @@ const computeStatus = (item: KnowledgeItem): StatusInfo => {
|
||||
if (item.parse_status === 'pending' || item.parse_status === 'processing') {
|
||||
return { label: t('knowledgeBase.statusProcessing'), theme: 'primary', icon: 'loading', spin: true };
|
||||
}
|
||||
// finalizing = primary parse done, enrichment subtasks still running.
|
||||
// While in this phase, prefer the specific "summary generating" copy
|
||||
// when summary is what's actually outstanding (preserves the old UX
|
||||
// where this label was tied to completed+summary_pending). Otherwise
|
||||
// fall back to the generic "finalizing" label — covers question gen
|
||||
// and graph extract, which the user historically had no visibility on.
|
||||
if (item.parse_status === 'finalizing') {
|
||||
if (item.summary_status === 'pending' || item.summary_status === 'processing') {
|
||||
return { label: t('knowledgeBase.generatingSummary'), theme: 'primary', icon: 'loading', spin: true };
|
||||
}
|
||||
return { label: t('knowledgeBase.statusFinalizing'), theme: 'primary', icon: 'loading', spin: true };
|
||||
}
|
||||
if (item.parse_status === 'failed') {
|
||||
return { label: t('knowledgeBase.statusFailed'), theme: 'danger', icon: 'close-circle' };
|
||||
}
|
||||
if (item.parse_status === 'cancelled') {
|
||||
return { label: t('knowledgeBase.statusCancelled'), theme: 'warning', icon: 'close-circle' };
|
||||
}
|
||||
if (item.parse_status === 'draft') {
|
||||
return { label: t('knowledgeBase.statusDraft'), theme: 'warning' };
|
||||
}
|
||||
// Legacy completed+summary_pending path: kept as a defensive fallback
|
||||
// for rows that bypassed finalizing (no enrichment configured, or
|
||||
// upgraded mid-flight from a pre-finalizing build).
|
||||
if (
|
||||
item.parse_status === 'completed' &&
|
||||
(item.summary_status === 'pending' || item.summary_status === 'processing')
|
||||
@@ -153,7 +171,14 @@ onBeforeUnmount(() => {
|
||||
stickyObserver = null;
|
||||
});
|
||||
|
||||
const handleAction = (action: 'edit' | 'reparse' | 'move' | 'delete', item: KnowledgeItem) => {
|
||||
// Cancellable parse statuses mirror the backend CancelKnowledgeParse
|
||||
// gate: pending / processing / finalizing all surface the stop entry,
|
||||
// while completed / failed / cancelled / deleting hide it.
|
||||
const CANCELABLE_PARSE_STATUSES = new Set(['pending', 'processing', 'finalizing']);
|
||||
const canCancelParse = (item: KnowledgeItem) =>
|
||||
CANCELABLE_PARSE_STATUSES.has(String(item.parse_status ?? ''));
|
||||
|
||||
const handleAction = (action: 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'delete', item: KnowledgeItem) => {
|
||||
moreOpen.value = null;
|
||||
item.isMore = false;
|
||||
emit('action', action, item);
|
||||
@@ -284,6 +309,14 @@ const handleAction = (action: 'edit' | 'reparse' | 'move' | 'delete', item: Know
|
||||
<t-icon class="icon" name="refresh" />
|
||||
<span>{{ t('knowledgeBase.rebuildDocument') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="canCancelParse(item)"
|
||||
class="row-menu-item danger"
|
||||
@click.stop="handleAction('cancel-parse', item)"
|
||||
>
|
||||
<t-icon class="icon" name="close-circle" />
|
||||
<span>{{ t('knowledgeBase.cancelParse') }}</span>
|
||||
</div>
|
||||
<div class="row-menu-item" @click.stop="handleAction('move', item)">
|
||||
<t-icon class="icon" name="swap" />
|
||||
<span>{{ t('knowledgeBase.moveDocument') }}</span>
|
||||
|
||||
Reference in New Issue
Block a user