fix(runner): apply-time guard consults focused window, not just resumed activity

ensureForeground detects a system overlay (notification shade) owning the focused window while the app stays the resumed activity, but appIsForeground only queried ForegroundApp. A swipe that pulls the shade over the app between observe and apply then fired onto the shade. Mirror the focus check at apply time so the action skips and the next step dismisses the overlay.
This commit is contained in:
pj committed 2026-06-11 09:17:44 +05:30
1 parent 72a0c1c26e
commit 663f9e7180
1 file changed
+16 -1
+16 -1
View File
@@ -437,7 +437,22 @@ func appIsForeground(ctx context.Context, options Options) bool {
if err != nil || foreground == "" {
return true
}
return foreground == options.BundleID
if foreground != options.BundleID {
return false
}
// The app is the resumed activity, but a system overlay (the notification
// shade) can own the focused window while the app stays resumed; firing the
// action would land on the overlay. Mirror ensureForeground's focus check
// here so the apply-time guard skips and the next step dismisses it.
focusChecker, ok := options.Driver.(driver.FocusedWindowChecker)
if !ok {
return true
}
focused, err := focusChecker.FocusedWindowApp(ctx)
if err != nil || focused == "" {
return true
}
return focused == options.BundleID
}
// foregroundReadyAttempts bounds how many times waitForForeground tries to