diff --git a/components/dashboard/network-timeline.tsx b/components/dashboard/network-timeline.tsx index d7ee3ac..3a2b768 100644 --- a/components/dashboard/network-timeline.tsx +++ b/components/dashboard/network-timeline.tsx @@ -923,6 +923,45 @@ export function NetworkTimeline({ return formatTime(remainingTime); } + // 获取任务日志内容(右侧面板展示) + function getTaskLogContent(viewTask: TaskExecution): string { + // 优先从原始任务中提取完整字段 + let origin: any | null = null; + if (viewTask.level === 0) { + origin = tasks.find((t: any) => t.task_id === viewTask.id) || null; + } else if (viewTask.level === 1 && viewTask.parentId) { + const parent = tasks.find((t: any) => t.task_id === viewTask.parentId); + origin = parent?.sub_tasks?.find((st: any) => st.task_id === viewTask.id) || null; + } + + if (!origin) return '无可用日志'; + + const resultObj = parseTaskResult(origin.task_result); + const payload: Record = { + task_id: origin.task_id, + task_name: origin.task_name, + task_status: origin.task_status, + task_message: origin.task_message || null, + error_message: origin.error_message || resultObj?.error_message || null, + error_traceback: origin.error_traceback || resultObj?.error_traceback || null, + progress_percentage: resultObj?.progress_percentage ?? origin.progress ?? null, + params: origin.task_params || null, + result: resultObj || origin.task_result || null, + timestamps: { + created_at: origin.created_at || null, + updated_at: origin.updated_at || null, + start_time: origin.start_time || null, + end_time: origin.end_time || null, + }, + }; + + try { + return JSON.stringify(payload, null, 2); + } catch { + return typeof origin.task_result === 'string' ? origin.task_result : '无可用日志'; + } + } + // 获取状态颜色 function getStatusColor(status: number): string { if (status >= 200 && status < 300) return 'text-green-400'; @@ -950,13 +989,13 @@ export function NetworkTimeline({ return (
{/* 工具栏 */} -
-
+
+

任务执行时间线

{/* 任务统计 */} -
+
总任务: {taskStats.total} @@ -1083,7 +1122,7 @@ export function NetworkTimeline({ {/* 左侧任务列表 */}
{/* 列表头部 */} -
+
状态
{/* 展开/折叠按钮列 */}
任务名称
@@ -1094,7 +1133,7 @@ export function NetworkTimeline({
{/* 任务列表 */} -
+
{filteredTaskExecutions.length === 0 ? (
@@ -1110,7 +1149,7 @@ export function NetworkTimeline({
{/* 状态图标 */}
- {task.statusCode === 200 && } - {task.statusCode === 202 && } - {task.statusCode === 100 && } - {task.statusCode >= 400 && } + {task.statusCode === 200 && } + {task.statusCode === 202 && } + {task.statusCode === 100 && } + {task.statusCode >= 400 && }
{/* 展开/折叠按钮 */} @@ -1341,12 +1380,12 @@ export function NetworkTimeline({ {/* 右侧时间线 */}
-
+
时间线视图 (总耗时: {formatTime(maxTime)})
-
+
{/* 时间刻度 */}
@@ -1386,13 +1425,13 @@ export function NetworkTimeline({ filteredTaskExecutions.map((task) => (
{/* 任务条 */}
= 400 ? "bg-rose-500" : "bg-amber-500", @@ -1575,23 +1614,48 @@ ${task.status === 'IN_PROGRESS' ? `进度: ${task.progress}%` : ''} initial={{ opacity: 0, height: 0 }} animate={{ opacity: 1, height: 'auto' }} exit={{ opacity: 0, height: 0 }} - className="border-t border-gray-800 p-4" + className="border-t border-gray-800 p-3" > {(() => { const task = taskExecutions.find((t: TaskExecution) => t.id === selectedTask); if (!task) return null; return ( -
+

{task.level === 0 ? '主任务详情' : '子任务详情'}

+ {/* 顶部一行:任务关键信息 + 时间信息 */} + {(() => { + const t = getTaskTimes(task); + return ( +
+ + {task.displayName} + + {getTaskStatusText(task.status)} + {task.type} + {t.startTime && ( + + 开始 {new Date(t.startTime).toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit', second: '2-digit' })} + + )} + {t.endTime && ( + + 结束 {new Date(t.endTime).toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit', second: '2-digit' })} + + )} + {t.startTime && t.endTime && ( + + 时长 {formatTime(task.executionTime)} + + )} +
+ ); + })()}
-
任务名称: {task.displayName}
任务ID: {task.name}
-
状态: {getTaskStatusText(task.status)}
-
类型: {task.type}
层级: {task.level === 0 ? '主任务' : '子任务'}
{/* 子任务完成状况 */} @@ -1603,28 +1667,7 @@ ${task.status === 'IN_PROGRESS' ? `进度: ${task.progress}%` : ''} ) : null; })()} - {/* 时间信息显示 */} - {(() => { - const taskTimes = getTaskTimes(task); - return ( - <> -
-
⏰ 时间信息
-
开始时间: {formatDateTime(taskTimes.startTime)}
-
结束时间: {formatDateTime(taskTimes.endTime)}
- {taskTimes.createdAt && taskTimes.createdAt !== taskTimes.startTime && ( -
创建时间: {formatDateTime(taskTimes.createdAt)}
- )} - {taskTimes.updatedAt && taskTimes.updatedAt !== taskTimes.endTime && ( -
更新时间: {formatDateTime(taskTimes.updatedAt)}
- )} - {taskTimes.startTime && taskTimes.endTime && ( -
执行时长: {formatTime(task.executionTime)}
- )} -
- - ); - })()} + {/* 时间信息已并入顶部一行,此处不再重复 */} {task.status === 'IN_PROGRESS' && ( <>
进度: {task.progress}%
@@ -1658,21 +1701,21 @@ ${task.status === 'IN_PROGRESS' ? `进度: ${task.progress}%` : ''} if (!errorInfo.hasError) return null; return ( -
-
+
+
- 错误信息 + 错误
-
{errorInfo.errorMessage}
+ {errorInfo.errorMessage} {errorInfo.errorCode && ( -
代码: {errorInfo.errorCode}
+ 代码: {errorInfo.errorCode} )} {onRetryTask && (
-

执行分析

-
-
总时间: {formatTime(task.executionTime)}
-
AI处理: {formatTime(task.phases.aiProcessing || 0)}
- {/*
数据大小: {formatSize(task.dataSize)}
*/} - {task.level === 0 && task.taskResult?.total_count && ( -
子任务数: {task.taskResult.total_count}
- )} - {task.level === 0 && task.taskResult?.completed_count !== undefined && ( -
已完成: {task.taskResult.completed_count}/{task.taskResult.total_count}
- )} - {task.level === 1 && task.taskResult?.urls && ( -
输出文件: {task.taskResult.urls.length} 个
- )} -
+

执行日志

+ {/*
+
+
+{getTaskLogContent(task)}
+                        
+
+
仅展示与该任务相关的最新字段(状态、消息、错误、参数与结果)。
+
*/}
);