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:
@@ -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")
|
||||
|
||||
if win_path.is_file() and window_rect:
|
||||
img = PILImage.open(str(win_path))
|
||||
using_window = True
|
||||
logger.debug("Grounding : image fenêtre %s (%dx%d)", win_path.name, *img.size)
|
||||
else:
|
||||
# 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 window_rect:
|
||||
x1, y1, x2, y2 = window_rect
|
||||
img = img.crop((x1, y1, x2, y2))
|
||||
using_window = True
|
||||
logger.debug("Grounding : crop fenêtre (%d,%d,%d,%d) → %dx%d", x1, y1, x2, y2, *img.size)
|
||||
else:
|
||||
using_window = False
|
||||
|
||||
orig_w, orig_h = img.size
|
||||
|
||||
Reference in New Issue
Block a user