Skip to content

Commit e23245f

Browse files
committed
fix: print the tool result marker on its own line after the output
The timestamp/metrics marker used to ride the first line of a tool result, mixing bookkeeping into the output. It now lands on its own line at the end.
1 parent 4712f53 commit e23245f

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/lecode/tui/feed.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ def tool_call(self, name: str, args_preview: str) -> None:
183183
self._console.print(Text(line + self._suffix(), style=self._theme.tool))
184184

185185
def tool_result(self, name: str, content: str, is_error: bool = False) -> None:
186-
"""Render a tool result head with ``… (N more lines)`` elision."""
186+
"""Render a tool result head with ``… (N more lines)`` elision.
187+
188+
The timestamp/metrics marker goes on its own line after the output,
189+
so multi-line output reads top-down and the bookkeeping lands last.
190+
"""
187191
lines = content.splitlines()
188192
shown = lines[:TOOL_RESULT_HEAD_LINES]
189193
if len(lines) > TOOL_RESULT_HEAD_LINES:
190194
shown.append(f"… ({len(lines) - TOOL_RESULT_HEAD_LINES} more lines)")
191-
if shown:
192-
shown[0] = f"[{self._stamp()}] {shown[0]}{self._suffix()}"
195+
shown.append(f"[{self._stamp()}]{self._suffix()}")
193196
style = self._theme.error if is_error else self._theme.muted
194197
self._console.print(Text("\n".join(shown), style=style))
195198

tests/test_tui_feed.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ def test_lines_carry_timestamps(theme):
5353
cost_usd=0.001,
5454
session_cost_usd=0.002,
5555
)
56-
stamped = [ln for ln in out.getvalue().splitlines() if ln.startswith("[")]
57-
# tool call, tool result, info, error, turn stats (not the user echo)
56+
lines = out.getvalue().splitlines()
57+
stamped = [ln for ln in lines if ln.startswith("[")]
58+
# tool call, tool result marker, info, error, turn stats (not the user echo)
5859
assert len(stamped) == 5
5960
assert all(len(ln) >= 10 and ln[1:3].isdigit() and ln[3] == ":" for ln in stamped)
61+
# the tool result marker is its own line after the output
62+
assert lines[lines.index("ok") + 1].startswith("[")
6063

6164

6265
def test_metrics_suffix_on_action_lines(theme):

0 commit comments

Comments
 (0)