Surface definition-of-done state in CLI and TUI
- SHA
f0c4a1751c6bf030a43bfe87f13bfd84f1156fc1- Parents
-
7d46142 - Tree
438a411
f0c4a17
f0c4a1751c6bf030a43bfe87f13bfd84f1156fc17d46142
438a411| Status | File | + | - |
|---|---|---|---|
| M |
src/loader/cli/__init__.py
|
9 | 1 |
| M |
src/loader/cli/main.py
|
22 | 4 |
| A |
src/loader/cli/rendering.py
|
15 | 0 |
| M |
src/loader/ui/__init__.py
|
9 | 1 |
| M |
src/loader/ui/adapter.py
|
32 | 8 |
| M |
src/loader/ui/app.py
|
34 | 12 |
| A |
src/loader/ui/status_helpers.py
|
34 | 0 |
| M |
src/loader/ui/widgets/status_line.py
|
42 | 0 |
| A |
tests/test_status_surfaces.py
|
32 | 0 |
src/loader/cli/__init__.pymodified@@ -1,5 +1,13 @@ | ||
| 1 | 1 | """CLI interface.""" |
| 2 | 2 | |
| 3 | -from .main import main | |
| 3 | +from typing import Any | |
| 4 | + | |
| 5 | + | |
| 6 | +def main(*args: Any, **kwargs: Any): | |
| 7 | + """Lazy wrapper for the Click entrypoint.""" | |
| 8 | + from .main import main as click_main | |
| 9 | + | |
| 10 | + return click_main(*args, **kwargs) | |
| 11 | + | |
| 4 | 12 | |
| 5 | 13 | __all__ = ["main"] |
src/loader/cli/main.pymodified@@ -11,6 +11,8 @@ from rich.panel import Panel | ||
| 11 | 11 | from rich.prompt import Confirm |
| 12 | 12 | from rich.table import Table |
| 13 | 13 | |
| 14 | +from .rendering import format_dod_status | |
| 15 | + | |
| 14 | 16 | console = Console() |
| 15 | 17 | |
| 16 | 18 | |
@@ -369,14 +371,22 @@ async def run_once(agent, prompt: str, skip_confirmation: bool = False) -> None: | ||
| 369 | 371 | console.print(f" [dim]({elapsed:.1f}s)[/dim]") |
| 370 | 372 | thinking_start = None |
| 371 | 373 | args_str = _format_tool_args(event.tool_args) |
| 372 | - console.print(f"[cyan]> {event.tool_name}[/cyan]({args_str})") | |
| 374 | + tool_label = ( | |
| 375 | + f"verify {event.tool_name}" | |
| 376 | + if event.phase == "verification" | |
| 377 | + else event.tool_name | |
| 378 | + ) | |
| 379 | + console.print(f"[cyan]> {tool_label}[/cyan]({args_str})") | |
| 373 | 380 | elif event.type == "tool_result": |
| 374 | 381 | # Show result in a compact panel |
| 375 | 382 | lines = event.content.splitlines() |
| 376 | 383 | preview = "\n".join(lines[:10]) |
| 377 | 384 | if len(lines) > 10: |
| 378 | 385 | preview += f"\n[dim]... ({len(lines) - 10} more lines)[/dim]" |
| 379 | - console.print(Panel(preview, border_style="dim")) | |
| 386 | + border_style = "magenta" if event.phase == "verification" else "dim" | |
| 387 | + console.print(Panel(preview, border_style=border_style)) | |
| 388 | + elif event.type == "dod_status": | |
| 389 | + console.print(f"[dim]{format_dod_status(event)}[/dim]") | |
| 380 | 390 | elif event.type == "recovery": |
| 381 | 391 | console.print(f"[yellow]Recovering from error ({event.recovery_attempt}/3)...[/yellow]") |
| 382 | 392 | elif event.type == "error": |
@@ -485,7 +495,12 @@ async def run_interactive(agent, skip_confirmation: bool = False) -> None: | ||
| 485 | 495 | console.print() # New line after any streamed content |
| 486 | 496 | streaming_started = False |
| 487 | 497 | args_str = _format_tool_args(event.tool_args) |
| 488 | - console.print(f"[cyan]> {event.tool_name}[/cyan]({args_str})") | |
| 498 | + tool_label = ( | |
| 499 | + f"verify {event.tool_name}" | |
| 500 | + if event.phase == "verification" | |
| 501 | + else event.tool_name | |
| 502 | + ) | |
| 503 | + console.print(f"[cyan]> {tool_label}[/cyan]({args_str})") | |
| 489 | 504 | elif event.type == "tool_result": |
| 490 | 505 | # Show compact result |
| 491 | 506 | lines = event.content.splitlines() |
@@ -493,7 +508,10 @@ async def run_interactive(agent, skip_confirmation: bool = False) -> None: | ||
| 493 | 508 | preview = event.content |
| 494 | 509 | else: |
| 495 | 510 | preview = "\n".join(lines[:3]) + f"\n[dim]... ({len(lines) - 3} more lines)[/dim]" |
| 496 | - console.print(f"[dim]{preview}[/dim]") | |
| 511 | + style = "magenta" if event.phase == "verification" else "dim" | |
| 512 | + console.print(f"[{style}]{preview}[/{style}]") | |
| 513 | + elif event.type == "dod_status": | |
| 514 | + console.print(f"\n[dim]{format_dod_status(event)}[/dim]") | |
| 497 | 515 | elif event.type == "recovery": |
| 498 | 516 | console.print(f"\n[yellow]Recovering from error ({event.recovery_attempt}/3)...[/yellow]") |
| 499 | 517 | elif event.type == "error": |
src/loader/cli/rendering.pyadded@@ -0,0 +1,15 @@ | ||
| 1 | +"""Lightweight CLI rendering helpers.""" | |
| 2 | + | |
| 3 | +from __future__ import annotations | |
| 4 | + | |
| 5 | +from ..runtime.events import AgentEvent | |
| 6 | + | |
| 7 | + | |
| 8 | +def format_dod_status(event: AgentEvent) -> str: | |
| 9 | + """Format a definition-of-done status event for CLI output.""" | |
| 10 | + parts = [f"DoD: {event.dod_status or 'unknown'}"] | |
| 11 | + if event.pending_items_count is not None: | |
| 12 | + parts.append(f"{event.pending_items_count} pending") | |
| 13 | + if event.last_verification_result: | |
| 14 | + parts.append(f"last verify: {event.last_verification_result}") | |
| 15 | + return " | ".join(parts) | |
src/loader/ui/__init__.pymodified@@ -1,5 +1,13 @@ | ||
| 1 | 1 | """Textual TUI for Loader.""" |
| 2 | 2 | |
| 3 | -from .app import LoaderApp | |
| 3 | +from typing import Any | |
| 4 | + | |
| 5 | + | |
| 6 | +def LoaderApp(*args: Any, **kwargs: Any): | |
| 7 | + """Lazy wrapper for the Textual application.""" | |
| 8 | + from .app import LoaderApp as _LoaderApp | |
| 9 | + | |
| 10 | + return _LoaderApp(*args, **kwargs) | |
| 11 | + | |
| 4 | 12 | |
| 5 | 13 | __all__ = ["LoaderApp"] |
src/loader/ui/adapter.pymodified@@ -9,14 +9,14 @@ from ..agent.loop import AgentEvent | ||
| 9 | 9 | |
| 10 | 10 | if TYPE_CHECKING: |
| 11 | 11 | from ..agent.reasoning import ( |
| 12 | - TaskDecomposition, | |
| 13 | - Subtask, | |
| 14 | - SelfCritique, | |
| 15 | - ConfidenceAssessment, | |
| 16 | 12 | ActionVerification, |
| 17 | - TaskCompletionCheck, | |
| 18 | - RollbackPlan, | |
| 13 | + ConfidenceAssessment, | |
| 19 | 14 | RollbackAction, |
| 15 | + RollbackPlan, | |
| 16 | + SelfCritique, | |
| 17 | + Subtask, | |
| 18 | + TaskCompletionCheck, | |
| 19 | + TaskDecomposition, | |
| 20 | 20 | ) |
| 21 | 21 | |
| 22 | 22 | |
@@ -42,6 +42,7 @@ class ToolCallStarted(Message): | ||
| 42 | 42 | |
| 43 | 43 | tool_name: str |
| 44 | 44 | tool_args: dict |
| 45 | + phase: str | None = None | |
| 45 | 46 | |
| 46 | 47 | |
| 47 | 48 | @dataclass |
@@ -51,6 +52,7 @@ class ToolCallCompleted(Message): | ||
| 51 | 52 | tool_name: str |
| 52 | 53 | content: str |
| 53 | 54 | is_error: bool = False |
| 55 | + phase: str | None = None | |
| 54 | 56 | # For edit tool diffs |
| 55 | 57 | old_string: str | None = None |
| 56 | 58 | new_string: str | None = None |
@@ -182,6 +184,16 @@ class RollbackSummary(Message): | ||
| 182 | 184 | rollback_plan: "RollbackPlan | None" = None |
| 183 | 185 | |
| 184 | 186 | |
| 187 | +@dataclass | |
| 188 | +class DefinitionOfDoneUpdated(Message): | |
| 189 | + """Definition-of-done status changed.""" | |
| 190 | + | |
| 191 | + content: str | |
| 192 | + dod_status: str | |
| 193 | + pending_items_count: int = 0 | |
| 194 | + last_verification_result: str | None = None | |
| 195 | + | |
| 196 | + | |
| 185 | 197 | class EventAdapter: |
| 186 | 198 | """Adapts Agent callback events to Textual messages.""" |
| 187 | 199 | |
@@ -244,6 +256,7 @@ class EventAdapter: | ||
| 244 | 256 | ToolCallStarted( |
| 245 | 257 | tool_name=tool_name, |
| 246 | 258 | tool_args=tool_args, |
| 259 | + phase=event.phase, | |
| 247 | 260 | ) |
| 248 | 261 | ) |
| 249 | 262 | |
@@ -297,7 +310,7 @@ class EventAdapter: | ||
| 297 | 310 | ) |
| 298 | 311 | self._debug_log(f" edit extracted: old={bool(old_string)} ({len(old_string) if old_string else 0} chars), new={bool(new_string)} ({len(new_string) if new_string else 0} chars), path={file_path}") |
| 299 | 312 | else: |
| 300 | - self._debug_log(f" edit: tool_args was empty!") | |
| 313 | + self._debug_log(" edit: tool_args was empty!") | |
| 301 | 314 | elif tool_name == "write": |
| 302 | 315 | # For writes, content is the new file content |
| 303 | 316 | # Try multiple key names that models might use |
@@ -315,13 +328,14 @@ class EventAdapter: | ||
| 315 | 328 | ) |
| 316 | 329 | self._debug_log(f" write extracted: new={bool(new_string)} ({len(new_string) if new_string else 0} chars), path={file_path}") |
| 317 | 330 | else: |
| 318 | - self._debug_log(f" write: tool_args was empty!") | |
| 331 | + self._debug_log(" write: tool_args was empty!") | |
| 319 | 332 | |
| 320 | 333 | self.app.post_message( |
| 321 | 334 | ToolCallCompleted( |
| 322 | 335 | tool_name=tool_name, |
| 323 | 336 | content=event.content, |
| 324 | 337 | is_error=event.is_error, |
| 338 | + phase=event.phase, | |
| 325 | 339 | old_string=old_string, |
| 326 | 340 | new_string=new_string, |
| 327 | 341 | file_path=file_path, |
@@ -414,3 +428,13 @@ class EventAdapter: | ||
| 414 | 428 | content=event.content, |
| 415 | 429 | rollback_plan=event.rollback_plan, |
| 416 | 430 | )) |
| 431 | + | |
| 432 | + case "dod_status": | |
| 433 | + self.app.post_message( | |
| 434 | + DefinitionOfDoneUpdated( | |
| 435 | + content=event.content, | |
| 436 | + dod_status=event.dod_status or "", | |
| 437 | + pending_items_count=event.pending_items_count or 0, | |
| 438 | + last_verification_result=event.last_verification_result, | |
| 439 | + ) | |
| 440 | + ) | |
src/loader/ui/app.pymodified@@ -5,13 +5,12 @@ import time | ||
| 5 | 5 | from pathlib import Path |
| 6 | 6 | |
| 7 | 7 | from rich.markup import escape |
| 8 | - | |
| 8 | +from textual import work | |
| 9 | 9 | from textual.app import App, ComposeResult |
| 10 | 10 | from textual.binding import Binding |
| 11 | 11 | from textual.containers import Container, ScrollableContainer |
| 12 | 12 | from textual.reactive import reactive |
| 13 | 13 | from textual.widgets import Footer, Input, Static |
| 14 | -from textual import work | |
| 15 | 14 | from textual.worker import Worker, get_current_worker |
| 16 | 15 | |
| 17 | 16 | from ..agent.loop import Agent, AgentEvent |
@@ -21,6 +20,7 @@ from .adapter import ( | ||
| 21 | 20 | ConfidenceAssessed, |
| 22 | 21 | CritiquePerformed, |
| 23 | 22 | DecompositionCreated, |
| 23 | + DefinitionOfDoneUpdated, | |
| 24 | 24 | ErrorOccurred, |
| 25 | 25 | EventAdapter, |
| 26 | 26 | PlanCreated, |
@@ -36,7 +36,14 @@ from .adapter import ( | ||
| 36 | 36 | ToolCallStarted, |
| 37 | 37 | VerificationPerformed, |
| 38 | 38 | ) |
| 39 | -from .widgets import ApprovalBar, ConfirmationModal, DiffWidget, InputArea, StatusLine, StreamingText, ToolCallWidget | |
| 39 | +from .widgets import ( | |
| 40 | + ApprovalBar, | |
| 41 | + DiffWidget, | |
| 42 | + InputArea, | |
| 43 | + StatusLine, | |
| 44 | + StreamingText, | |
| 45 | + ToolCallWidget, | |
| 46 | +) | |
| 40 | 47 | |
| 41 | 48 | |
| 42 | 49 | class LoaderApp(App): |
@@ -174,7 +181,9 @@ class LoaderApp(App): | ||
| 174 | 181 | # Show generating status immediately (before async work starts) |
| 175 | 182 | self.is_generating = True |
| 176 | 183 | self._start_timer() |
| 177 | - self.query_one(StatusLine).set_generating(True) | |
| 184 | + status = self.query_one(StatusLine) | |
| 185 | + status.clear_definition_of_done() | |
| 186 | + status.set_generating(True) | |
| 178 | 187 | |
| 179 | 188 | # Start agent task |
| 180 | 189 | self.run_agent(user_input) |
@@ -291,7 +300,6 @@ class LoaderApp(App): | ||
| 291 | 300 | details: str, |
| 292 | 301 | ) -> bool: |
| 293 | 302 | """Show approval bar and wait for user response.""" |
| 294 | - import threading | |
| 295 | 303 | |
| 296 | 304 | # Create a future to wait on |
| 297 | 305 | loop = asyncio.get_event_loop() |
@@ -305,7 +313,7 @@ class LoaderApp(App): | ||
| 305 | 313 | try: |
| 306 | 314 | approval_bar.show_approval(tool_name, message, details) |
| 307 | 315 | with open("/tmp/loader_debug.log", "a") as f: |
| 308 | - f.write(f"[approval] Bar shown, waiting for user input\n") | |
| 316 | + f.write("[approval] Bar shown, waiting for user input\n") | |
| 309 | 317 | except Exception as e: |
| 310 | 318 | with open("/tmp/loader_debug.log", "a") as f: |
| 311 | 319 | f.write(f"[approval] Error showing bar: {e}\n") |
@@ -328,10 +336,10 @@ class LoaderApp(App): | ||
| 328 | 336 | except Exception: |
| 329 | 337 | pass |
| 330 | 338 | return result |
| 331 | - except asyncio.TimeoutError: | |
| 339 | + except TimeoutError: | |
| 332 | 340 | try: |
| 333 | 341 | with open("/tmp/loader_debug.log", "a") as f: |
| 334 | - f.write(f"[approval] Timeout waiting for user\n") | |
| 342 | + f.write("[approval] Timeout waiting for user\n") | |
| 335 | 343 | except Exception: |
| 336 | 344 | pass |
| 337 | 345 | return False |
@@ -348,7 +356,7 @@ class LoaderApp(App): | ||
| 348 | 356 | """Handle approval from the bar.""" |
| 349 | 357 | try: |
| 350 | 358 | with open("/tmp/loader_debug.log", "a") as f: |
| 351 | - f.write(f"[approval] Approved handler called\n") | |
| 359 | + f.write("[approval] Approved handler called\n") | |
| 352 | 360 | except Exception: |
| 353 | 361 | pass |
| 354 | 362 | if self._pending_confirmation and not self._pending_confirmation.done(): |
@@ -358,7 +366,7 @@ class LoaderApp(App): | ||
| 358 | 366 | """Handle rejection from the bar.""" |
| 359 | 367 | try: |
| 360 | 368 | with open("/tmp/loader_debug.log", "a") as f: |
| 361 | - f.write(f"[approval] Rejected handler called\n") | |
| 369 | + f.write("[approval] Rejected handler called\n") | |
| 362 | 370 | except Exception: |
| 363 | 371 | pass |
| 364 | 372 | if self._pending_confirmation and not self._pending_confirmation.done(): |
@@ -370,7 +378,7 @@ class LoaderApp(App): | ||
| 370 | 378 | """Handle edit request - put command in input for editing.""" |
| 371 | 379 | try: |
| 372 | 380 | with open("/tmp/loader_debug.log", "a") as f: |
| 373 | - f.write(f"[approval] Edit handler called\n") | |
| 381 | + f.write("[approval] Edit handler called\n") | |
| 374 | 382 | except Exception: |
| 375 | 383 | pass |
| 376 | 384 | if self._pending_confirmation and not self._pending_confirmation.done(): |
@@ -386,6 +394,7 @@ class LoaderApp(App): | ||
| 386 | 394 | async def run_agent(self, user_input: str) -> str: |
| 387 | 395 | """Run the agent asynchronously.""" |
| 388 | 396 | import asyncio |
| 397 | + | |
| 389 | 398 | import httpx |
| 390 | 399 | |
| 391 | 400 | worker = get_current_worker() |
@@ -499,7 +508,11 @@ class LoaderApp(App): | ||
| 499 | 508 | |
| 500 | 509 | # Create tool widget |
| 501 | 510 | widget = ToolCallWidget( |
| 502 | - tool_name=message.tool_name, | |
| 511 | + tool_name=( | |
| 512 | + f"verify {message.tool_name}" | |
| 513 | + if message.phase == "verification" | |
| 514 | + else message.tool_name | |
| 515 | + ), | |
| 503 | 516 | tool_args=message.tool_args, |
| 504 | 517 | ) |
| 505 | 518 | msg_area.mount(widget) |
@@ -583,6 +596,14 @@ class LoaderApp(App): | ||
| 583 | 596 | if not self._streamed_content and message.content.strip(): |
| 584 | 597 | self._add_message(message.content) |
| 585 | 598 | |
| 599 | + def on_definition_of_done_updated(self, message: DefinitionOfDoneUpdated) -> None: | |
| 600 | + """Handle definition-of-done status changes.""" | |
| 601 | + self.query_one(StatusLine).update_definition_of_done( | |
| 602 | + message.dod_status, | |
| 603 | + message.pending_items_count, | |
| 604 | + message.last_verification_result, | |
| 605 | + ) | |
| 606 | + | |
| 586 | 607 | def on_steering_received(self, message: SteeringReceived) -> None: |
| 587 | 608 | """Handle steering message being processed by agent.""" |
| 588 | 609 | # Don't display anything - auto-steering is internal |
@@ -722,6 +743,7 @@ class LoaderApp(App): | ||
| 722 | 743 | msg_area = self.query_one("#message-area", ScrollableContainer) |
| 723 | 744 | msg_area.remove_children() |
| 724 | 745 | self.agent.clear_history() |
| 746 | + self.query_one(StatusLine).clear_definition_of_done() | |
| 725 | 747 | self._add_message("[dim]Conversation cleared.[/dim]") |
| 726 | 748 | |
| 727 | 749 | def action_cancel(self) -> None: |
src/loader/ui/status_helpers.pyadded@@ -0,0 +1,34 @@ | ||
| 1 | +"""Formatting helpers for user-visible runtime status.""" | |
| 2 | + | |
| 3 | +from __future__ import annotations | |
| 4 | + | |
| 5 | + | |
| 6 | +def format_definition_of_done_parts( | |
| 7 | + status: str, | |
| 8 | + pending_items_count: int, | |
| 9 | + last_verification_result: str, | |
| 10 | +) -> list[str]: | |
| 11 | + """Format definition-of-done state for the status line.""" | |
| 12 | + if not status: | |
| 13 | + return [] | |
| 14 | + | |
| 15 | + dod_color = { | |
| 16 | + "draft": "cyan", | |
| 17 | + "in_progress": "cyan", | |
| 18 | + "verifying": "yellow", | |
| 19 | + "fixing": "magenta", | |
| 20 | + "done": "green", | |
| 21 | + "failed": "red", | |
| 22 | + }.get(status, "white") | |
| 23 | + parts = [f"[{dod_color}]DoD: {status}[/{dod_color}]"] | |
| 24 | + parts.append(f"[dim]{pending_items_count} pending[/dim]") | |
| 25 | + | |
| 26 | + if last_verification_result: | |
| 27 | + verify_color = "green" if last_verification_result == "passed" else "red" | |
| 28 | + if last_verification_result == "skipped": | |
| 29 | + verify_color = "dim" | |
| 30 | + parts.append( | |
| 31 | + f"[{verify_color}]verify {last_verification_result}[/{verify_color}]" | |
| 32 | + ) | |
| 33 | + | |
| 34 | + return parts | |
src/loader/ui/widgets/status_line.pymodified@@ -3,6 +3,8 @@ | ||
| 3 | 3 | from textual.reactive import reactive |
| 4 | 4 | from textual.widgets import Static |
| 5 | 5 | |
| 6 | +from ..status_helpers import format_definition_of_done_parts | |
| 7 | + | |
| 6 | 8 | |
| 7 | 9 | class StatusLine(Static): |
| 8 | 10 | """Status bar showing model info, activity, elapsed time, and tokens.""" |
@@ -12,6 +14,9 @@ class StatusLine(Static): | ||
| 12 | 14 | activity: reactive[str] = reactive("") |
| 13 | 15 | elapsed: reactive[float] = reactive(0.0) |
| 14 | 16 | tokens: reactive[int] = reactive(0) |
| 17 | + dod_status: reactive[str] = reactive("") | |
| 18 | + pending_items_count: reactive[int] = reactive(0) | |
| 19 | + last_verification_result: reactive[str] = reactive("") | |
| 15 | 20 | |
| 16 | 21 | def render(self) -> str: |
| 17 | 22 | """Render the status line.""" |
@@ -29,6 +34,14 @@ class StatusLine(Static): | ||
| 29 | 34 | if self.tokens > 0: |
| 30 | 35 | parts.append(f"[dim]{self.tokens} tokens[/dim]") |
| 31 | 36 | |
| 37 | + parts.extend( | |
| 38 | + format_definition_of_done_parts( | |
| 39 | + self.dod_status, | |
| 40 | + self.pending_items_count, | |
| 41 | + self.last_verification_result, | |
| 42 | + ) | |
| 43 | + ) | |
| 44 | + | |
| 32 | 45 | # Model info |
| 33 | 46 | if self.model: |
| 34 | 47 | parts.append(f"[blue]{self.model}[/blue]") |
@@ -51,6 +64,18 @@ class StatusLine(Static): | ||
| 51 | 64 | """React to token count changes.""" |
| 52 | 65 | self.refresh() |
| 53 | 66 | |
| 67 | + def watch_dod_status(self, dod_status: str) -> None: | |
| 68 | + """React to DoD status changes.""" | |
| 69 | + self.refresh() | |
| 70 | + | |
| 71 | + def watch_pending_items_count(self, pending_items_count: int) -> None: | |
| 72 | + """React to DoD pending item changes.""" | |
| 73 | + self.refresh() | |
| 74 | + | |
| 75 | + def watch_last_verification_result(self, last_verification_result: str) -> None: | |
| 76 | + """React to verification result changes.""" | |
| 77 | + self.refresh() | |
| 78 | + | |
| 54 | 79 | def set_generating(self, is_generating: bool) -> None: |
| 55 | 80 | """Set generating state.""" |
| 56 | 81 | if is_generating: |
@@ -66,3 +91,20 @@ class StatusLine(Static): | ||
| 66 | 91 | def update_tokens(self, tokens: int) -> None: |
| 67 | 92 | """Update token count.""" |
| 68 | 93 | self.tokens = tokens |
| 94 | + | |
| 95 | + def update_definition_of_done( | |
| 96 | + self, | |
| 97 | + status: str, | |
| 98 | + pending_items_count: int, | |
| 99 | + last_verification_result: str | None, | |
| 100 | + ) -> None: | |
| 101 | + """Update definition-of-done status.""" | |
| 102 | + self.dod_status = status | |
| 103 | + self.pending_items_count = pending_items_count | |
| 104 | + self.last_verification_result = last_verification_result or "" | |
| 105 | + | |
| 106 | + def clear_definition_of_done(self) -> None: | |
| 107 | + """Clear definition-of-done status.""" | |
| 108 | + self.dod_status = "" | |
| 109 | + self.pending_items_count = 0 | |
| 110 | + self.last_verification_result = "" | |
tests/test_status_surfaces.pyadded@@ -0,0 +1,32 @@ | ||
| 1 | +"""Tests for user-visible definition-of-done status formatting.""" | |
| 2 | + | |
| 3 | +from loader.cli.rendering import format_dod_status | |
| 4 | +from loader.runtime.events import AgentEvent | |
| 5 | +from loader.ui.status_helpers import format_definition_of_done_parts | |
| 6 | + | |
| 7 | + | |
| 8 | +def test_status_helper_formats_definition_of_done_parts() -> None: | |
| 9 | + parts = format_definition_of_done_parts("verifying", 1, "failed") | |
| 10 | + | |
| 11 | + assert parts == [ | |
| 12 | + "[yellow]DoD: verifying[/yellow]", | |
| 13 | + "[dim]1 pending[/dim]", | |
| 14 | + "[red]verify failed[/red]", | |
| 15 | + ] | |
| 16 | + | |
| 17 | + | |
| 18 | +def test_status_helper_omits_definition_of_done_when_absent() -> None: | |
| 19 | + assert format_definition_of_done_parts("", 0, "") == [] | |
| 20 | + | |
| 21 | + | |
| 22 | +def test_cli_dod_status_format_includes_pending_and_verification() -> None: | |
| 23 | + event = AgentEvent( | |
| 24 | + type="dod_status", | |
| 25 | + dod_status="fixing", | |
| 26 | + pending_items_count=2, | |
| 27 | + last_verification_result="failed", | |
| 28 | + ) | |
| 29 | + | |
| 30 | + formatted = format_dod_status(event) | |
| 31 | + | |
| 32 | + assert formatted == "DoD: fixing | 2 pending | last verify: failed" | |