feat(ai): 优化拆解重跑与结果展示

This commit is contained in:
Script Generator
2026-06-26 11:01:11 +08:00
parent 55e24442ab
commit 56e0fe562d
36 changed files with 1342 additions and 186 deletions

View File

@@ -1,11 +1,17 @@
import type { VersionPlan } from './version-plan';
import type { ProductPlanKind, ProductPlanReviewFailureType, ProductPlanReviewResult, VersionPlan } from './version-plan';
export interface PlanResultPayload {
type?: VersionPlan['type'];
productPlanKind?: ProductPlanKind;
resultType?: 'link' | 'file';
resultTitle?: string;
resultUrl?: string;
resultFileName?: string;
resultFileData?: string;
prototypeReviewConfirmed?: boolean;
reviewResult?: ProductPlanReviewResult;
reviewFailureTypes?: ProductPlanReviewFailureType[];
reviewFailureReason?: string;
}
export interface PlanCompletionState {
@@ -20,6 +26,23 @@ export interface PlanCompletionState {
}
export function hasPlanResult(plan: PlanResultPayload): boolean {
if (plan.productPlanKind === 'review') {
if (plan.reviewResult === 'passed') return true;
if (plan.reviewResult === 'failed') {
return Boolean(plan.reviewFailureTypes?.length && plan.reviewFailureReason?.trim());
}
return false;
}
if (plan.productPlanKind === 'design') {
return Boolean(
plan.resultType === 'link'
&& plan.resultTitle?.trim()
&& plan.resultUrl?.trim()
&& plan.prototypeReviewConfirmed,
);
}
const hasTitle = Boolean(plan.resultTitle?.trim());
if (!hasTitle || !plan.resultType) return false;
if (plan.resultType === 'link') return Boolean(plan.resultUrl?.trim());
@@ -34,6 +57,11 @@ function requiresChecklist(plan: VersionPlan): boolean {
return plan.type === 'research';
}
function getProductPlanKind(plan: VersionPlan): ProductPlanKind | undefined {
if (plan.type !== 'product') return undefined;
return plan.productPlanKind ?? 'design';
}
export function getPlanCompletionState(plan: VersionPlan): PlanCompletionState {
const tasks = plan.tasks ?? [];
const checklistTotal = tasks.length;
@@ -52,8 +80,25 @@ export function getPlanCompletionState(plan: VersionPlan): PlanCompletionState {
}
const canSubmitResult = missingReasons.length === 0;
const hasResult = hasPlanResult(plan);
if (canSubmitResult && !hasResult) missingReasons.push('尚未提交成果');
const productPlanKind = getProductPlanKind(plan);
const resultPlan = productPlanKind ? { ...plan, productPlanKind } : plan;
const hasResult = hasPlanResult(resultPlan);
if (canSubmitResult && !hasResult) {
if (productPlanKind === 'design') {
if (plan.resultType === 'file') missingReasons.push('产品设计方案只支持原型链接');
if (plan.resultType === 'link' && plan.resultUrl?.trim() && !plan.prototypeReviewConfirmed) {
missingReasons.push('请先确认方案评审已通过');
} else {
missingReasons.push('尚未提交原型链接');
}
} else if (productPlanKind === 'review') {
if (!plan.reviewResult) missingReasons.push('请选择评审结论');
if (plan.reviewResult === 'failed' && !plan.reviewFailureTypes?.length) missingReasons.push('请选择评审不通过类型');
if (plan.reviewResult === 'failed' && !plan.reviewFailureReason?.trim()) missingReasons.push('请填写评审不通过原因');
} else {
missingReasons.push('尚未提交成果');
}
}
return {
checklistTotal,