71 lines
2.2 KiB
Python
Raw Normal View History

2025-11-04 05:17:27 +01:00
from pr.ui.colors import Colors
2025-11-04 08:09:12 +01:00
2025-11-04 05:17:27 +01:00
def display_tool_call(tool_name, arguments, status="running", result=None):
2025-11-04 05:57:23 +01:00
if status == "running":
return
2025-11-04 05:17:27 +01:00
2025-11-04 05:57:23 +01:00
args_str = ", ".join([f"{k}={str(v)[:20]}" for k, v in list(arguments.items())[:2]])
line = f"{tool_name}({args_str})"
2025-11-04 05:17:27 +01:00
2025-11-04 05:57:23 +01:00
if len(line) > 80:
line = line[:77] + "..."
2025-11-04 05:17:27 +01:00
2025-11-04 05:57:23 +01:00
print(f"{Colors.GRAY}{line}{Colors.RESET}")
2025-11-04 05:17:27 +01:00
2025-11-04 08:09:12 +01:00
2025-11-04 05:17:27 +01:00
def print_autonomous_header(task):
print(f"{Colors.BOLD}Task:{Colors.RESET} {task}")
2025-11-04 08:10:37 +01:00
print(f"{Colors.GRAY}r will work continuously until the task is complete.{Colors.RESET}")
2025-11-04 05:17:27 +01:00
print(f"{Colors.GRAY}Press Ctrl+C twice to interrupt.{Colors.RESET}\n")
print(f"{Colors.BOLD}{'' * 80}{Colors.RESET}\n")
def display_multiplexer_status(sessions):
"""Display the status of background sessions."""
if not sessions:
print(f"{Colors.GRAY}No background sessions running{Colors.RESET}")
return
print(f"\n{Colors.BOLD}Background Sessions:{Colors.RESET}")
print(f"{Colors.GRAY}{'\u2500' * 60}{Colors.RESET}")
for session_name, session_info in sessions.items():
status = session_info.get("status", "unknown")
pid = session_info.get("pid", "N/A")
command = session_info.get("command", "N/A")
status_color = {
"running": Colors.GREEN,
"stopped": Colors.RED,
"error": Colors.RED,
}.get(status, Colors.YELLOW)
print(f" {Colors.CYAN}{session_name}{Colors.RESET}")
print(f" Status: {status_color}{status}{Colors.RESET}")
print(f" PID: {pid}")
print(f" Command: {command}")
if "start_time" in session_info:
import time
elapsed = time.time() - session_info["start_time"]
print(f" Running for: {elapsed:.1f}s")
print()
def display_background_event(event):
"""Display a background event."""
event.get("type", "unknown")
session_name = event.get("session_name", "unknown")
timestamp = event.get("timestamp", 0)
message = event.get("message", "")
import datetime
time_str = datetime.datetime.fromtimestamp(timestamp).strftime("%H:%M:%S")
print(
f"{Colors.GRAY}[{time_str}]{Colors.RESET} {Colors.CYAN}{session_name}{Colors.RESET}: {message}"
)