feat(canvas): 画布媒体工作流 - 支持批量连线、失败重试与模型能力增强

合并 PR #230。保留当前主线样式与组件结构,吸收批量连线、失败批次重试、媒体模型能力和相关后端增强,并修复集成检查发现的分辨率选择器启用条件与测试稳定性问题。
This commit is contained in:
WindC0X authored and GitHub committed 2026-08-15 15:48:16 +08:00
1 parent b0c3159f8e
commit 0e251c3c8f
48 files changed
+1582 -83

No files matched your search

+22 -1
View File
@@ -1175,6 +1175,7 @@ func (s *Service) processAgentStoryboardTask(ctx context.Context, task model.Tas
text, _ := result["text"].(string)
plan, err := parseAgentStoryboardPlan(text)
if err == nil {
normalizeAutomaticStoryboardDurations(&plan, 0)
err = validateStoryboardPlan(plan, 0, 0, input.Characters)
}
if err != nil {
@@ -1183,6 +1184,9 @@ func (s *Service) processAgentStoryboardTask(ctx context.Context, task model.Tas
return nil, nil, err
}
}
if complexityErr := validateStoryboardComplexity(plan); complexityErr != nil {
_ = s.log(task.UserID, task.ID, "warn", "分镜复杂度建议", complexityErr.Error())
}
return s.buildAgentStoryboardResult(task, plan, assets, input.ProjectStyle)
}
@@ -1219,6 +1223,7 @@ func (s *Service) processStoryboardRowsTask(ctx context.Context, task model.Task
text, _ := result["text"].(string)
plan, err := parseAgentStoryboardPlan(text)
if err == nil {
normalizeAutomaticStoryboardDurations(&plan, input.ShotDuration)
err = validateStoryboardPlan(plan, input.ShotDuration, input.ShotCount, input.Characters)
}
if err != nil {
@@ -1227,6 +1232,9 @@ func (s *Service) processStoryboardRowsTask(ctx context.Context, task model.Task
return nil, nil, err
}
}
if complexityErr := validateStoryboardComplexity(plan); complexityErr != nil {
_ = s.log(task.UserID, task.ID, "warn", "分镜复杂度建议", complexityErr.Error())
}
rows := make([]map[string]any, 0, len(plan.Shots))
for index, shot := range plan.Shots {
imagePromptVariables := storyboardImagePromptValues(input.ProjectStyle.Prompt, plan.StyleGuide, shot)
@@ -1277,6 +1285,7 @@ func (s *Service) repairStoryboardPlan(ctx context.Context, task model.Task, inp
repairedText, _ := repaired["text"].(string)
plan, parseErr := parseAgentStoryboardPlan(repairedText)
if parseErr == nil {
normalizeAutomaticStoryboardDurations(&plan, shotDuration)
parseErr = validateStoryboardPlan(plan, shotDuration, shotCount, input.Characters)
}
if parseErr == nil {
@@ -1420,7 +1429,7 @@ func validateStoryboardPlan(plan agentStoryboardPlan, shotDuration int, shotCoun
if err := validateStoryboardCharacterIDs(plan, characters); err != nil {
return err
}
return validateStoryboardComplexity(plan)
return nil
}
func validateStoryboardShotCount(plan agentStoryboardPlan, target int) error {
@@ -1463,6 +1472,18 @@ func validateStoryboardComplexity(plan agentStoryboardPlan) error {
return fmt.Errorf("镜头复杂度超限:%s", strings.Join(issues, ";"))
}
func normalizeAutomaticStoryboardDurations(plan *agentStoryboardPlan, target int) {
if plan == nil || target != 0 {
return
}
for index := range plan.Shots {
shot := &plan.Shots[index]
dialogueLength := utf8.RuneCountInString(strings.TrimSpace(shot.Dialogue))
requiredDuration := (dialogueLength + 4) / 5
shot.Duration = min(60, max(1, shot.Duration, requiredDuration))
}
}
func validateStoryboardCharacterIDs(plan agentStoryboardPlan, characters []storyboardCharacterCard) error {
allowed := make(map[string]bool, len(characters))
for _, character := range characters {