MCPcopy Create free account
hub / github.com/RightNow-AI/rightnow-cli / interactive_mode

Function interactive_mode

rightnow_cli/cli_minimal.py:536–726  ·  view source on GitHub ↗

Production-ready interactive loop with comprehensive error handling. Rock-solid stability for cross-platform deployment.

(orchestrator: AgentOrchestrator)

Source from the content-addressed store, hash-verified

534
535
536def interactive_mode(orchestrator: AgentOrchestrator):
537 """
538 Production-ready interactive loop with comprehensive error handling.
539 Rock-solid stability for cross-platform deployment.
540 """
541 # Show banner once (only if not already shown)
542 try:
543 show_minimal_banner(orchestrator)
544 except Exception as e:
545 # Banner failed, but continue
546 pass # Silent fail - banner is not critical
547
548 # Error recovery counters
549 consecutive_errors = 0
550 max_consecutive_errors = 5
551 total_errors = 0
552 max_total_errors = 50
553
554 # Main loop with recovery
555 while True:
556 try:
557 # Ensure clean terminal state before input
558 try:
559 sys.stdout.flush()
560 sys.stderr.flush()
561 except:
562 pass
563
564 # Get input with fallback
565 try:
566 user_input = get_modern_input() # Use modern input with autocomplete
567 except (KeyboardInterrupt, EOFError):
568 raise # Re-raise these for proper handling
569 except Exception as input_error:
570 # Input failed - try fallback to minimal input (no autocomplete)
571 console.print("[yellow]Autocomplete unavailable, using basic input...[/yellow]")
572 try:
573 user_input = get_minimal_input()
574 except (KeyboardInterrupt, EOFError):
575 raise
576 except:
577 # Ultimate fallback - plain input
578 try:
579 user_input = input(" > ").strip()
580 except (KeyboardInterrupt, EOFError):
581 raise
582 except:
583 consecutive_errors += 1
584 if consecutive_errors >= max_consecutive_errors:
585 console.print("[red]Too many consecutive errors. Restarting...[/red]")
586 consecutive_errors = 0
587 continue
588
589 # Reset error counter on successful input
590 if user_input:
591 consecutive_errors = 0
592
593 # Skip empty input

Callers 1

mainFunction · 0.85

Calls 12

show_minimal_bannerFunction · 0.85
get_modern_inputFunction · 0.85
get_minimal_inputFunction · 0.85
handle_commandFunction · 0.85
show_errorFunction · 0.85
show_successFunction · 0.85
show_exit_confirmationFunction · 0.85
cleanup_global_spinnerFunction · 0.85
flushMethod · 0.80
askMethod · 0.80
save_api_keyMethod · 0.80
chatMethod · 0.45

Tested by

no test coverage detected