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