tenseleyflow/loader / 96d92d0

Browse files

Match tool widgets by name instead of FIFO to prevent result/widget swaps

Authored by espadonne
SHA
96d92d0f89850cdcf747fedc1996e3d8f7b4d3c0
Parents
1c7aa50
Tree
2698e58

1 changed file

StatusFile+-
M src/loader/ui/app.py 13 1
src/loader/ui/app.pymodified
@@ -657,7 +657,19 @@ class LoaderApp(App):
657657
             pass
658658
 
659659
         # Get the corresponding tool widget from queue (FIFO)
660
-        tool_widget = self._tool_widget_queue.pop(0) if self._tool_widget_queue else None
660
+        # Match widget by tool name instead of blind FIFO to prevent
661
+        # result/widget mismatches when events arrive out of order
662
+        tool_widget = None
663
+        if self._tool_widget_queue:
664
+            for i, w in enumerate(self._tool_widget_queue):
665
+                # Match on tool name (strip "verify " prefix for verification phase)
666
+                widget_name = w.tool_name.removeprefix("verify ")
667
+                if widget_name == message.tool_name:
668
+                    tool_widget = self._tool_widget_queue.pop(i)
669
+                    break
670
+            else:
671
+                # No name match — fall back to FIFO
672
+                tool_widget = self._tool_widget_queue.pop(0)
661673
 
662674
         # Check if this is an edit tool with diff info
663675
         # Note: old_string can be empty string (inserting), so check `is not None`