def cancel_prompt()

in src/nova_act/impl/extension.py [0:0]


    def cancel_prompt(self, act: Act | None = None):
        """Dispatch a cancel message to the extension.

        Post a message with `type: autonomy-cancel-prompt` within the browser context.
        The extension listens for messages of this type to cancel existing program runs.

        """
        cancel_prompt_message = {"type": CANCEL_PROMPT_TYPE}
        encrypted_message = self._playwright_manager.encrypter.encrypt(cancel_prompt_message)
        try:
            self._playwright_manager.main_page.evaluate(POST_MESSAGE_EXPRESSION, encrypted_message)
        except PlaywrightError:
            if self._verbose_errors:
                _LOGGER.error("Encountered PlaywrightError", exc_info=True)

        if act is None:
            return

        end_time = time.time() + EXTENSION_TIMEOUT_S
        while time.time() < end_time:
            if act.is_complete:
                return
            else:
                self._poll_playwright(EXTENSION_POLL_SLEEP_S)

        raise ActDispatchError(
            message="Failed to cancel Act",
            metadata=act.metadata,
        )