Skip to content

Interaction Guard

import { startInteractionGuard } from "webotron/plugins/interaction-guard";
  • startInteractionGuard(view, options?)
const guard = await startInteractionGuard(view, {
message: "Interaction blocked: automation session is active",
blockKeyboard: true,
disableInHeadless: true,
});
await guard.enable();
const offBlocked = guard.onBlockedAttempt((event) => {
console.log("Blocked interaction", event.eventType, event.x, event.y);
});
// Run automation actions while guard is enabled.
await view.click("#submit");
await guard.disable();
offBlocked();
await guard.stop();
  • enable()
  • disable()
  • isEnabled()
  • onBlockedAttempt(handler)
  • stop()
OptionTypePurpose
messagestringUI text shown when interaction is blocked.
zIndexnumberOverlay z-index used for the guard UI.
blockKeyboardbooleanWhether keyboard events are blocked while enabled.
toastDurationMsnumberDuration of blocked-interaction feedback message.
disableInHeadlessbooleanWhen true (default), plugin returns a no-op controller in headless sessions to avoid unnecessary overhead.

By default, the interaction guard does not activate in headless browsers because there is no direct human interaction to block. If you still want guard behavior in headless mode for a specific workflow, pass disableInHeadless: false.

This plugin is decoupled from the mouse pointer visualizer implementation details. Coordination happens over the host-side plugin message bus (plugins/shared/plugin-message-bus.ts) using message topics:

  • automation:bypass:before
  • automation:bypass:after

This means removing the visualizer plugin does not require changing interaction-guard code.