From d71d5df4a8b614a2bbebc4c1962fc1a0a03c951c Mon Sep 17 00:00:00 2001 From: Dom Date: Wed, 22 Apr 2026 17:03:18 +0200 Subject: [PATCH] =?UTF-8?q?fix(ORA):=20overlay=20=3D=20minimiser=20la=20fe?= =?UTF-8?q?n=C3=AAtre=20devant,=20pas=20juste=20chercher=20OK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quand la pré-vérification dit NO et qu'aucun pattern de dialogue n'est détecté, c'est une fenêtre quelconque qui masque la cible (Chrome, etc). xdotool windowminimize pour la dégager. Classification améliorée : pré-check rejeté → OVERLAY_BLOCKING (avant c'était ELEMENT_NOT_FOUND → scroll inutile). Co-Authored-By: Claude Opus 4.6 (1M context) --- core/execution/observe_reason_act.py | 60 +++++++++++++--------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/core/execution/observe_reason_act.py b/core/execution/observe_reason_act.py index 8e8ecc5c7..99d5b0afe 100644 --- a/core/execution/observe_reason_act.py +++ b/core/execution/observe_reason_act.py @@ -759,20 +759,21 @@ Règles: Returns: ErrorType constant. """ - # Si l'action a échoué avant même de cliquer, c'est ELEMENT_NOT_FOUND - if not act_success: - print(f"🔎 [ORA/classify] → {ErrorType.ELEMENT_NOT_FOUND} (action non exécutée)") - return ErrorType.ELEMENT_NOT_FOUND - - # Vérifier si un dialogue/popup bloque + # Vérifier TOUJOURS si un dialogue/popup/fenêtre bloque try: from core.execution.input_handler import check_screen_for_patterns pattern = check_screen_for_patterns() if pattern: print(f"🔎 [ORA/classify] → {ErrorType.OVERLAY_BLOCKING} (pattern={pattern.get('pattern', '?')})") return ErrorType.OVERLAY_BLOCKING - except Exception as e: - logger.debug(f"[ORA/classify] check_screen_for_patterns échoué: {e}") + except Exception: + pass + + # Si l'action a échoué (pré-vérification NO) → probablement une fenêtre devant + if not act_success: + # Le VLM a dit "ce n'est pas le bon élément" → une fenêtre masque la cible + print(f"🔎 [ORA/classify] → {ErrorType.OVERLAY_BLOCKING} (pré-check rejeté = fenêtre devant)") + return ErrorType.OVERLAY_BLOCKING # Vérifier si l'écran a changé du tout distance = self._phash_distance(pre.phash, post.phash) @@ -908,32 +909,25 @@ Règles: try: from core.execution.input_handler import check_screen_for_patterns, handle_detected_pattern - # --- Étape 1 : Détecter et identifier le dialogue --- + # --- Étape 1 : Détecter un dialogue connu --- pattern = check_screen_for_patterns() - if not pattern: - # Le pattern a peut-être disparu entre la classification et ici - return RecoveryAttempt( - error_type=ErrorType.OVERLAY_BLOCKING, - strategy="pattern_vanished", - success=True, - detail="Le dialogue a disparu spontanément" - ) - - print(f"🔧 [ORA/recovery/overlay] Pattern détecté: {pattern.get('pattern', '?')} → action={pattern.get('action', '?')}") - - # --- Étape 2 : Gérer le dialogue (cliquer OK/Fermer) --- - handled = handle_detected_pattern(pattern) - if not handled: - print(f"⚠️ [ORA/recovery/overlay] Impossible de gérer le pattern automatiquement") - return RecoveryAttempt( - error_type=ErrorType.OVERLAY_BLOCKING, - strategy="handle_failed", - success=False, - detail=f"Pattern '{pattern.get('pattern', '?')}' détecté mais non géré" - ) - - print(f"✅ [ORA/recovery/overlay] Dialogue fermé") - time.sleep(0.5) + if pattern: + print(f"🔧 [ORA/recovery/overlay] Pattern détecté: {pattern.get('pattern', '?')}") + handled = handle_detected_pattern(pattern) + if handled: + print(f"✅ [ORA/recovery/overlay] Dialogue fermé") + time.sleep(0.5) + else: + print(f"⚠️ [ORA/recovery/overlay] Pattern non géré, minimisation fenêtre") + subprocess.run(['xdotool', 'getactivewindow', 'windowminimize'], + capture_output=True, timeout=2) + time.sleep(0.5) + else: + # Pas de dialogue connu → fenêtre quelconque devant → minimiser + print(f"🔧 [ORA/recovery/overlay] Aucun dialogue connu — minimisation de la fenêtre active") + subprocess.run(['xdotool', 'getactivewindow', 'windowminimize'], + capture_output=True, timeout=2) + time.sleep(0.5) # --- Étape 3 : Retry l'action originale --- act_ok = self.act(decision, step_params)