Print a summary to the terminal after the Textual TUI exits.
(app: CrewRunApp)
| 491 | |
| 492 | |
| 493 | def _print_post_tui_summary(app: CrewRunApp) -> None: |
| 494 | """Print a summary to the terminal after the Textual TUI exits.""" |
| 495 | import time |
| 496 | |
| 497 | from rich.console import Console |
| 498 | from rich.markdown import Markdown |
| 499 | from rich.padding import Padding |
| 500 | from rich.panel import Panel |
| 501 | from rich.text import Text |
| 502 | |
| 503 | console = Console() |
| 504 | elapsed = time.time() - app._start_time |
| 505 | |
| 506 | out_tokens = app._output_tokens + app._live_out_tokens |
| 507 | token_parts = [] |
| 508 | if app._input_tokens: |
| 509 | token_parts.append(f"↑{app._input_tokens:,}") |
| 510 | if out_tokens: |
| 511 | token_parts.append(f"↓{out_tokens:,}") |
| 512 | token_str = " ".join(token_parts) |
| 513 | if token_str: |
| 514 | token_str += " tokens" |
| 515 | |
| 516 | crewai_red = "#FF5A50" |
| 517 | crewai_teal = "#1F7982" |
| 518 | |
| 519 | if app._status == "completed": |
| 520 | summary = Text() |
| 521 | summary.append( |
| 522 | f" ✔ Completed {app._total_tasks} tasks", |
| 523 | style=f"bold {crewai_teal}", |
| 524 | ) |
| 525 | summary.append(f" in {elapsed:.1f}s", style="dim") |
| 526 | if token_str: |
| 527 | summary.append(f" {token_str}", style="dim") |
| 528 | console.print( |
| 529 | Panel( |
| 530 | summary, |
| 531 | title=f" {app._crew_name} ", |
| 532 | title_align="left", |
| 533 | border_style=crewai_teal, |
| 534 | padding=(0, 1), |
| 535 | ) |
| 536 | ) |
| 537 | if app._final_output: |
| 538 | console.print() |
| 539 | console.print(Text(" Final Result", style=f"bold {crewai_teal}")) |
| 540 | console.print() |
| 541 | console.print(Padding(Markdown(app._final_output), (0, 2))) |
| 542 | elif app._status == "failed": |
| 543 | content = Text() |
| 544 | content.append(" ✘ Failed", style=f"bold {crewai_red}") |
| 545 | content.append(f" after {elapsed:.1f}s\n", style="dim") |
| 546 | if app._error: |
| 547 | content.append(f"\n {app._error}\n", style=crewai_red) |
| 548 | console.print( |
| 549 | Panel( |
| 550 | content, |
no test coverage detected
searching dependent graphs…