fix(navigation): detect end of carousel by checking ui delta to prevent blind swiping

This commit is contained in:
2026-05-05 12:07:27 +02:00
parent 59e7967458
commit ac272eadce

View File

@@ -74,13 +74,23 @@ class CarouselBrowsingPlugin(BehaviorPlugin):
# ── Curiosity Dwell ──
if i == curiosity_slide:
dwell = random.uniform(3.0, 7.0)
logger.debug(f"📸 [Carousel] Curiosity Peak hit on slide {i+1}. " f"Gazing for {dwell:.1f}s...")
logger.debug(f"📸 [Carousel] Curiosity Peak hit on slide {i+1}. Gazing for {dwell:.1f}s...")
sleep(dwell * ctx.sleep_mod)
xml_before = ctx.device.dump_hierarchy()
# Horizontal swipe: Right to left
humanized_horizontal_swipe(ctx.device, start_x=w * 0.8, end_x=w * 0.2, y=h * 0.5, duration_ms=250)
sleep(random.uniform(1.0, 2.0) * ctx.sleep_mod)
# Brief wait for transition to complete
sleep(random.uniform(1.5, 2.5) * ctx.sleep_mod)
xml_after = ctx.device.dump_hierarchy()
xml_delta = abs(len(xml_before) - len(xml_after))
if xml_before == xml_after or xml_delta < 50:
logger.info(f"📸 [Carousel] End of carousel detected on slide {i+1} (UI stable). Stopping swipe.")
break
return BehaviorResult(
executed=True, interactions=count, metadata={"slides_viewed": count, "curiosity_slide": curiosity_slide}