MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / _wait_for_gemini

Function _wait_for_gemini

core/peer_shell.py:375–415  ·  view source on GitHub ↗

Handle Gemini CLI's startup sequence before we type the task. Gemini prints keychain warnings first, then loads credentials, then renders its interactive prompt (> or ❯). We wait up to 5 s for any of those signals before typing — matching the user's observed startup time on An

(child, pexpect_mod)

Source from the content-addressed store, hash-verified

373
374
375def _wait_for_gemini(child, pexpect_mod) -> None:
376 """
377 Handle Gemini CLI's startup sequence before we type the task.
378
379 Gemini prints keychain warnings first, then loads credentials, then
380 renders its interactive prompt (> or ❯). We wait up to 5 s for any
381 of those signals before typing — matching the user's observed startup
382 time on Android ARM64.
383 """
384 # Phase 1 — wait for credentials to load OR the prompt to appear
385 CRED_OR_PROMPT = [
386 "Loaded cached credentials",
387 "cached credentials",
388 r"❯[\s$]",
389 r"❯$",
390 r">\s*$",
391 r"\?\s*$",
392 pexpect_mod.TIMEOUT,
393 ]
394 try:
395 idx = child.expect(CRED_OR_PROMPT, timeout=5.0)
396 hit_creds = idx < 2 # first two patterns are credential lines
397 except (pexpect_mod.TIMEOUT, pexpect_mod.EOF):
398 hit_creds = False
399
400 if hit_creds:
401 # Credentials loaded — now wait for the interactive prompt to appear
402 PROMPT_PATTERNS = [
403 r"❯[\s$]",
404 r"❯$",
405 r">\s*$",
406 r"\?\s*$",
407 pexpect_mod.TIMEOUT,
408 ]
409 try:
410 child.expect(PROMPT_PATTERNS, timeout=3.0)
411 except (pexpect_mod.TIMEOUT, pexpect_mod.EOF):
412 pass
413
414 # Give the TUI a moment to finish rendering before we send text
415 time.sleep(0.8)
416
417
418def _wait_for_ready(child, cli_name: str, pexpect_mod) -> None:

Callers 1

_wait_for_readyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected