You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f584e8a
Browse filesBrowse the repository at this point in the historyBrowse files
fix(alerts): let only the latest answered capture claim a visible dialog
Two review findings on the confirm split, one batch:
- The spent-budget exits of confirmTreeAlertDismissed omitted
details.reason, while commands.md promises every post-press failure
branches on alert-window-expired. Both unconfirmed and still-visible
failures now carry the typed reason, pinned in the Android and Limrun
suites.
- The same-alert flag latched on the first matching capture, so a later
undecided re-read still reported the dialog as currently visible.
Each probe now replaces the verdict with its own observation: the
still-visible failure requires the latest capture that answered to
name the same alert, and a fresher undecided read exits as an
unconfirmed press. A probe whose capture never answered is not a
completed observation, so the thrown cutoff keeps saying only that
the press went unconfirmed, at any earlier match.
Pinned fail-before at the pre-fix alert.ts: same-alert then undecided
to budget-end, and same-alert then a hung capture, both expect the
unconfirmed message and the typed reason. The helper-scope comment is
trimmed to the non-obvious constraint per AGENTS.
@@ -516,33 +517,26 @@ async function confirmTreeAlertDismissed<
516
517
signal,
517
518
}));
518
519
}catch(error){
519
-
// A confirmation capture this phase cuts off says what the press cannot say alone: whether
520
-
// the dialog is still there, or whether the check itself never answered. Only the first is
521
-
// the stuck-alert failure; the second must not claim a visible dialog it never observed.
520
+
// The newest probe never answered, so no capture of this phase can claim where the dialog
521
+
// stands at the budget's end — even one that saw the alert a poll earlier.
522
522
if(isAlertWindowExpired(error)){
523
-
if(sameAlertObserved){
524
-
thrownewAppError('COMMAND_FAILED',`alert ${action} did not dismiss the visible alert`,{
525
-
alert: dismissed,
526
-
reason: ALERT_WINDOW_EXPIRED_REASON,
527
-
hint: 'The alert button was pressed but the dialog is still visible. Inspect alert get --json, then press the visible button by label/ref or retry.',
528
-
});
529
-
}
530
523
thrownewAppError(
531
524
'COMMAND_FAILED',
532
525
`alert ${action} pressed the button but the dismissal could not be confirmed`,
533
526
{
534
527
alert: dismissed,
535
528
reason: ALERT_WINDOW_EXPIRED_REASON,
536
-
hint: 'The alert button was pressed; the post-press read never answered within the budget, so the dialog may already be gone. Run alert get --json before retrying.',
529
+
hint: 'The alert button was pressed; the latest post-press check never answered within the budget, so the dialog may already be gone. Run alert get --json before retrying.',
537
530
},
538
531
);
539
532
}
540
533
throwerror;
541
534
}
542
535
if(settled)return;
543
-
if(sameAlertObserved){
536
+
if(lastCaptureNamesAlert){
544
537
thrownewAppError('COMMAND_FAILED',`alert ${action} did not dismiss the visible alert`,{
545
538
alert: dismissed,
539
+
reason: ALERT_WINDOW_EXPIRED_REASON,
546
540
hint: 'The alert button was pressed but the dialog is still visible. Inspect alert get --json, then press the visible button by label/ref or retry.',
547
541
});
548
542
}
@@ -551,6 +545,7 @@ async function confirmTreeAlertDismissed<
551
545
`alert ${action} pressed the button but the dismissal could not be confirmed`,
552
546
{
553
547
alert: dismissed,
548
+
reason: ALERT_WINDOW_EXPIRED_REASON,
554
549
hint: 'The alert button was pressed; no post-press read resolved to an answer within the budget, so the dialog may already be gone. Run alert get --json before retrying.',
Copy file name to clipboardExpand all lines: website/docs/docs/commands.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -386,7 +386,7 @@ agent-device alert dismiss
386
386
- Polling wait timeouts, and a replayed wait refused with `wait_landmark_identity_mismatch`, also carry `captures`, `readableCaptures`, and `polls` so you can see where the budget went. Each poll has `startedMs`, `durationMs`, and an `outcome`: `readable`, `unreadable`, `retriable`, `deadline`, `runner-restart`, or `readiness`. Long waits keep the first 5 and last 25 polls. A wait that never saw a readable capture reports the error its polls hit, with that error's code and retry details, instead of a generic timeout; `wait stable` and a never-readable strict absence keep their own diagnostics. `logPath` links the full request log.
387
387
- `alert` (same as `alert get`) inspects or handles system alerts on iOS simulator, macOS desktop, and Android permission dialogs. On iOS it also covers app-owned modal popups with native blocking markers. `alert wait <ms>` takes a budget up to 2147483647 ms (~24.8 days); larger is refused as `INVALID_ARGS` before anything runs.
388
388
- On the snapshot-derived backends (Android, Limrun iOS) `alert get --json` answers with a typed `status`: `visible`, `none`, or `undecided` (an alert-shaped capture that resolves to no single alert). Branch on `status`, not on the message.
389
-
- On those backends, when `alert accept`/`dismiss` fails, `error.details.reason` names why. Before any press, `dispatched: no` and the reason is `alert-not-found` (the action budget passed with no alert seen), `alert-window-expired` (the budget closed before a capture or the press could resolve), `alert_capture_undecided`, or `alert_button_undecided` (the sheet is too ambiguous to act on). After a press, “did not dismiss the visible alert” means a re-read named the same dialog again; “could not be confirmed” means the press went out but no post-press read resolved in time, so the dialog may already be gone; `dispatched: unknown` means the press itself was cut off and may have landed. Run `alert get` before acting again.
389
+
- On those backends, when `alert accept`/`dismiss` fails, `error.details.reason` names why. Before any press, `dispatched: no` and the reason is `alert-not-found` (the action budget passed with no alert seen), `alert-window-expired` (the budget closed before a capture or the press could resolve), `alert_capture_undecided`, or `alert_button_undecided` (the sheet is too ambiguous to act on). After a press, `dispatched` is absent and the reason is `alert-window-expired`; “did not dismiss the visible alert” means the latest post-press capture that answered named the same dialog again, “could not be confirmed” means the press went out but the latest read was unresolvable or never answered, so the dialog may already be gone; `dispatched: unknown` means the press itself was cut off and may have landed. Run `alert get` before acting again.
390
390
- On Android, an alert capture that outlives its budget is stopped in flight. On Limrun the transport cannot cancel a request: the command refuses a late answer and presses nothing, but a hung capture can keep running after the command has already failed. If Limrun alert commands stall, restart the instance session.
391
391
- Use `alert get` for a quick check, and `alert wait <short-ms>` only when a prompt may appear after async work. Don't use `settings permission` to answer a dialog already on screen; it is for setup before a flow.
392
392
- `accept` and `dismiss` are sent once on every platform and never replayed, even if the response is lost. On iOS the runner activates the button once, then only observes until the alert disappears, changes, or the deadline expires. A changed alert does not prove a permission was granted; verify the app outcome.
0 commit comments