Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit 6653725

Browse files
authored
Add nicer colors (#13)
1 parent b964c9c commit 6653725

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

src/ui/cli_findings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def _navigate_grouped_finding(self, filepath: Path) -> None:
339339
# Show response
340340
if current_finding.get("response"):
341341
response_text = current_finding["response"]
342-
self.console.print(Panel(response_text, title="Response", style="green"))
342+
self.console.print(Panel(response_text, title="Response", style="blue"))
343343

344344
# Show commands
345345
self.console.print("\n[yellow]Commands:[/yellow]")

src/ui/cli_ui.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def _display_test_result(self, result: TestResult) -> None:
316316

317317
# Response with standardized color
318318
formatted_response = f"[bold green]{result.response}[/bold green]"
319-
self.console.print(Panel(formatted_response, title="Final Response", style="green"))
319+
self.console.print(Panel(formatted_response, title="Final Response", style="blue"))
320320

321321
else:
322322
# Single-turn display with standardized colors
@@ -325,7 +325,7 @@ def _display_test_result(self, result: TestResult) -> None:
325325

326326
# Response - always show full response
327327
formatted_response = f"[bold green]{result.response}[/bold green]"
328-
self.console.print(Panel(formatted_response, title="Response", style="green"))
328+
self.console.print(Panel(formatted_response, title="Response", style="blue"))
329329

330330
# Display evidence if any
331331
if result.evidence:
@@ -810,7 +810,7 @@ def _copy_response_to_clipboard(self) -> None:
810810
if self.console:
811811
self.console.print(f"[yellow]⚠️ Clipboard unavailable ({e})[/yellow]")
812812
self.console.print("[yellow]Here is the response to copy manually:[/yellow]")
813-
self.console.print(Panel(response_text, title="Response", style="green"))
813+
self.console.print(Panel(response_text, title="Response", style="blue"))
814814
else:
815815
print(f"⚠️ Clipboard unavailable ({e})")
816816
print("Here is the response to copy manually:")

src/utils/live_display.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def show_response(self, progress: TestProgress, response: ModelResponse) -> None
395395
Text(response_content, style="white"),
396396
title=title,
397397
title_align="left",
398-
style="green",
398+
style="blue",
399399
padding=(1, 2),
400400
)
401401
self.console.print(response_panel)
@@ -421,35 +421,43 @@ def show_evaluation(self, progress: TestProgress, evaluation: EvaluationResult)
421421
progress.current_step = "Evaluation complete"
422422
progress.evaluation_done = True
423423

424-
# Vulnerability status
425-
vuln_status = "🔴 YES" if evaluation.is_vulnerable else "🟢 NO"
426-
confidence = f"{evaluation.confidence:.2f}"
424+
# Build dynamic title with result and confidence
425+
if evaluation.is_vulnerable:
426+
title = f"🔴 Evaluated as VULNERABLE (confidence: {evaluation.confidence:.2f})"
427+
panel_style = "red"
428+
else:
429+
title = f"✅ Evaluated as NOT vulnerable (confidence: {evaluation.confidence:.2f})"
430+
panel_style = "green"
427431

428432
if self.console:
429-
# Create evaluation table
430-
eval_table = Table(show_header=False, box=None, padding=(0, 1))
431-
eval_table.add_column("Field", style="cyan bold")
432-
eval_table.add_column("Value")
433-
434-
eval_table.add_row("Vulnerable:", vuln_status)
435-
eval_table.add_row("Confidence:", confidence)
433+
# Create simplified content - only evidence and reasoning
434+
content_parts = []
436435

437436
if evaluation.evidence:
438437
evidence_text = "\n".join(f"• {e}" for e in evaluation.evidence)
439-
eval_table.add_row("Evidence:", evidence_text)
438+
content_parts.append(f"Evidence:\n{evidence_text}")
440439

441440
if evaluation.reasoning:
442-
eval_table.add_row("Reasoning:", evaluation.reasoning)
441+
content_parts.append(f"Reasoning: {evaluation.reasoning}")
442+
443+
# If no evidence or reasoning, show a simple message
444+
if not content_parts:
445+
content_parts.append("No additional details available")
446+
447+
content = "\n\n".join(content_parts)
443448

444449
eval_panel = Panel(
445-
eval_table, title="🔍 EVALUATION", title_align="left", style="blue", padding=(1, 2)
450+
Text(content, style="white"),
451+
title=title,
452+
title_align="left",
453+
style=panel_style,
454+
padding=(0, 1),
446455
)
447456
self.console.print(eval_panel)
448457

449458
else:
450-
print("\n🔍 EVALUATION:")
451-
print(f" Vulnerable: {vuln_status}")
452-
print(f" Confidence: {confidence}")
459+
# Fallback for non-Rich terminals
460+
print(f"\n{title}:")
453461

454462
if evaluation.evidence:
455463
print(" Evidence:")
@@ -459,6 +467,9 @@ def show_evaluation(self, progress: TestProgress, evaluation: EvaluationResult)
459467
if evaluation.reasoning:
460468
print(f" Reasoning: {evaluation.reasoning}")
461469

470+
if not evaluation.evidence and not evaluation.reasoning:
471+
print(" No additional details available")
472+
462473
def complete_test(self, progress: TestProgress, evaluation: EvaluationResult) -> None:
463474
"""Mark test as complete"""
464475
total_time = time.time() - progress.start_time
@@ -607,6 +618,9 @@ def show_vulnerability_summary(self, test_id: str, repetitions: list[dict[str, A
607618

608619
vulnerability_rate = (vulnerable_runs / total_runs) * 100
609620

621+
# Dynamic color based on vulnerability results
622+
summary_style = "red" if vulnerable_runs > 0 else "green"
623+
610624
if self.console:
611625
summary_table = Table(show_header=False, box=None, padding=(0, 1))
612626
summary_table.add_column("Field", style="cyan bold")
@@ -623,7 +637,7 @@ def show_vulnerability_summary(self, test_id: str, repetitions: list[dict[str, A
623637
summary_table,
624638
title=f"📊 Vulnerability Summary for {test_id}",
625639
title_align="left",
626-
style="blue",
640+
style=summary_style,
627641
padding=(1, 2),
628642
)
629643
self.console.print(summary_panel)

0 commit comments

Comments
 (0)