From 4d26bdf00db37734fc22f176bb58a325d5ff2642 Mon Sep 17 00:00:00 2001 From: PJ Date: Thu, 28 May 2026 11:19:49 +0530 Subject: [PATCH] feat(driver): add ForegroundChecker optional capability --- internal/driver/driver.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/driver/driver.go b/internal/driver/driver.go index ef5d589..ccd916d 100644 --- a/internal/driver/driver.go +++ b/internal/driver/driver.go @@ -35,6 +35,18 @@ type DeviceDriver interface { Metrics(ctx context.Context, bundleID string) (Metrics, error) } +// ForegroundChecker is the optional capability for reporting which app is +// currently in the foreground. The runner uses it to keep exploration scoped +// to the app under test: when an action backs out of (or otherwise leaves) the +// app, the runner relaunches it before acting again. Drivers that cannot +// determine the foreground app simply do not implement this interface. +type ForegroundChecker interface { + // ForegroundApp returns the bundle id / package of the app currently in + // the foreground. An empty string means "unknown" and the runner skips + // enforcement for that step rather than relaunching blindly. + ForegroundApp(ctx context.Context) (string, error) +} + type LogEntry struct { UnixMillis int64 Level string