diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts index eac6989e..7a268642 100644 --- a/lightrag_webui/src/api/lightrag.ts +++ b/lightrag_webui/src/api/lightrag.ts @@ -242,6 +242,7 @@ export type PipelineStatusResponse = { batchs: number cur_batch: number request_pending: boolean + cancellation_requested?: boolean latest_message: string history_messages?: string[] update_status?: Record @@ -691,6 +692,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 2a2c5d93..0aab7dfe 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 be0c82cb..67b90629 100644 --- a/lightrag_webui/src/locales/ar.json +++ b/lightrag_webui/src/locales/ar.json @@ -157,17 +157,25 @@ "hideFileNameTooltip": "إخفاء اسم الملف" }, "pipelineStatus": { - "title": "حالة خط المعالجة", - "busy": "خط المعالجة مشغول", - "requestPending": "الطلب معلق", + "title": "حالة خط الأنابيب", + "busy": "خط الأنابيب مشغول", + "requestPending": "طلب معلق", + "cancellationRequested": "طلب الإلغاء", "jobName": "اسم المهمة", "startTime": "وقت البدء", "progress": "التقدم", "unit": "دفعة", "latestMessage": "آخر رسالة", - "historyMessages": "سجل الرسائل", + "historyMessages": "رسائل السجل", + "cancelButton": "إلغاء", + "cancelTooltip": "إلغاء معالجة خط الأنابيب", + "cancelInProgress": "الإلغاء قيد التقدم...", + "pipelineNotRunning": "خط الأنابيب غير قيد التشغيل", + "cancelSuccess": "تم طلب إلغاء خط الأنابيب", + "cancelFailed": "فشل إلغاء خط الأنابيب\n{{error}}", + "cancelNotBusy": "خط الأنابيب غير قيد التشغيل، لا حاجة للإلغاء", "errors": { - "fetchFailed": "فشل في جلب حالة خط المعالجة\n{{error}}" + "fetchFailed": "فشل في جلب حالة خط الأنابيب\n{{error}}" } } }, diff --git a/lightrag_webui/src/locales/en.json b/lightrag_webui/src/locales/en.json index 5ce4b3df..e48c0207 100644 --- a/lightrag_webui/src/locales/en.json +++ b/lightrag_webui/src/locales/en.json @@ -160,14 +160,22 @@ "title": "Pipeline Status", "busy": "Pipeline Busy", "requestPending": "Request Pending", + "cancellationRequested": "Cancellation Requested", "jobName": "Job Name", "startTime": "Start Time", "progress": "Progress", - "unit": "batch", + "unit": "Batch", "latestMessage": "Latest Message", "historyMessages": "History Messages", + "cancelButton": "Cancel", + "cancelTooltip": "Cancel pipeline processing", + "cancelInProgress": "Cancellation in progress...", + "pipelineNotRunning": "Pipeline not running", + "cancelSuccess": "Pipeline cancellation requested", + "cancelFailed": "Failed to cancel pipeline\n{{error}}", + "cancelNotBusy": "Pipeline is not running, no need to cancel", "errors": { - "fetchFailed": "Failed to get pipeline status\n{{error}}" + "fetchFailed": "Failed to fetch pipeline status\n{{error}}" } } }, diff --git a/lightrag_webui/src/locales/fr.json b/lightrag_webui/src/locales/fr.json index 941b55de..b75e3e63 100644 --- a/lightrag_webui/src/locales/fr.json +++ b/lightrag_webui/src/locales/fr.json @@ -158,14 +158,22 @@ }, "pipelineStatus": { "title": "État du Pipeline", - "busy": "Pipeline occupé", - "requestPending": "Requête en attente", - "jobName": "Nom du travail", - "startTime": "Heure de début", - "progress": "Progression", - "unit": "lot", - "latestMessage": "Dernier message", - "historyMessages": "Historique des messages", + "busy": "Pipeline Occupé", + "requestPending": "Demande en Attente", + "cancellationRequested": "Annulation Demandée", + "jobName": "Nom du Travail", + "startTime": "Heure de Début", + "progress": "Progrès", + "unit": "Lot", + "latestMessage": "Dernier Message", + "historyMessages": "Messages d'Historique", + "cancelButton": "Annuler", + "cancelTooltip": "Annuler le traitement du pipeline", + "cancelInProgress": "Annulation en cours...", + "pipelineNotRunning": "Le pipeline n'est pas en cours d'exécution", + "cancelSuccess": "Annulation du pipeline demandée", + "cancelFailed": "Échec de l'annulation du pipeline\n{{error}}", + "cancelNotBusy": "Le pipeline n'est pas en cours d'exécution, pas besoin d'annuler", "errors": { "fetchFailed": "Échec de la récupération de l'état du pipeline\n{{error}}" } diff --git a/lightrag_webui/src/locales/zh.json b/lightrag_webui/src/locales/zh.json index 3bbb31aa..2712a6d2 100644 --- a/lightrag_webui/src/locales/zh.json +++ b/lightrag_webui/src/locales/zh.json @@ -160,12 +160,20 @@ "title": "流水线状态", "busy": "流水线忙碌", "requestPending": "待处理请求", + "cancellationRequested": "取消请求", "jobName": "作业名称", "startTime": "开始时间", "progress": "进度", "unit": "批", "latestMessage": "最新消息", "historyMessages": "历史消息", + "cancelButton": "中断", + "cancelTooltip": "中断流水线处理", + "cancelInProgress": "取消请求进行中...", + "pipelineNotRunning": "流水线未运行", + "cancelSuccess": "流水线中断请求已发送", + "cancelFailed": "中断流水线失败\n{{error}}", + "cancelNotBusy": "流水线未运行,无需中断", "errors": { "fetchFailed": "获取流水线状态失败\n{{error}}" } diff --git a/lightrag_webui/src/locales/zh_TW.json b/lightrag_webui/src/locales/zh_TW.json index e4387e98..8fb06bf8 100644 --- a/lightrag_webui/src/locales/zh_TW.json +++ b/lightrag_webui/src/locales/zh_TW.json @@ -157,17 +157,25 @@ "hideFileNameTooltip": "隱藏檔案名稱" }, "pipelineStatus": { - "title": "pipeline 狀態", - "busy": "pipeline 忙碌中", + "title": "流水線狀態", + "busy": "流水線忙碌", "requestPending": "待處理請求", - "jobName": "工作名稱", + "cancellationRequested": "取消請求", + "jobName": "作業名稱", "startTime": "開始時間", "progress": "進度", - "unit": "梯次", - "latestMessage": "最新訊息", - "historyMessages": "歷史訊息", + "unit": "批", + "latestMessage": "最新消息", + "historyMessages": "歷史消息", + "cancelButton": "中斷", + "cancelTooltip": "中斷流水線處理", + "cancelInProgress": "取消請求進行中...", + "pipelineNotRunning": "流水線未運行", + "cancelSuccess": "流水線中斷請求已發送", + "cancelFailed": "中斷流水線失敗\n{{error}}", + "cancelNotBusy": "流水線未運行,無需中斷", "errors": { - "fetchFailed": "取得pipeline 狀態失敗\n{{error}}" + "fetchFailed": "獲取流水線狀態失敗\n{{error}}" } } },