Refactor pipeline task handling and UI flows

This commit is contained in:
2026-06-13 21:09:49 +02:00
parent 21c7e4c9a4
commit ff4c572157
24 changed files with 1346 additions and 236 deletions

View File

@@ -132,10 +132,22 @@ export const followUpDraftSchema = z.object({
goals: z.array(z.string()).nullable(),
});
export const qualityReviewRevisedCopySchema = z.object({
publicSummary: nonEmptyTextSchema,
publicBody: nonEmptyTextSchema,
emailSubject: nonEmptyTextSchema,
emailBody: nonEmptyTextSchema,
phoneScript: callScriptSchema,
followUpDraft: followUpDraftSchema,
});
export const qualityReviewSchema = z.object({
isValid: z.boolean(),
severity: z.enum(["ok", "warning", "unsafe"]),
issues: z.array(z.string()),
suggestions: z.array(z.string()),
rewriteRequired: z.boolean(),
revisedCopy: qualityReviewRevisedCopySchema.nullable(),
notes: z.array(z.string()).nullable(),
});
@@ -154,4 +166,5 @@ export type EmailDraft = z.infer<typeof emailDraftSchema>;
export type EmailSubject = z.infer<typeof emailSubjectSchema>;
export type CallScript = z.infer<typeof callScriptSchema>;
export type FollowUpDraft = z.infer<typeof followUpDraftSchema>;
export type QualityReviewRevisedCopy = z.infer<typeof qualityReviewRevisedCopySchema>;
export type QualityReview = z.infer<typeof qualityReviewSchema>;

75
lib/audits/progress.ts Normal file
View File

@@ -0,0 +1,75 @@
export const AUDIT_PROGRESS_TOTAL_STEPS = 6;
export type AuditProgress = {
step: number;
total: number;
label: string;
percent: number;
};
const fallbackProgress: AuditProgress = {
step: 1,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Audit vorbereitet",
percent: 17,
};
const progressByStep: Record<string, AuditProgress> = {
audit_prepared: fallbackProgress,
pagespeed_insights: {
step: 2,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Messe PageSpeed",
percent: 33,
},
website_signals: {
step: 3,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Sammle Website-Signale",
percent: 50,
},
classification: {
step: 4,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Bewerte Befunde",
percent: 67,
},
evidenceVerifier: {
step: 4,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Bewerte Befunde",
percent: 67,
},
multimodalAudit: {
step: 4,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Bewerte Befunde",
percent: 67,
},
germanCopy: {
step: 5,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Erstelle Texte",
percent: 83,
},
qualityReview: {
step: 6,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Speichere Audit",
percent: 100,
},
persist_audit: {
step: 6,
total: AUDIT_PROGRESS_TOTAL_STEPS,
label: "Speichere Audit",
percent: 100,
},
};
export function getAuditProgressForStep(step: string | null | undefined) {
if (!step) {
return fallbackProgress;
}
return progressByStep[step] ?? fallbackProgress;
}