fix: EnhancedCLI timeout e fallback a CLI semplice
- Rimosso CursorShape.BEAM che causa hang su alcuni terminali - Aggiunto timeout 30s con fallback a CLI semplice - Cattura KeyboardInterrupt, EOFError, OSError per hang - Signal handler per Ctrl+C in EnhancedCLI
This commit is contained in:
1 parent
e75a75e16c
commit
453156148c
2 files changed
+31
-2
No files matched your search
+10
-1
@@ -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)
|
||||
|
||||
|
||||
+21
-1
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user