feat: 添加管线阶段可视化展示并改进任务日志

- 添加 PipelineStages 组件,用圆角矩形和箭头展示管线阶段
- 三色方案:已完成为浅绿、进行中为浅橙、未完成为灰色
- 任务列表中显示进度百分比和管线阶段
- 增强后端日志输出,添加任务启动、进度更新和管线完成日志
- 用于诊断任务卡在 running 状态的问题
This commit is contained in:
2026-05-25 18:34:46 +08:00
parent 0847d126a2
commit e0a70106c1
3 changed files with 87 additions and 3 deletions
@@ -0,0 +1,71 @@
const STAGES = [
{ key: 'prompt_builder', label: '提示词' },
{ key: 'asset_generator', label: '生成中' },
{ key: 'quality_supervisor', label: '质检中' },
{ key: 'format_adapter', label: '格式转换' },
] as const
type Stage = typeof STAGES[number]['key']
interface PipelineStagesProps {
currentStage: Stage | null
status: string
}
export default function PipelineStages({ currentStage, status }: PipelineStagesProps) {
if (!currentStage || status !== 'running') {
return null
}
const currentIndex = STAGES.findIndex(s => s.key === currentStage)
return (
<div style={{ marginTop: 8, display: 'flex', alignItems: 'center', gap: 4 }}>
{STAGES.map((stage, index) => {
let bgColor: string
let textColor: string
if (index < currentIndex) {
bgColor = 'rgba(74, 222, 128, 0.15)'
textColor = '#4ade80'
} else if (index === currentIndex) {
bgColor = 'rgba(251, 146, 60, 0.15)'
textColor = '#fb923c'
} else {
bgColor = 'rgba(156, 163, 175, 0.1)'
textColor = '#9ca3af'
}
return (
<div key={stage.key} style={{ display: 'flex', alignItems: 'center' }}>
<span
style={{
padding: '4px 8px',
borderRadius: 6,
fontSize: 11,
fontWeight: 500,
backgroundColor: bgColor,
color: textColor,
whiteSpace: 'nowrap',
}}
>
{stage.label}
</span>
{index < STAGES.length - 1 && (
<span
style={{
marginLeft: 4,
marginRight: 4,
fontSize: 12,
color: '#9ca3af',
}}
>
→
</span>
)}
</div>
)
})}
</div>
)
}
+12 -3
View File
@@ -3,6 +3,7 @@ import { useParams } from 'react-router-dom'
import { getTasks } from '../api/project'
import type { Task } from '../api/types'
import StatusBadge from './StatusBadge'
import PipelineStages from './PipelineStages'
import Skeleton from './Skeleton'
const ASSET_TYPE_LABELS: Record<string, string> = {
@@ -103,9 +104,17 @@ export default function TaskListPanel() {
>
{task.prompt}
</p>
<span style={{ fontSize: 11, color: 'var(--text-muted)', marginTop: 4, display: 'block' }}>
{formatRelativeTime(task.createdAt)}
</span>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 4 }}>
<span style={{ fontSize: 11, color: 'var(--text-muted)' }}>
{formatRelativeTime(task.createdAt)}
</span>
{task.progress !== undefined && task.status === 'running' && (
<span style={{ fontSize: 11, color: 'var(--text-muted)' }}>
{task.progress}%
</span>
)}
</div>
<PipelineStages currentStage={task.stage ?? null} status={task.status} />
</a>
))
)}