fix: immediate AI loading feedback + auto-fallback for deprecated model

- BulkAiAnalyzer: set isAnalyzing=true immediately on click (before
  context fetch), so the spinner appears instantly instead of after
  1-2 seconds of silence
- analyze/route.ts: if configured model returns 400/404 (e.g., deprecated
  google/gemini-flash-1.5), automatically retry with google/gemini-2.0-flash-001
- batch-analyze/route.ts: same fallback logic

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Sonnet 4.6 committed 2026-04-03 11:34:14 +02:00
1 parent 2aa9cbecaa
commit bbb04a4d2a
3 files changed
+32 -9

No files matched your search

@@ -41,6 +41,10 @@ export function BulkAiAnalyzer() {
const { rows } = useGridStore.getState();
isCancelledRef.current = false;
// Show immediate visual feedback before any async work
setIsAnalyzing(true);
setProgress({ current: 0, total: 0, message: "Chargement du contexte...", errors: 0 });
// 1. Fetch AI Context for the Supplier
let supplierContext = "";
if (supplierCode) {
@@ -166,7 +170,6 @@ export function BulkAiAnalyzer() {
// 2c. Context profiling en micro-batches asynchrones
// Le score est déjà calculé par score-engine.ts (champ row.score sur chaque ProductRow).
setIsAnalyzing(true);
setProgress({ current: 0, total: payloadsWithSales.length, message: "Calcul du contexte...", errors: 0 });
const SCORING_BATCH_SIZE = 25;