fix: cropper la fenêtre depuis le screenshot live (pas chercher _window.png)

Le resolve_target reçoit un screenshot temp de l'agent — le fichier
_window.png n'existe pas à cet emplacement. Au lieu de chercher un
fichier, on crop directement la fenêtre depuis le full screenshot
en utilisant window_rect du target_spec.

Fonctionne au replay (screenshot live) comme à l'enregistrement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dom
2026-04-05 09:09:13 +02:00
parent 20b74286f7
commit 2486e43def

View File

@@ -4557,16 +4557,16 @@ def _resolve_by_grounding(
from PIL import Image as PILImage from PIL import Image as PILImage
from pathlib import Path from pathlib import Path
# Chercher le screenshot fenêtre (_window.png) # Utiliser la fenêtre active : cropper depuis le screenshot full
full_path = Path(screenshot_path) # via window_rect (fonctionne au replay comme à l'enregistrement)
win_path = full_path.parent / full_path.name.replace("_full.png", "_window.png") img = PILImage.open(screenshot_path)
if win_path.is_file() and window_rect: if window_rect:
img = PILImage.open(str(win_path)) x1, y1, x2, y2 = window_rect
img = img.crop((x1, y1, x2, y2))
using_window = True 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: else:
img = PILImage.open(screenshot_path)
using_window = False using_window = False
orig_w, orig_h = img.size orig_w, orig_h = img.size