fix: show proper error messages in speaking script generation instead of empty []
Made-with: Cursor
This commit is contained in:
@@ -294,10 +294,18 @@ export default function GenerationPage() {
|
||||
mutationFn: (params: { topics: string[]; difficulty: string; partIndex: number }) =>
|
||||
generationService.generateSpeakingScript({ topics: params.topics.filter(Boolean), difficulty: params.difficulty, part: "speaking_1" }),
|
||||
onSuccess: (res, vars) => {
|
||||
const r = res as Record<string, unknown>;
|
||||
if (r.error) {
|
||||
toast({ variant: "destructive", title: "Script generation failed", description: String(r.error) });
|
||||
return;
|
||||
}
|
||||
const st = getModuleState("speaking");
|
||||
const parts = [...st.speakingParts];
|
||||
const r = res as Record<string, unknown>;
|
||||
const script = (r.script as string) ?? JSON.stringify(r.questions ?? res);
|
||||
const script = (r.script as string) || "";
|
||||
if (!script) {
|
||||
toast({ variant: "destructive", title: "No script returned", description: "AI returned empty response — try again." });
|
||||
return;
|
||||
}
|
||||
parts[vars.partIndex] = { ...parts[vars.partIndex], script };
|
||||
updateModuleState("speaking", { speakingParts: parts });
|
||||
toast({ title: "Script generated" });
|
||||
|
||||
Reference in New Issue
Block a user