feat: 实现剧本创作与拆解前端工作台
This commit is contained in:
1 parent
edc003443f
commit
2ee6f049f6
56 files changed
+7597
-2
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import type { BreakdownState } from '../breakdown/types'
|
||||
import type { Checkpoint } from './types'
|
||||
|
||||
/** 按工作流隔离并排序,后端数组顺序变化不会影响恢复判断。 */
|
||||
export function workflowCheckpoints(checkpoints: Checkpoint[], name: string): Checkpoint[] {
|
||||
return checkpoints
|
||||
.filter(item => item.workflowName === name)
|
||||
.toSorted((a, b) => Date.parse(a.createdAt) - Date.parse(b.createdAt))
|
||||
}
|
||||
|
||||
/** 失败快照可能只有错误;回看最近有效状态,同时只使用最新记录的执行状态。 */
|
||||
export function breakdownSnapshot(checkpoints: Checkpoint[]): BreakdownState | null {
|
||||
const records = workflowCheckpoints(checkpoints, 'breakdown')
|
||||
const latest = records.at(-1)
|
||||
if (!latest) return null
|
||||
const data =
|
||||
records
|
||||
.slice(-30)
|
||||
.toReversed()
|
||||
.find(item => item.state.runConfig || item.state.breakdownResult || item.state.storyboardPlans?.length)
|
||||
?.state ?? {}
|
||||
return { ...data, workflowExecution: latest.state.workflowExecution }
|
||||
}
|
||||
|
||||
/** 根据最近后端可恢复窗口推导操作;页面仍需先确认任务已经结束。 */
|
||||
export function recoveryOptions(checkpoints: Checkpoint[]) {
|
||||
const records = workflowCheckpoints(checkpoints, 'breakdown').toReversed()
|
||||
const retry = records.slice(0, 10).some(item => item.state.tasks?.some(task => task.status === 'failed'))
|
||||
const shots = records
|
||||
.slice(0, 30)
|
||||
.some(({ state }) =>
|
||||
Boolean(
|
||||
state.storyboardPlans?.length &&
|
||||
state.subjectCandidates?.length &&
|
||||
state.subjectForms &&
|
||||
(state.storyboardEpisodeShots?.length ?? 0) < state.storyboardPlans.length
|
||||
)
|
||||
)
|
||||
const storyboard = records
|
||||
.slice(0, 10)
|
||||
.some(({ state }) =>
|
||||
Boolean(state.storyboardEpisodeShots?.length && state.subjectCandidates?.length && state.subjectForms)
|
||||
)
|
||||
return { retry, shots, storyboard }
|
||||
}
|
||||
Reference in new issue
Block a user