tapir:reset_overlays
Return the app to a known clean screen by dismissing every modal, pressing Escape, and tapping a Cancel/Dismiss affordance as a fallback.
On this page
tapir:reset_overlays promotes the manual overlay-reset dance (dismiss + Escape + Cancel-tap) into one idempotent command, so an agent can reliably clear stuck dialogs, bottom sheets, dropdown menus, and barrier modals between flows without composing the steps by hand.
Synopsis#
dart run tapir tapir:reset_overlays
tapir:reset_overlays requires a running Flutter session (CommandBoot.connected). It takes no arguments, calls ext.tapir.reset_overlays, and prints the JSON result. It is idempotent: calling it when nothing is open is a safe no-op.
Layers#
Three escalating layers run in order, each a no-op when the prior already cleared the overlays:
- Dismiss modals: pops every
PopupRoute(dialogs, bottom sheets, popups) across everyNavigatorState, reusing the samedismissAllModalspath astapir:modal. The page navigation stack is never touched. - Escape key: delivers an
Escapekey down + up through the binding'sonKeyData(the path real key data takes, so the focus tree hears it), dismissing overlays driven by the dismiss shortcut that are NOTPopupRoutes (customOverlayEntrypanels, dropdown menus closed viaShortcuts). - Cancel/Dismiss tap: only attempted when an overlay still appears present. Finds the first tappable Semantics node whose label matches
Cancel,Dismiss,Close,OK, orDone(case-insensitive) and synthesises a tap at its centre, for modal barriers that require an explicit affordance to close.
Returns#
| Exit code | Meaning |
|---|---|
0 |
Reset attempted. Emits the JSON result. |
| non-zero | VM Service handler returned an error (no running app at the recorded URI, unexpected failure). |
Success envelope:
{
"popped": 2,
"escaped": true,
"dismissTapped": false
}
popped: number ofPopupRoutes dismissed by layer 1.escaped: whether the Escape key press was dispatched.dismissTapped: whether layer 3 tapped a Cancel/Dismiss affordance.
On a clean tree all three indicate no work was done (popped: 0, dismissTapped: false), confirming idempotency.
Examples#
1. Reset overlays between test flows#
dart run tapir tapir:reset_overlays
{"popped":1,"escaped":true,"dismissTapped":false}
2. Speculative reset before navigating#
dart run tapir tapir:reset_overlays
dart run tapir tapir:navigate --route=/dashboard
Safe to call even when nothing is open; the no-op path returns popped: 0.
Related Documentation#
- tapir:modal: the underlying dismiss-modals path (the
tapir_dismiss_modalsMCP tool);tapir:reset_overlaysadds Escape + Cancel-tap fallback on top. - tapir:tap: tap a specific Cancel button by ref when you want precise control.
- tapir:snap: re-snapshot after a reset; refs from before the reset are stale.