tenseleyflow/loader / b2fd90c

Browse files

Show file content preview in tool widget for write/edit calls before approval

Authored by espadonne
SHA
b2fd90ce4011a0369028e2e6cd23e7815f8abcde
Parents
0f650d2
Tree
aba79a2

1 changed file

StatusFile+-
M src/loader/ui/widgets/tool_widget.py 17 1
src/loader/ui/widgets/tool_widget.pymodified
@@ -47,7 +47,23 @@ class ToolCallWidget(Vertical):
4747
             id="tool-header",
4848
             classes="tool-header",
4949
         )
50
-        yield Static("", id="tool-summary", classes="tool-summary")
50
+
51
+        # For write/edit tools, show the content as a pre-approval preview
52
+        initial_summary = Text()
53
+        if self.tool_name in ("write", "edit", "patch"):
54
+            content = self.tool_args.get("content", "")
55
+            file_path = self.tool_args.get("file_path", "")
56
+            if content and file_path:
57
+                initial_summary.append(f"  ► {file_path}\n", style="bold")
58
+                lines = content.splitlines()
59
+                for i, line in enumerate(lines[:20]):
60
+                    initial_summary.append(f"  {i + 1:>3} ", style="dim")
61
+                    initial_summary.append(f"{line}\n")
62
+                if len(lines) > 20:
63
+                    initial_summary.append(
64
+                        f"  ... ({len(lines) - 20} more lines)\n", style="dim"
65
+                    )
66
+        yield Static(initial_summary, id="tool-summary", classes="tool-summary")
5167
 
5268
         # Toggle button for expand/collapse (hidden by default until result has more lines)
5369
         toggle = Button("▶ Show full output", id="tool-toggle", classes="tool-toggle", variant="default")