tenseleyflow/loader / 19f8bdf

Browse files

fix: show DiffWidget for edits even when old_string is empty

- Changed condition from 'old_string and new_string' to 'old_string is not None'
- This handles edits where old_string='' (inserting new content)
- Added debug logging with character counts
Authored by espadonne
SHA
19f8bdf4c75b168bf72bfde28301da671a277da9
Parents
5946d38
Tree
8ca69c9

1 changed file

StatusFile+-
M src/loader/ui/app.py 4 3
src/loader/ui/app.pymodified
@@ -322,9 +322,10 @@ class LoaderApp(App):
322322
         tool_widget = self._tool_widget_queue.pop(0) if self._tool_widget_queue else None
323323
 
324324
         # Check if this is an edit tool with diff info
325
-        if message.tool_name == "edit" and message.old_string and message.new_string:
325
+        # Note: old_string can be empty string (inserting), so check `is not None`
326
+        if message.tool_name == "edit" and message.new_string and message.old_string is not None:
326327
             # Replace tool widget with diff widget
327
-            self._debug_log("  -> showing EDIT diff widget")
328
+            self._debug_log(f"  -> showing EDIT diff widget (old={len(message.old_string)} chars, new={len(message.new_string)} chars)")
328329
             if tool_widget:
329330
                 tool_widget.remove()
330331
 
@@ -336,7 +337,7 @@ class LoaderApp(App):
336337
             msg_area.mount(diff_widget)
337338
         # Check if this is a write tool - show as diff (new file)
338339
         elif message.tool_name == "write" and message.new_string:
339
-            self._debug_log("  -> showing WRITE diff widget")
340
+            self._debug_log(f"  -> showing WRITE diff widget ({len(message.new_string)} chars)")
340341
             if tool_widget:
341342
                 tool_widget.remove()
342343