feat(tracing): enhance first-time trace display and auto-open browser

This commit is contained in:
Joao Moura
2025-09-18 16:37:48 -07:00
parent 2f682e1564
commit a0cbb5cfdb
2 changed files with 9 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
import logging
import uuid
import webbrowser
from rich.console import Console
from rich.panel import Panel
@@ -108,9 +109,14 @@ class FirstTimeTraceHandler:
self._gracefully_fail(f"Backend initialization failed: {e}")
def _display_ephemeral_trace_link(self):
"""Display the ephemeral trace link to the user."""
"""Display the ephemeral trace link to the user and automatically open browser."""
console = Console()
try:
webbrowser.open(self.ephemeral_url)
except Exception as e:
pass
panel_content = f"""
🎉 Your First CrewAI Execution Trace is Ready!

View File

@@ -138,13 +138,6 @@ class TraceBatchManager:
if not use_ephemeral
else response_data["ephemeral_trace_id"]
)
console = Console()
panel = Panel(
f"✅ Trace batch initialized with session ID: {self.trace_batch_id}",
title="Trace Batch Initialization",
border_style="green",
)
console.print(panel)
else:
logger.warning(
f"Trace batch initialization returned status {response.status_code}. Continuing without tracing."
@@ -263,7 +256,8 @@ class TraceBatchManager:
title="Trace Batch Finalization",
border_style="green",
)
console.print(panel)
if not should_auto_collect_first_time_traces():
console.print(panel)
else:
logger.error(