diff --git a/agent_v0/server_v1/api_stream.py b/agent_v0/server_v1/api_stream.py index c767ff063..76fc36776 100644 --- a/agent_v0/server_v1/api_stream.py +++ b/agent_v0/server_v1/api_stream.py @@ -4557,16 +4557,16 @@ def _resolve_by_grounding( from PIL import Image as PILImage from pathlib import Path - # Chercher le screenshot fenêtre (_window.png) - full_path = Path(screenshot_path) - win_path = full_path.parent / full_path.name.replace("_full.png", "_window.png") + # Utiliser la fenêtre active : cropper depuis le screenshot full + # via window_rect (fonctionne au replay comme à l'enregistrement) + img = PILImage.open(screenshot_path) - if win_path.is_file() and window_rect: - img = PILImage.open(str(win_path)) + if window_rect: + x1, y1, x2, y2 = window_rect + img = img.crop((x1, y1, x2, y2)) using_window = True - logger.debug("Grounding : image fenêtre %s (%dx%d)", win_path.name, *img.size) + logger.debug("Grounding : crop fenêtre (%d,%d,%d,%d) → %dx%d", x1, y1, x2, y2, *img.size) else: - img = PILImage.open(screenshot_path) using_window = False orig_w, orig_h = img.size