From 203dc00d53d2468eaeee496c41cac8f071fabb65 Mon Sep 17 00:00:00 2001 From: Dom Date: Mon, 13 Apr 2026 10:27:08 +0200 Subject: [PATCH] fix: UIA compare les noms d'app au lieu des titres complets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Fichier" dans "*,Ceci est un test – Bloc-notes" était rejeté parce que le titre attendu était "test.txt – Bloc-notes". Maintenant la comparaison extrait le nom d'app (Bloc-notes) et accepte le match si c'est la même application. Résout : "Ajouter un nouvel onglet" bloqué quand un fichier différent est ouvert dans Bloc-notes. Co-Authored-By: Claude Opus 4.6 (1M context) --- agent_v0/agent_v1/core/executor.py | 22 ++++++++++++++----- .../windows_client/agent_v1/core/executor.py | 18 +++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/agent_v0/agent_v1/core/executor.py b/agent_v0/agent_v1/core/executor.py index 9ecaf7df9..a17b482fa 100644 --- a/agent_v0/agent_v1/core/executor.py +++ b/agent_v0/agent_v1/core/executor.py @@ -334,16 +334,28 @@ class ActionExecutorV1: break if found_root and expected_root != found_root: - # Match souple : une sous-partie commune (ex: "Bloc-notes") - if (expected_root.lower() not in found_root.lower() - and found_root.lower() not in expected_root.lower()): + # Match souple : même app (ex: "Bloc-notes") + # Le titre peut changer (fichier différent) mais + # l'app est la même → "Fichier" est au bon endroit. + def _app_from(t): + for s in [" – ", " - ", " — "]: + if s in t: + return t.split(s)[-1].strip().lower() + return t.strip().lower() + + same_app = _app_from(expected_root) == _app_from(found_root) + substring_match = ( + expected_root.lower() in found_root.lower() + or found_root.lower() in expected_root.lower() + ) + if not same_app and not substring_match: logger.warning( f"UIA REJET : '{name}' trouvé dans '{found_root}' " f"mais attendu dans '{expected_root}'" ) print( - f" [UIA] REJET — '{name}' trouvé dans mauvaise fenêtre " - f"({found_root} ≠ {expected_root})" + f" [UIA] REJET — '{name}' dans mauvaise app " + f"({_app_from(found_root)} ≠ {_app_from(expected_root)})" ) return None diff --git a/agent_v0/deploy/windows_client/agent_v1/core/executor.py b/agent_v0/deploy/windows_client/agent_v1/core/executor.py index 34a857c6a..93de6859b 100644 --- a/agent_v0/deploy/windows_client/agent_v1/core/executor.py +++ b/agent_v0/deploy/windows_client/agent_v1/core/executor.py @@ -302,15 +302,25 @@ class ActionExecutorV1: break if found_root and expected_root != found_root: - if (expected_root.lower() not in found_root.lower() - and found_root.lower() not in expected_root.lower()): + def _app_from(t): + for s in [" – ", " - ", " — "]: + if s in t: + return t.split(s)[-1].strip().lower() + return t.strip().lower() + + same_app = _app_from(expected_root) == _app_from(found_root) + substring_match = ( + expected_root.lower() in found_root.lower() + or found_root.lower() in expected_root.lower() + ) + if not same_app and not substring_match: logger.warning( f"UIA REJET : '{name}' trouvé dans '{found_root}' " f"mais attendu dans '{expected_root}'" ) print( - f" [UIA] REJET — '{name}' trouvé dans mauvaise fenêtre " - f"({found_root} ≠ {expected_root})" + f" [UIA] REJET — '{name}' dans mauvaise app " + f"({_app_from(found_root)} ≠ {_app_from(expected_root)})" ) return None