feat: render reasoning as italics

This commit is contained in:
banteg
2025-12-29 03:05:43 +04:00
parent 6ec5469a0b
commit 26fa96a353
2 changed files with 7 additions and 1 deletions
@@ -90,6 +90,9 @@ def extract_numeric_id(item_id: Optional[object], fallback: Optional[int] = None
def attach_id(item_id: Optional[int], line: str) -> str: def attach_id(item_id: Optional[int], line: str) -> str:
return f"[{item_id if item_id is not None else '?'}] {line}" return f"[{item_id if item_id is not None else '?'}] {line}"
def format_reasoning(text: str) -> str:
return f"_{one_line(text)}_"
def format_item_action_line(etype: str, item: dict[str, Any]) -> str | None: def format_item_action_line(etype: str, item: dict[str, Any]) -> str | None:
match (item["type"], etype): match (item["type"], etype):
@@ -113,6 +116,8 @@ def format_item_action_line(etype: str, item: dict[str, Any]) -> str | None:
def format_item_completed_line(item: dict[str, Any]) -> str | None: def format_item_completed_line(item: dict[str, Any]) -> str | None:
match item["type"]: match item["type"]:
case "reasoning":
return format_reasoning(item["text"])
case "web_search": case "web_search":
query = format_query(item["query"]) query = format_query(item["query"])
return f"{STATUS_DONE} searched: {query}" return f"{STATUS_DONE} searched: {query}"
@@ -28,8 +28,10 @@ def test_render_event_cli_sample_stream() -> None:
assert out == [ assert out == [
"thread started", "thread started",
"turn started", "turn started",
"[0] _**Searching for README files**_",
"[1] ▸ running: `bash -lc ls`", "[1] ▸ running: `bash -lc ls`",
"[1] ✓ ran: `bash -lc ls` (exit 0)", "[1] ✓ ran: `bash -lc ls` (exit 0)",
"[2] _**Checking repository root for README**_",
"assistant:", "assistant:",
" Yep — theres a `README.md` in the repository root.", " Yep — theres a `README.md` in the repository root.",
"turn completed", "turn completed",
@@ -50,4 +52,3 @@ def test_progress_renderer_renders_progress_and_final() -> None:
assert "running:" not in final assert "running:" not in final
assert "ran:" not in final assert "ran:" not in final
assert final.endswith("answer") assert final.endswith("answer")