fix: UIA compare les noms d'app au lieu des titres complets

"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) <noreply@anthropic.com>
This commit is contained in:
Dom
2026-04-13 10:27:08 +02:00
parent e9a028134a
commit 203dc00d53
2 changed files with 31 additions and 9 deletions

View File

@@ -334,16 +334,28 @@ class ActionExecutorV1:
break break
if found_root and expected_root != found_root: if found_root and expected_root != found_root:
# Match souple : une sous-partie commune (ex: "Bloc-notes") # Match souple : même app (ex: "Bloc-notes")
if (expected_root.lower() not in found_root.lower() # Le titre peut changer (fichier différent) mais
and found_root.lower() not in expected_root.lower()): # 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( logger.warning(
f"UIA REJET : '{name}' trouvé dans '{found_root}' " f"UIA REJET : '{name}' trouvé dans '{found_root}' "
f"mais attendu dans '{expected_root}'" f"mais attendu dans '{expected_root}'"
) )
print( print(
f" [UIA] REJET — '{name}' trouvé dans mauvaise fenêtre " f" [UIA] REJET — '{name}' dans mauvaise app "
f"({found_root}{expected_root})" f"({_app_from(found_root)}{_app_from(expected_root)})"
) )
return None return None

View File

@@ -302,15 +302,25 @@ class ActionExecutorV1:
break break
if found_root and expected_root != found_root: if found_root and expected_root != found_root:
if (expected_root.lower() not in found_root.lower() def _app_from(t):
and found_root.lower() not in expected_root.lower()): 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( logger.warning(
f"UIA REJET : '{name}' trouvé dans '{found_root}' " f"UIA REJET : '{name}' trouvé dans '{found_root}' "
f"mais attendu dans '{expected_root}'" f"mais attendu dans '{expected_root}'"
) )
print( print(
f" [UIA] REJET — '{name}' trouvé dans mauvaise fenêtre " f" [UIA] REJET — '{name}' dans mauvaise app "
f"({found_root}{expected_root})" f"({_app_from(found_root)}{_app_from(expected_root)})"
) )
return None return None