迁移调度中心页签;Button 抽出 buttonCls 供站内链接复用、Chip/Check 支持只读与 title
parent
da679e135e
commit
88a05eb189
|
|
@ -62,19 +62,29 @@ type CommonProps = {
|
|||
type ButtonProps = CommonProps & ButtonHTMLAttributes<HTMLButtonElement> & { href?: undefined }
|
||||
type AnchorProps = CommonProps & AnchorHTMLAttributes<HTMLAnchorElement> & { href: string }
|
||||
|
||||
/**
|
||||
* 按钮的样式计算单独拿出来:<Link> / <NavLink> 这类「看起来是按钮的站内链接」
|
||||
* (模型迁移入口、空状态里的「去创建」)复用同一份配方,
|
||||
* 而不是再抄一遍类名 —— 抄的那份永远不会跟着变体调整。
|
||||
*/
|
||||
export function buttonCls(opt: CommonProps & { variant?: ButtonVariant } = {}) {
|
||||
const { variant = 'secondary', size = 'md', square, danger, on, className } = opt
|
||||
return cn(
|
||||
BASE,
|
||||
VARIANTS[variant as ButtonVariant],
|
||||
size !== 'md' && SIZES[size as ButtonSize],
|
||||
square && 'w-(--ctl-h) px-0 text-ui',
|
||||
danger && variant === 'outline' && 'text-danger-bright border-danger-line hover:not-disabled:bg-danger-tint-2',
|
||||
danger && variant === 'ghost' && 'text-danger-bright border-danger-line',
|
||||
danger && variant === 'del' && 'bg-danger border-danger text-danger-ink shadow-raise',
|
||||
on && 'border-accent-line bg-accent-tint text-accent-bright',
|
||||
className
|
||||
)
|
||||
}
|
||||
|
||||
export const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps | AnchorProps>(
|
||||
function Button({ variant = 'secondary', size = 'md', square, danger, on, className, children, ...rest }: any, ref) {
|
||||
const classes = cn(
|
||||
BASE,
|
||||
VARIANTS[variant as ButtonVariant],
|
||||
size !== 'md' && SIZES[size as ButtonSize],
|
||||
square && 'w-(--ctl-h) px-0 text-ui',
|
||||
danger && variant === 'outline' && 'text-danger-bright border-danger-line hover:not-disabled:bg-danger-tint-2',
|
||||
danger && variant === 'ghost' && 'text-danger-bright border-danger-line',
|
||||
danger && variant === 'del' && 'bg-danger border-danger text-danger-ink shadow-raise',
|
||||
on && 'border-accent-line bg-accent-tint text-accent-bright',
|
||||
className
|
||||
)
|
||||
const classes = buttonCls({ variant, size, square, danger, on, className })
|
||||
/* ref 是「按钮或链接」的联合类型,到这里没法收窄,交给 DOM 元素自己判断 */
|
||||
const nodeRef = ref as Ref<any> | undefined
|
||||
if (rest.href !== undefined) {
|
||||
|
|
|
|||
|
|
@ -121,16 +121,21 @@ export function ChipBar({ children, label, className, top }: { children: ReactNo
|
|||
)
|
||||
}
|
||||
|
||||
/** 筛选/开关胶囊(.chip) */
|
||||
/**
|
||||
* 筛选/开关胶囊(.chip)。
|
||||
* 默认是可点的 button;只读计数(调度中心队列旁的「queued 12」那种)传 as="span",
|
||||
* 否则一行里会冒出七八个按了没反应的 Tab 停靠点。
|
||||
*/
|
||||
export function Chip({ active, children, onClick, className, title, disabled, as = 'button', href }: {
|
||||
active?: boolean; children: ReactNode; onClick?: () => void; className?: string; title?: string
|
||||
disabled?: boolean; as?: 'button' | 'a'; href?: string
|
||||
disabled?: boolean; as?: 'button' | 'a' | 'span'; href?: string
|
||||
}) {
|
||||
const classes = cn('inline-flex items-center justify-center gap-[5px] h-(--ctl-h-md) px-2 text-tiny rounded-pill '
|
||||
+ 'border whitespace-nowrap shrink-0 no-underline transition-colors duration-150',
|
||||
active ? 'bg-accent-fill border-accent-fill text-on-accent font-bold'
|
||||
: 'bg-raise border-line-strong text-ink-3 hover:bg-active hover:text-ink',
|
||||
disabled && 'opacity-40 cursor-not-allowed', className)
|
||||
if (as === 'span') return <span title={title} className={classes}>{children}</span>
|
||||
if (as === 'a') return <a href={href} title={title} className={classes}>{children}</a>
|
||||
return <button type="button" title={title} disabled={disabled} onClick={onClick} className={classes}>{children}</button>
|
||||
}
|
||||
|
|
@ -176,11 +181,11 @@ export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra
|
|||
}
|
||||
|
||||
/** 复选(.check):勾选框 + 文案,整块可点 */
|
||||
export function Check({ checked, onChange, children, disabled, className }: {
|
||||
checked: boolean; onChange: (next: boolean) => void; children: ReactNode; disabled?: boolean; className?: string
|
||||
export function Check({ checked, onChange, children, disabled, className, title }: {
|
||||
checked: boolean; onChange: (next: boolean) => void; children: ReactNode; disabled?: boolean; className?: string; title?: string
|
||||
}) {
|
||||
return (
|
||||
<label className={cn('inline-flex flex-row items-center gap-[7px] text-caption text-ink-3 cursor-pointer flex-none whitespace-nowrap', className)}>
|
||||
<label title={title} className={cn('inline-flex flex-row items-center gap-[7px] text-caption text-ink-3 cursor-pointer flex-none whitespace-nowrap', className)}>
|
||||
<input type="checkbox" className="w-auto" checked={checked} disabled={disabled} onChange={(e) => onChange(e.target.checked)} />
|
||||
{children}
|
||||
</label>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,434 @@
|
|||
/** 待迁移:调度中心(占位,见 .local/vue-ref/src/views/tabs/Dispatch.vue) */
|
||||
export default function Dispatch() {
|
||||
return <div className="p-[26px] text-center text-faint text-body">调度中心 迁移中…</div>
|
||||
/**
|
||||
* 调度中心(图2 节点 ④ plan_tasks → ⑪ 派发执行)
|
||||
* 清单怎么算、队列怎么排、心跳谁断了:后端是权威,这一页只负责说人话 + 给按钮。
|
||||
*/
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Link, useSearchParams } from 'react-router-dom'
|
||||
import * as api from '../../api/client'
|
||||
import { fmtAgo, fmtMoney, statusLabel } from '../../lib/format'
|
||||
import { useAutoRefresh } from '../../hooks'
|
||||
import { Select } from '../../components/forms'
|
||||
import {
|
||||
Actions, Between, Button, buttonCls, Check, Chip, ChipBar, Ctlbar, Divider, ErrorText, Field,
|
||||
Layout, MONO, MUTED, MUTED_MONO, Panel, PanelHead, ProgressBar, Row, Spinner, Status, TabStack,
|
||||
Table, TableBox, Tag, cellCenter, cellRight, cellWrap
|
||||
} from '../../components/ui'
|
||||
import { refresh, useProjectStore } from '../../stores/project'
|
||||
import { useSystemStore } from '../../stores/system'
|
||||
import { notify } from '../../stores/notice'
|
||||
|
||||
const QUEUE_STATUSES = ['planned', 'queued', 'running', 'retrying', 'succeeded', 'failed', 'cancelled', 'skipped']
|
||||
const QUEUE_KINDS = ['generate_shot', 'voiceover', 'qc_shot', 'compose', 'import', 'asset']
|
||||
/** 后端 /api/meta 挂了也要能筛:这份兜底只在 meta 缺席时出现 */
|
||||
const FALLBACK_TASK_STATUSES = ['planned', 'queued', 'running', 'retrying', 'waiting_review', 'succeeded', 'failed', 'cancelled', 'skipped']
|
||||
const ACTIVE_STATUSES = ['queued', 'running', 'retrying', 'planned']
|
||||
/** 执行方式是平台内部实现细节,界面只说人话:任务现在怎么跑、什么时候能看到结果 */
|
||||
const EXEC_LABEL: Record<string, string> = { inline: '平台内即时执行', celery: '后台任务队列' }
|
||||
/** 清单动作:后端是三态 enqueue / skip / needs_attention,别把「阻塞」显示成「跳过」 */
|
||||
const ACTION_LABELS: Record<string, string> = { enqueue: '待入队', skip: '跳过', needs_attention: '预检阻塞' }
|
||||
const actionLabel = (a: string) => ACTION_LABELS[a] || a || '—'
|
||||
const EMPTY_CELL = 'text-center py-[22px] leading-[1.7]'
|
||||
|
||||
/** 心跳年龄说成人话:「12 分钟」比「742 秒」更能判断该不该干预。 */
|
||||
function fmtAge(sec?: number | null) {
|
||||
if (sec === null || sec === undefined) return '从未心跳'
|
||||
if (sec < 60) return `${sec} 秒`
|
||||
const m = Math.round(sec / 60)
|
||||
return m < 60 ? `${m} 分钟` : `${Math.floor(m / 60)} 小时 ${m % 60} 分`
|
||||
}
|
||||
|
||||
type Switches = { force: boolean; allow_unready: boolean }
|
||||
|
||||
export default function Dispatch() {
|
||||
const projectId = useProjectStore((s) => s.id)
|
||||
const meta = useSystemStore((s) => s.meta)
|
||||
const [params] = useSearchParams()
|
||||
const [error, setError] = useState('')
|
||||
const [busy, setBusy] = useState('')
|
||||
const [plan, setPlan] = useState<any>(null)
|
||||
const [queue, setQueue] = useState<any>(null)
|
||||
const [tasks, setTasks] = useState<any[]>([])
|
||||
/** 任务状态枚举只认后端 /api/meta(TaskStatus.ALL):状态机加一档,筛选就该跟着长,
|
||||
* 不能再靠这里抄一遍 —— 抄漏的那档会在列表里出现却筛不出来。 */
|
||||
const taskStatusOptions: string[] = (meta?.task_statuses as string[]) || FALLBACK_TASK_STATUSES
|
||||
const [statusFilter, setStatusFilter] = useState('')
|
||||
const [drain, setDrain] = useState(true)
|
||||
const [shotIds, setShotIds] = useState<number[]>([])
|
||||
const [withVoiceover, setWithVoiceover] = useState(true)
|
||||
const [switches, setSwitches] = useState<Switches>({ force: false, allow_unready: false })
|
||||
const [priority, setPriority] = useState(5)
|
||||
const [limit, setLimit] = useState(32)
|
||||
const [timeout_, setTimeout_] = useState(900)
|
||||
|
||||
const counts = queue?.counts || {}
|
||||
const executorLabel = queue?.executor ? (EXEC_LABEL[queue.executor] || queue.executor) : '未知'
|
||||
const activeCount = ACTIVE_STATUSES.reduce((sum, k) => sum + (counts[k] || 0), 0)
|
||||
/** 心跳停更的「进行中」:执行体可能已经没了(服务被杀 / 平台热重载),界面必须说破。 */
|
||||
const staleTasks = tasks.filter((t) => t.stale)
|
||||
const livenessLabel = (() => {
|
||||
const sec = Number(tasks.find((t) => t.stale)?.stale_after_seconds || 0)
|
||||
return sec >= 60 ? `${Math.round(sec / 60)} 分钟` : `${sec} 秒`
|
||||
})()
|
||||
const enqueueable = (plan?.shots || []).filter((s: any) => s.action !== 'skip')
|
||||
const voiceoverable = (plan?.voiceovers || []).filter((v: any) => v.action !== 'skip')
|
||||
/** 队列矩阵按 kind×status 反查,表格里三列循环不必每次都扫一遍数组 */
|
||||
const matrix = useMemo(() => {
|
||||
const map = new Map<string, any>()
|
||||
for (const row of queue?.matrix || []) map.set(`${row.kind}|${row.status}`, row)
|
||||
return map
|
||||
}, [queue])
|
||||
|
||||
/** load 里要按「当前」的强制/放行开关问后端,但它们又不该进依赖数组
|
||||
* (否则每勾一次就把整页三张表重新拉一遍),所以留一份 ref 给闭包用。 */
|
||||
const switchesRef = useRef(switches)
|
||||
switchesRef.current = switches
|
||||
|
||||
// 清单必须按当前这几个开关去问后端:后端算 skip/enqueue 看的正是 force/allow_unready。
|
||||
// 以前固定不带 force 去读,已生成或已审核合格的镜头永远显示「跳过」,
|
||||
// 加上下面 skip 行不许勾选,用户从分镜点「重新生成」过来就一个都选不动。
|
||||
const load = useCallback(async (silent = true, sw?: Switches) => {
|
||||
if (!projectId) return null
|
||||
const gates = sw ?? switchesRef.current
|
||||
if (!silent) setBusy('读取队列')
|
||||
try {
|
||||
const [pl, qu, tk] = await Promise.all([
|
||||
api.get(`/api/projects/${projectId}/tasklist`, { force: gates.force, allow_unready: gates.allow_unready }),
|
||||
api.get(`/api/projects/${projectId}/queue`),
|
||||
api.get('/api/tasks', { project_id: projectId, status: statusFilter })
|
||||
])
|
||||
setPlan(pl.plan)
|
||||
setQueue(qu)
|
||||
setTasks(tk.tasks || [])
|
||||
setError('')
|
||||
return pl.plan
|
||||
} catch (exc: any) { setError(exc?.message || String(exc)); return null }
|
||||
finally { setBusy('') }
|
||||
}, [projectId, statusFilter])
|
||||
|
||||
async function run(label: string, fn: () => Promise<any>, message?: (res: any) => string) {
|
||||
setBusy(label); setError('')
|
||||
try {
|
||||
const res = await fn()
|
||||
const text = message ? message(res) : ''
|
||||
if (text) notify(text)
|
||||
await Promise.all([load(), refresh()])
|
||||
return res
|
||||
} catch (exc: any) { setError(exc?.message || String(exc)); return null }
|
||||
finally { setBusy('') }
|
||||
}
|
||||
|
||||
/** 勾选「强制重建 / 放行未就绪」后清单要重算,否则「动作」列还是按旧开关显示跳过。
|
||||
* 只监听这两个开关:load 的函数身份也随状态筛选变化,写进依赖会多发一次请求。 */
|
||||
const booted = useRef(false)
|
||||
useEffect(() => {
|
||||
if (!booted.current) { booted.current = true; return }
|
||||
void load()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [switches.force, switches.allow_unready])
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true
|
||||
;(async () => {
|
||||
// 分镜工作台卡片上的「▷ 生成 / ↻ 重生成」带 ?shot= 过来时,预勾选该镜头,避免误伤整批。
|
||||
// 带 force=1 说明来意就是**重做这一镜**:它的产物已经存在,后端默认判 skip,
|
||||
// 不先把强制打开,这一镜在清单里根本选不动。
|
||||
const want = Number(params.get('shot') || 0)
|
||||
const wantForce = !!want && Number(params.get('force') || 0) === 1
|
||||
if (wantForce) setSwitches((s) => ({ ...s, force: true }))
|
||||
const pl = await load(false, { force: wantForce, allow_unready: false })
|
||||
if (!alive) return
|
||||
const row = (pl?.shots || []).find((s: any) => s.shot_id === want)
|
||||
if (!row) return
|
||||
setShotIds([want])
|
||||
if (row.action === 'skip') {
|
||||
notify(`镜头 #${row.order_index} 暂不需要生成:${row.reason}。勾上「强制重建任务」就能只重做它`)
|
||||
} else {
|
||||
notify(`已勾选镜头 #${row.order_index},点「入队所选」即可只生成这一镜`)
|
||||
}
|
||||
})()
|
||||
return () => { alive = false }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [projectId])
|
||||
|
||||
/* 队列里有活就 4 秒看一次;空闲时不必反复敲后端 */
|
||||
useAutoRefresh(() => void load(), 4000, !!busy, false)
|
||||
|
||||
/** 派发/入队返回的 blocked[]:模型停用或并发·RPM 额度用尽时说明「为什么没动」 */
|
||||
function blockedNote(r: any) {
|
||||
const blocked = r?.dispatched?.blocked || []
|
||||
return blocked.length ? `;${blocked.length} 个模型暂不可派发:`
|
||||
+ blocked.map((b: any) => `${b.provider_model}(${b.reason})`).join(';') : ''
|
||||
}
|
||||
|
||||
const enqueue = () => run('生成任务并入队', () => api.post(`/api/projects/${projectId}/tasks`, {
|
||||
shot_ids: shotIds.length ? shotIds : null, force: switches.force, allow_unready: switches.allow_unready,
|
||||
priority, with_voiceover: withVoiceover, actor: 'studio'
|
||||
}), (r) => `已入队 ${r?.created?.count ?? 0} 个任务(其中配音 ${(r?.created?.voiceovers || []).length},`
|
||||
+ `跳过 ${(r?.created?.skipped || []).length} —— 跳过原因见清单「动作」列` + blockedNote(r))
|
||||
|
||||
const buildVoiceover = () => run('生成配音任务', () => api.post(`/api/projects/${projectId}/voiceover`, {
|
||||
shot_ids: null, only_missing: true, priority: 4
|
||||
}), (r) => `已创建 ${r?.count ?? 0} 条配音任务`)
|
||||
|
||||
const doDispatch = () => run(drain ? '派发并排空队列' : '派发任务', () => api.post(`/api/projects/${projectId}/dispatch`, {
|
||||
limit, drain, timeout: timeout_
|
||||
}), (r) => drain
|
||||
? `本轮派发 ${r?.dispatched?.count ?? 0} 个,排空期间跑完 `
|
||||
+ `${r?.drained?.completed_during_drain ?? 0} 个(终态累计 ${r?.drained?.completed ?? 0})`
|
||||
+ (r?.drained?.remaining ? `,仍在队列 ${r.drained.remaining} 个` : ',队列已清空')
|
||||
+ (r?.drained?.timed_out ? '(等待超时,可加大「排空等待」或再点一次)' : '')
|
||||
+ (r?.drained?.stalled
|
||||
? `;已停滞:${(r.drained.stalled_detail?.blocked || []).map((b: any) => `${b.provider_model} ${b.reason}`).join(';')}`
|
||||
: '')
|
||||
+ blockedNote(r)
|
||||
: `已派发 ${r?.dispatched?.count ?? 0} 个任务${blockedNote(r)}`)
|
||||
|
||||
const retryFailed = () => run('重排失败任务', () => api.post(`/api/projects/${projectId}/tasks/retry-failed`, { reset_attempts: true }), (r) => `重新入队 ${r?.count ?? 0} 个失败任务`)
|
||||
const cancelActive = () => run('取消进行中的任务', () => api.post(`/api/projects/${projectId}/tasks/cancel-active`, { reason: '人工在调度中心取消' }), (r) => `已取消 ${r?.count ?? 0} 个任务`)
|
||||
const resume = () => run('断点续跑', () => api.post(`/api/projects/${projectId}/resume`, {}), (r) => `恢复中断任务 ${r?.resume?.count ?? 0} 个,本进程已接手 ${(r?.recovered_here || []).length} 个`)
|
||||
|
||||
const retryTask = (t: any) => run('重试任务', () => api.post(`/api/tasks/${t.id}/retry`, {}), () => `任务 #${t.id} 已重新入队`)
|
||||
const cancelTask = (t: any) => run('取消任务', () => api.post(`/api/tasks/${t.id}/cancel`, { reason: '人工取消' }), () => `任务 #${t.id} 已取消`)
|
||||
|
||||
function toggleShot(id: number) {
|
||||
setShotIds((list) => (list.includes(id) ? list.filter((x) => x !== id) : [...list, id]))
|
||||
}
|
||||
|
||||
return (
|
||||
<TabStack>
|
||||
<Between>
|
||||
<Row>
|
||||
<Tag tone="info">任务执行:{executorLabel}</Tag>
|
||||
{Object.entries(counts).map(([k, v]) => <Chip key={k} as="span">{statusLabel(k)} {String(v)}</Chip>)}
|
||||
{!activeCount && <span className={MUTED}>队列空闲</span>}
|
||||
</Row>
|
||||
<Row>{busy ? <span className={MUTED}><Spinner /> {busy}…</span> : null}</Row>
|
||||
</Between>
|
||||
<ErrorText>{error}</ErrorText>
|
||||
|
||||
{/* ===== 任务清单(图2 节点④ plan_tasks) ===== */}
|
||||
<Layout>
|
||||
<Panel>
|
||||
<PanelHead eyebrow="PIPELINE · 生成分镜任务清单" title="分镜任务清单"
|
||||
right={<><span className={MUTED}>预计成本 {fmtMoney(plan?.estimated_cost, plan?.currency)}</span>
|
||||
<Button variant="primary" disabled={!!busy} onClick={enqueue}>▶ 入队所选 / 全部待生成</Button></>} />
|
||||
<ChipBar>
|
||||
<Chip as="span">待入队 {enqueueable.length}</Chip>
|
||||
<Chip as="span">配音待生成 {voiceoverable.length}</Chip>
|
||||
<Chip as="span">已排队 {plan?.queued_count || 0}</Chip>
|
||||
<Chip as="span">阻塞 {plan?.blocked_count || 0}</Chip>
|
||||
<Chip as="span">跳过 {plan?.skipped_count || 0}</Chip>
|
||||
<Chip as="span">预检就绪 {plan?.preflight?.ready || 0}</Chip>
|
||||
<Chip as="span">预检告警 {plan?.preflight?.warnings || 0}</Chip>
|
||||
<Chip as="span">预计 {plan?.voiceover_count || 0} 条配音</Chip>
|
||||
</ChipBar>
|
||||
<TableBox maxHeight={360}>
|
||||
<Table minWidth={860}>
|
||||
<thead>
|
||||
<tr><th className={`${cellCenter} w-[34px]`}>#</th><th>镜头</th><th>动作</th><th>Provider / 模型</th>
|
||||
<th className={cellRight}>时长</th><th className={cellRight}>预估成本</th><th>说明</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(plan?.shots || []).map((s: any) => (
|
||||
<tr key={s.shot_id}>
|
||||
<td className={cellCenter}>
|
||||
<input type="checkbox" className="w-auto" aria-label={`选择镜头 ${s.order_index}`}
|
||||
checked={shotIds.includes(s.shot_id)} disabled={s.action === 'skip' && !switches.force}
|
||||
onChange={() => toggleShot(s.shot_id)} />
|
||||
</td>
|
||||
<td><b>#{s.order_index}</b> {s.title}<div className={MUTED_MONO}>shot#{s.shot_id}</div></td>
|
||||
<td><Tag tone={s.action === 'enqueue' ? 'ok' : s.action === 'needs_attention' ? 'bad' : 'warn'}>{actionLabel(s.action)}</Tag></td>
|
||||
<td className={`${MONO} ${MUTED}`}>{s.provider || '—'} / {s.model || '默认'}</td>
|
||||
<td className={`${cellRight} ${MONO}`}>{s.duration}s</td>
|
||||
<td className={`${cellRight} ${MONO}`}>{fmtMoney(s.estimated_cost)}</td>
|
||||
<td className={`${cellWrap} ${MUTED}`}>{s.reason}
|
||||
{s.blocking?.length ? <span className="text-danger"> 阻塞:{s.blocking.join(';')}</span> : null}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{(plan?.voiceovers || []).map((v: any) => (
|
||||
<tr key={`v${v.shot_id}`}>
|
||||
<td className={cellCenter}>🔊</td>
|
||||
<td><b>#{v.order_index}</b> 配音<div className={MUTED_MONO}>shot#{v.shot_id}</div></td>
|
||||
<td><Tag tone={v.action !== 'skip' ? 'ok' : 'default'}>{v.action !== 'skip' ? '待配音' : '跳过'}</Tag></td>
|
||||
<td className={`${MONO} ${MUTED}`}>TTS</td>
|
||||
<td className={`${cellRight} ${MONO}`}>{v.chars} 字</td>
|
||||
<td className={`${cellRight} ${MONO}`}>—</td>
|
||||
<td className={`${cellWrap} ${MUTED}`}>{v.reason}</td>
|
||||
</tr>
|
||||
))}
|
||||
{!(plan?.shots || []).length && !(plan?.voiceovers || []).length
|
||||
? <tr><td colSpan={7} className={`${MUTED} ${EMPTY_CELL}`}>还没有分镜清单,先去「分镜工作台」拆镜头。</td></tr> : null}
|
||||
</tbody>
|
||||
</Table>
|
||||
</TableBox>
|
||||
</Panel>
|
||||
|
||||
<Panel>
|
||||
<h3>调度控制</h3>
|
||||
<Ctlbar>
|
||||
<Check checked={withVoiceover} onChange={setWithVoiceover}>入队时一并排配音任务</Check>
|
||||
<Check checked={switches.allow_unready} onChange={(v) => setSwitches((s) => ({ ...s, allow_unready: v }))}>放行预检未通过的镜头(默认只跳过它们)</Check>
|
||||
<Check title="忽略「产物已存在 / 已审核合格 / 已在队列」这三类跳过判定,也忽略幂等键。要单独重做某一镜就得勾它"
|
||||
checked={switches.force} onChange={(v) => setSwitches((s) => ({ ...s, force: v }))}>强制重建任务(忽略幂等,可重做已生成的镜头)</Check>
|
||||
<Field label="优先级" width="narrow">
|
||||
<input type="number" min={0} max={9} aria-label="任务优先级"
|
||||
value={priority} onChange={(e) => setPriority(Number(e.target.value))} />
|
||||
</Field>
|
||||
</Ctlbar>
|
||||
<Divider />
|
||||
<Ctlbar>
|
||||
<Check title="勾选「派发后同步排空」会一直等到任务执行结束再返回,适合小批量验证;不勾选时任务留在队列后台执行,页面自动刷新进度。"
|
||||
checked={drain} onChange={setDrain}>派发后同步排空(等任务跑完再返回)</Check>
|
||||
<Field label="单次派发上限" width="narrow">
|
||||
<input type="number" min={1} max={256} aria-label="单次派发上限"
|
||||
value={limit} onChange={(e) => setLimit(Number(e.target.value))} />
|
||||
</Field>
|
||||
<Field label="排空等待(秒)" width="narrow">
|
||||
<input type="number" min={30} max={7200} aria-label="排空等待秒数"
|
||||
value={timeout_} onChange={(e) => setTimeout_(Number(e.target.value))} />
|
||||
</Field>
|
||||
</Ctlbar>
|
||||
<Actions>
|
||||
<Button variant="primary" disabled={!!busy} onClick={doDispatch}>⇶ {drain ? '派发并排空队列' : '只派发'}</Button>
|
||||
<Button variant="secondary" disabled={!!busy} onClick={buildVoiceover}>🔊 批量生成配音</Button>
|
||||
</Actions>
|
||||
<Divider />
|
||||
<h3 className="mt-0">异常处理</h3>
|
||||
<Actions>
|
||||
<Button variant="outline" disabled={!!busy} onClick={retryFailed}>↺ 重排全部失败任务</Button>
|
||||
<Button variant="outline" disabled={!!busy} onClick={resume}>⏱ 断点续跑(恢复中断)</Button>
|
||||
<Button variant="outline" disabled={!!busy} onClick={cancelActive}>✕ 取消进行中任务</Button>
|
||||
</Actions>
|
||||
</Panel>
|
||||
</Layout>
|
||||
|
||||
{/* ===== 队列与容量 ===== */}
|
||||
<Layout>
|
||||
<Panel>
|
||||
<PanelHead eyebrow="QUEUE MATRIX" title="队列状态" />
|
||||
<TableBox maxHeight={false}>
|
||||
<Table minWidth={760}>
|
||||
<thead>
|
||||
<tr><th>任务类型</th>
|
||||
{QUEUE_STATUSES.map((st) => <th key={st} className={cellCenter}>{statusLabel(st)}</th>)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{QUEUE_KINDS.map((kind) => (
|
||||
<tr key={kind}>
|
||||
<td><b>{statusLabel(kind)}</b></td>
|
||||
{QUEUE_STATUSES.map((st) => {
|
||||
const hit = matrix.get(`${kind}|${st}`)
|
||||
return <td key={st} className={`${cellCenter} ${MONO}`}>{hit ? <Tag tone="ok">{hit.count || ''}</Tag> : null}</td>
|
||||
})}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</Table>
|
||||
</TableBox>
|
||||
</Panel>
|
||||
|
||||
<Panel>
|
||||
<PanelHead eyebrow="CAPACITY" title="模型并发与限流" />
|
||||
<TableBox maxHeight={false}>
|
||||
<Table minWidth={560}>
|
||||
<thead>
|
||||
<tr><th>Provider / 模型</th><th className={cellCenter}>运行</th><th className={cellCenter}>排队</th>
|
||||
<th className={cellCenter}>槽位</th><th className={cellCenter}>RPM 余量</th><th>状态</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(queue?.capacity || []).map((c: any) => (
|
||||
<tr key={`${c.provider}${c.model}${c.media_type}`}>
|
||||
<td className={MONO}>{c.provider} / {c.model || '默认'}<div className={MUTED}>{c.media_type}</div></td>
|
||||
<td className={`${cellCenter} ${MONO}`}>{c.running}</td>
|
||||
<td className={`${cellCenter} ${MONO}`}>{c.queued}</td>
|
||||
<td className={`${cellCenter} ${MONO}`}>{c.slots}/{c.concurrency_limit}</td>
|
||||
<td className={`${cellCenter} ${MONO}`}>{c.rpm_headroom}</td>
|
||||
<td><Tag tone={!c.enabled ? 'bad' : c.saturated ? 'warn' : 'ok'}>{!c.enabled ? '已停用' : c.saturated ? '已满负荷' : '可用'}</Tag></td>
|
||||
</tr>
|
||||
))}
|
||||
{!(queue?.capacity || []).length
|
||||
? <tr><td colSpan={6} className={`${MUTED} ${EMPTY_CELL}`}>没有登记并发的模型:所有任务按默认额度执行。</td></tr> : null}
|
||||
</tbody>
|
||||
</Table>
|
||||
</TableBox>
|
||||
</Panel>
|
||||
</Layout>
|
||||
|
||||
{/* ===== 任务列表 ===== */}
|
||||
<Panel>
|
||||
<PanelHead eyebrow="TASKS"
|
||||
title={<>任务执行明细({tasks.length})
|
||||
{staleTasks.length ? <Tag tone="warn" className="ml-2">{staleTasks.length} 条心跳已停止</Tag> : null}
|
||||
</>}
|
||||
sub={staleTasks.length
|
||||
? <>这些任务的执行体超过 {livenessLabel}没有报活:多半是那台机器上的模型服务或平台进程中断过。
|
||||
产物与断点都留着,平台回收后会自动续跑;着急就点上方「断点续跑」立即处理。</>
|
||||
: undefined}
|
||||
right={<Ctlbar as="div" className="mb-0">
|
||||
<Field label="状态" width="narrow">
|
||||
<Select size="sm" ariaLabel="任务状态筛选" value={statusFilter} onChange={setStatusFilter}
|
||||
options={[{ value: '', label: '全部状态' }, ...taskStatusOptions.map((s) => ({ value: s, label: statusLabel(s) }))]} />
|
||||
</Field>
|
||||
</Ctlbar>} />
|
||||
<TableBox>
|
||||
<Table minWidth={1180}>
|
||||
<thead>
|
||||
<tr><th>ID</th><th>任务</th><th>镜头</th><th>后端</th><th className={cellCenter}>尝试</th>
|
||||
<th className={cellCenter}>进度</th><th className={cellRight}>耗时</th><th>状态</th><th>错误 / 检查点</th><th className={cellRight}>操作</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{tasks.map((t: any) => (
|
||||
<tr key={t.id}>
|
||||
<td className={MONO}>#{t.id}</td>
|
||||
<td>{t.name}<div className={MUTED_MONO}>{statusLabel(t.kind)} · {t.stage}</div></td>
|
||||
<td className={MONO}>{t.shot_id ? `#${t.shot_id}` : t.timeline_id ? `时间线#${t.timeline_id}` : '—'}</td>
|
||||
<td className={`${MONO} ${MUTED}`}>{statusLabel(t.execution_backend)}
|
||||
{t.worker_id ? <div className={MUTED}>{t.worker_id}</div> : null}
|
||||
</td>
|
||||
<td className={`${cellCenter} ${MONO}`}>{t.attempts}/{t.max_attempts}</td>
|
||||
<td className={cellCenter}><ProgressBar value={Math.round((t.progress || 0) * 100)} /></td>
|
||||
<td className={`${cellRight} ${MONO}`}>{t.elapsed_ms ? `${(t.elapsed_ms / 1000).toFixed(1)}s`
|
||||
: t.queue_wait_ms ? `排队 ${(t.queue_wait_ms / 1000).toFixed(1)}s` : '—'}</td>
|
||||
<td><Status value={t.status} />
|
||||
<div className={MUTED}>{fmtAgo(t.updated_at)}</div>
|
||||
{t.stale
|
||||
? <div className="mt-1 max-w-[190px] text-[11px] leading-[1.45] text-warn-bright">⚠ 心跳已停止 {fmtAge(t.heartbeat_age_seconds)}:可能已中断,不会永远转圈</div>
|
||||
: null}
|
||||
</td>
|
||||
<td className={cellWrap}>
|
||||
{t.error_message ? <span className="text-danger">{t.error_code} {t.error_message}</span> : null}
|
||||
{t.checkpoint?.last_note ? <div className={MUTED}>{t.checkpoint.last_note}</div>
|
||||
: Object.keys(t.checkpoint || {}).length ? <div className={MUTED_MONO}>checkpoint: {JSON.stringify(t.checkpoint).slice(0, 90)}</div> : null}
|
||||
{t.output_url ? <a className="text-success text-caption no-underline hover:underline" href={t.output_url} target="_blank" rel="noreferrer">产物 ↗</a> : null}
|
||||
</td>
|
||||
<td className={cellRight}>
|
||||
<Row className="justify-end">
|
||||
{['failed', 'cancelled'].includes(t.status)
|
||||
? <Button variant="outline" size="sm" onClick={() => retryTask(t)}>重试</Button> : null}
|
||||
{ACTIVE_STATUSES.includes(t.status)
|
||||
? <Button variant="outline" size="sm" onClick={() => cancelTask(t)}>取消</Button> : null}
|
||||
{t.status === 'succeeded' || t.status === 'skipped' ? <span className={MUTED}>—</span> : null}
|
||||
</Row>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{!tasks.length
|
||||
? <tr><td colSpan={10} className={`${MUTED} ${EMPTY_CELL}`}>暂无任务,先在上方生成任务清单并入队。</td></tr> : null}
|
||||
</tbody>
|
||||
</Table>
|
||||
</TableBox>
|
||||
</Panel>
|
||||
|
||||
<Panel className="flex justify-between items-center gap-5 flex-wrap max-tiny:flex-col max-tiny:items-start">
|
||||
<div className="min-w-0">
|
||||
<div className="text-tiny tracking-[1.6px] text-muted font-bold">MODEL REGISTRY</div>
|
||||
<h2 className="mt-[5px] mb-0 text-h2 font-bold">模型配置已迁移至独立管理中心</h2>
|
||||
</div>
|
||||
<Link to="/models" title="统一维护大模型、图像、视频与声音模型的适配器、默认项、并发、限流、价格、能力与连接探测。调度中心只负责项目任务编排与执行。"
|
||||
className={buttonCls({ variant: 'primary', className: 'no-underline' })}>打开模型管理中心 →</Link>
|
||||
</Panel>
|
||||
</TabStack>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue