Skip to content

The agent that grows with you

fix(google_meet): poll for the Join button instead of clicking once after domcontentloaded

minh-alpon5381c6c2c373
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]
new file mode 100644
index 00000000000..e3948a7516d
--- /dev/null
+++ b/contributors/emails/[email protected]
@@ -0,0 +1 @@
+minh-alpon
diff --git a/plugins/google_meet/meet_bot.py b/plugins/google_meet/meet_bot.py
index 5abdbfdd130..303eb62fd95 100644
--- a/plugins/google_meet/meet_bot.py
+++ b/plugins/google_meet/meet_bot.py
@@ -323,17 +323,24 @@ def _config_from_env() -> _BotConfig:
lobby_timeout=float(env("HERMES_MEET_LOBBY_TIMEOUT", "300")))
-def _join(page, cfg: _BotConfig, state: _BotState) -> None:
- """Fill the guest-name field and click 'Join now' / 'Ask to join' (the latter → lobby_waiting)."""
- name_box = _visible(page.locator('input[aria-label*="name" i]'))
- if name_box is not None:
- _quiet(name_box.fill, cfg.guest_name, timeout=2_000)
- for label in ("Join now", "Ask to join"):
- btn = _visible(page.get_by_role("button", name=label, exact=False))
- if btn is not None and _quiet(lambda: (btn.click(timeout=3_000), True)):
- if label == "Ask to join":
- state.set(lobby_waiting=True)
- break
+def _join(page, cfg: _BotConfig, state: _BotState, timeout: float = 30.0) -> None:
+ """Fill the guest-name field and click 'Join now' / 'Ask to join' (the latter → lobby_waiting).
+ Meet renders the pre-join buttons asynchronously after ``domcontentloaded``, so poll for up to
+ *timeout* seconds instead of checking once — a single miss leaves the bot silently in the lobby."""
+ deadline = time.time() + timeout
+ while True:
+ name_box = _visible(page.locator('input[aria-label*="name" i]'))
+ if name_box is not None:
+ _quiet(name_box.fill, cfg.guest_name, timeout=2_000)
+ for label in ("Join now", "Ask to join"):
+ btn = _visible(page.get_by_role("button", name=label, exact=False))
+ if btn is not None and _quiet(lambda: (btn.click(timeout=3_000), True)):
+ if label == "Ask to join":
+ state.set(lobby_waiting=True)
+ return
+ if time.time() >= deadline:
+ return
+ time.sleep(0.5)
def _drain_loop(page, cfg: _BotConfig, state: _BotState, rt: dict, stop_flag: dict) -> None: