Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit ·
22c7ba4
1
Parent(s): 4eb48db
Sub-agent display: 2 lines, gray, 20 char truncation
Browse files
agent/utils/terminal_display.py
CHANGED
|
@@ -65,22 +65,22 @@ def print_tool_output(output: str, success: bool, truncate: bool = True) -> None
|
|
| 65 |
|
| 66 |
|
| 67 |
class SubAgentDisplay:
|
| 68 |
-
"""Rolling
|
| 69 |
|
| 70 |
-
_MAX_VISIBLE =
|
|
|
|
| 71 |
|
| 72 |
def __init__(self):
|
| 73 |
self._calls: list[str] = []
|
| 74 |
self._lines_on_screen = 0
|
| 75 |
|
| 76 |
def update(self, tool_desc: str) -> None:
|
| 77 |
-
|
| 78 |
-
self._calls.append(
|
| 79 |
visible = self._calls[-self._MAX_VISIBLE:]
|
| 80 |
self._redraw(visible)
|
| 81 |
|
| 82 |
def clear(self) -> None:
|
| 83 |
-
"""Erase the display and reset state."""
|
| 84 |
if self._lines_on_screen > 0:
|
| 85 |
f = _console.file
|
| 86 |
for _ in range(self._lines_on_screen):
|
|
@@ -91,17 +91,11 @@ class SubAgentDisplay:
|
|
| 91 |
|
| 92 |
def _redraw(self, visible: list[str]) -> None:
|
| 93 |
f = _console.file
|
| 94 |
-
# Erase previous lines
|
| 95 |
if self._lines_on_screen > 0:
|
| 96 |
for _ in range(self._lines_on_screen):
|
| 97 |
f.write("\033[A\033[K")
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
dim = i < len(visible) - 1 # older calls are dimmer
|
| 101 |
-
if dim:
|
| 102 |
-
f.write(f"{_I} \033[2m{desc}\033[0m\n")
|
| 103 |
-
else:
|
| 104 |
-
f.write(f"{_I}\033[36m▸ {desc}\033[0m\n")
|
| 105 |
f.flush()
|
| 106 |
self._lines_on_screen = len(visible)
|
| 107 |
|
|
|
|
| 65 |
|
| 66 |
|
| 67 |
class SubAgentDisplay:
|
| 68 |
+
"""Rolling 2-line gray display of the last 2 sub-agent tool calls, truncated to 20 chars."""
|
| 69 |
|
| 70 |
+
_MAX_VISIBLE = 2
|
| 71 |
+
_MAX_CHARS = 20
|
| 72 |
|
| 73 |
def __init__(self):
|
| 74 |
self._calls: list[str] = []
|
| 75 |
self._lines_on_screen = 0
|
| 76 |
|
| 77 |
def update(self, tool_desc: str) -> None:
|
| 78 |
+
truncated = tool_desc[:self._MAX_CHARS] + ("…" if len(tool_desc) > self._MAX_CHARS else "")
|
| 79 |
+
self._calls.append(truncated)
|
| 80 |
visible = self._calls[-self._MAX_VISIBLE:]
|
| 81 |
self._redraw(visible)
|
| 82 |
|
| 83 |
def clear(self) -> None:
|
|
|
|
| 84 |
if self._lines_on_screen > 0:
|
| 85 |
f = _console.file
|
| 86 |
for _ in range(self._lines_on_screen):
|
|
|
|
| 91 |
|
| 92 |
def _redraw(self, visible: list[str]) -> None:
|
| 93 |
f = _console.file
|
|
|
|
| 94 |
if self._lines_on_screen > 0:
|
| 95 |
for _ in range(self._lines_on_screen):
|
| 96 |
f.write("\033[A\033[K")
|
| 97 |
+
for desc in visible:
|
| 98 |
+
f.write(f"{_I} \033[2m{desc}\033[0m\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
f.flush()
|
| 100 |
self._lines_on_screen = len(visible)
|
| 101 |
|