« All posts

Bringing OS-Style Interrupt Handlers to Browser Automation

How a Cue-based interrupt-handler pattern fixes flaky browser automation scripts, with reliability safeguards and a compile-to-plain-code export.

Browser automation scripts are written linearly, but the web is asynchronous: cookie banners, subscribe modals, and session expirations can strike at any point mid-run. Sprinkling checks between steps or retrying entire scripts are both brittle and expensive workarounds. A desktop automation tool called Orchestra borrows a decades-old OS concept instead: a 'Cue' is a background watcher that polls a condition (a selector, URL, network response, etc.) while the main flow runs, and fires a handler the moment the condition is true — then returns control to the main script.

A naive polling watcher hits four real failure modes: infinite fire loops, handlers that hang forever, 'zombie' watchers that keep failing without effect, and handlers that report success without actually fixing anything. The design addresses each with concrete mechanisms — cooldowns, max-fire limits, fire timeouts, a circuit breaker after repeated failures, and an opt-in verification step that re-checks the condition after the handler runs.

Notably, when flows are exported as plain Playwright scripts, the entire watcher engine compiles down to about 15 lines of readable, editable code plus two scheduling loops — no runtime dependency required, making the interrupt-handling logic fully portable and inspectable.

This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work