diff --git a/enhanced_cli.py b/enhanced_cli.py index 9d9bae2..cd0f144 100644 --- a/enhanced_cli.py +++ b/enhanced_cli.py @@ -428,7 +428,6 @@ class EnhancedCLI: key_bindings=self.key_bindings, auto_suggest=AutoSuggestFromHistory(), multiline=True, - cursor=CursorShape.BEAM, mouse_support=self.enable_mouse, ) @@ -656,6 +655,16 @@ class EnhancedCLI: Args: agent_callback: Function that takes user input and returns agent response """ + import signal + import sys + + # Register signal handler for Ctrl+C + def handle_sigint(signum, frame): + print("\n\n👋 Arrivederci!") + sys.exit(0) + + signal.signal(signal.SIGINT, handle_sigint) + # Print welcome print(self.welcome_message) diff --git a/langcode.py b/langcode.py index dacb7ed..0652620 100755 --- a/langcode.py +++ b/langcode.py @@ -109,16 +109,36 @@ def cmd_chat(args): use_enhanced = not args.simple if use_enhanced: + import errno + import fcntl + import select + import threading + + def timeout_handler(): + print("\n⚠️ EnhancedCLI timeout - uso CLI semplice") + try: from enhanced_cli import create_enhanced_cli cli = create_enhanced_cli( history_file="./.langcode/.cli_history", theme="default" ) + + # Run with timeout detection + timeout_seconds = 30 + timer = threading.Timer(timeout_seconds, timeout_handler) + timer.daemon = True + timer.start() + cli.run(agent_callback) + timer.cancel() return + except (KeyboardInterrupt, EOFError, OSError) as e: + # EnhancedCLI hang - fall back to simple + print(f"⚠️ EnhancedCLI bloccato: {e}") + print("📝 Uso CLI semplice...") except Exception as e: - print(f"⚠️ EnhancedCLI non disponibile: {e}") + print(f"⚠️ EnhancedCLI errore: {e}") print("📝 Uso CLI semplice...") # CLI semplice con input()