diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts index 86156e97..97663954 100644 --- a/lightrag_webui/src/api/lightrag.ts +++ b/lightrag_webui/src/api/lightrag.ts @@ -236,6 +236,7 @@ export type PipelineStatusResponse = { batchs: number cur_batch: number request_pending: boolean + cancellation_requested?: boolean latest_message: string history_messages?: string[] update_status?: Record @@ -673,6 +674,14 @@ export const getPipelineStatus = async (): Promise => { return response.data } +export const cancelPipeline = async (): Promise<{ + status: 'cancellation_requested' | 'not_busy' + message: string +}> => { + const response = await axiosInstance.post('/documents/cancel_pipeline') + return response.data +} + export const loginToServer = async (username: string, password: string): Promise => { const formData = new FormData(); formData.append('username', username); diff --git a/lightrag_webui/src/components/documents/PipelineStatusDialog.tsx b/lightrag_webui/src/components/documents/PipelineStatusDialog.tsx index 7754bb32..956538fd 100644 --- a/lightrag_webui/src/components/documents/PipelineStatusDialog.tsx +++ b/lightrag_webui/src/components/documents/PipelineStatusDialog.tsx @@ -11,7 +11,7 @@ import { DialogDescription } from '@/components/ui/Dialog' import Button from '@/components/ui/Button' -import { getPipelineStatus, PipelineStatusResponse } from '@/api/lightrag' +import { getPipelineStatus, cancelPipeline, PipelineStatusResponse } from '@/api/lightrag' import { errorMessage } from '@/lib/utils' import { cn } from '@/lib/utils' @@ -81,6 +81,23 @@ export default function PipelineStatusDialog({ return () => clearInterval(interval) }, [open, t]) + // Handle cancel pipeline + const handleCancelPipeline = async () => { + try { + const result = await cancelPipeline() + if (result.status === 'cancellation_requested') { + toast.success(t('documentPanel.pipelineStatus.cancelSuccess')) + } else if (result.status === 'not_busy') { + toast.info(t('documentPanel.pipelineStatus.cancelNotBusy')) + } + } catch (err) { + toast.error(t('documentPanel.pipelineStatus.cancelFailed', { error: errorMessage(err) })) + } + } + + // Determine if cancel button should be enabled + const canCancel = status?.busy === true && !status?.cancellation_requested + return ( - {/* Pipeline Status */} -
-
-
{t('documentPanel.pipelineStatus.busy')}:
-
-
-
-
{t('documentPanel.pipelineStatus.requestPending')}:
-
+ {/* Pipeline Status - with cancel button */} +
+ {/* Left side: Status indicators */} +
+
+
{t('documentPanel.pipelineStatus.busy')}:
+
+
+
+
{t('documentPanel.pipelineStatus.requestPending')}:
+
+
+ {/* Only show cancellation status when it's requested */} + {status?.cancellation_requested && ( +
+
{t('documentPanel.pipelineStatus.cancellationRequested')}:
+
+
+ )}
+ + {/* Right side: Cancel button - only show when pipeline is busy */} + {status?.busy && ( + + )}
{/* Job Information */} diff --git a/lightrag_webui/src/locales/ar.json b/lightrag_webui/src/locales/ar.json index 9d78da19..67b90629 100644 --- a/lightrag_webui/src/locales/ar.json +++ b/lightrag_webui/src/locales/ar.json @@ -165,7 +165,8 @@ "startTime": "وقت البدء", "progress": "التقدم", "unit": "دفعة", - "pipelineMessages": "رسائل خط الأنابيب", + "latestMessage": "آخر رسالة", + "historyMessages": "رسائل السجل", "cancelButton": "إلغاء", "cancelTooltip": "إلغاء معالجة خط الأنابيب", "cancelInProgress": "الإلغاء قيد التقدم...", diff --git a/lightrag_webui/src/locales/en.json b/lightrag_webui/src/locales/en.json index 205a7e66..e48c0207 100644 --- a/lightrag_webui/src/locales/en.json +++ b/lightrag_webui/src/locales/en.json @@ -165,7 +165,8 @@ "startTime": "Start Time", "progress": "Progress", "unit": "Batch", - "pipelineMessages": "Pipeline Messages", + "latestMessage": "Latest Message", + "historyMessages": "History Messages", "cancelButton": "Cancel", "cancelTooltip": "Cancel pipeline processing", "cancelInProgress": "Cancellation in progress...", diff --git a/lightrag_webui/src/locales/fr.json b/lightrag_webui/src/locales/fr.json index 48dbe03d..b75e3e63 100644 --- a/lightrag_webui/src/locales/fr.json +++ b/lightrag_webui/src/locales/fr.json @@ -165,7 +165,8 @@ "startTime": "Heure de Début", "progress": "Progrès", "unit": "Lot", - "pipelineMessages": "Messages de Pipeline", + "latestMessage": "Dernier Message", + "historyMessages": "Messages d'Historique", "cancelButton": "Annuler", "cancelTooltip": "Annuler le traitement du pipeline", "cancelInProgress": "Annulation en cours...", diff --git a/lightrag_webui/src/locales/zh.json b/lightrag_webui/src/locales/zh.json index b361e1ff..2712a6d2 100644 --- a/lightrag_webui/src/locales/zh.json +++ b/lightrag_webui/src/locales/zh.json @@ -165,7 +165,8 @@ "startTime": "开始时间", "progress": "进度", "unit": "批", - "pipelineMessages": "流水线消息", + "latestMessage": "最新消息", + "historyMessages": "历史消息", "cancelButton": "中断", "cancelTooltip": "中断流水线处理", "cancelInProgress": "取消请求进行中...", diff --git a/lightrag_webui/src/locales/zh_TW.json b/lightrag_webui/src/locales/zh_TW.json index e822aa77..8fb06bf8 100644 --- a/lightrag_webui/src/locales/zh_TW.json +++ b/lightrag_webui/src/locales/zh_TW.json @@ -165,7 +165,8 @@ "startTime": "開始時間", "progress": "進度", "unit": "批", - "pipelineMessages": "流水線消息", + "latestMessage": "最新消息", + "historyMessages": "歷史消息", "cancelButton": "中斷", "cancelTooltip": "中斷流水線處理", "cancelInProgress": "取消請求進行中...",