tenseleyflow/loader / 833086d

Browse files

fix: smarter tool_call/result queue matching for diff views

Instead of strict FIFO, now matches tool_result to tool_call by
name. Falls back to FIFO if no match found. This handles cases
where events might arrive out of order and ensures write/edit
tools get their arguments for diff display.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
833086dce9e832e88abc9bfe2530da5d78a8fdbf
Parents
9e0e422
Tree
d4c2d91

1 changed file

StatusFile+-
M src/loader/ui/adapter.py 11 1
src/loader/ui/adapter.pymodified
@@ -213,8 +213,18 @@ class EventAdapter:
213213
                 # Get matching args from queue (FIFO)
214214
                 tool_name = event.tool_name or ""
215215
                 tool_args = {}
216
+
217
+                # Find matching tool_call in queue (should be FIFO but handle mismatch)
216218
                 if self._tool_args_queue:
217
-                    _, tool_args = self._tool_args_queue.pop(0)
219
+                    # Try to find matching tool by name, fallback to FIFO
220
+                    for i, (queued_name, queued_args) in enumerate(self._tool_args_queue):
221
+                        if queued_name == tool_name:
222
+                            tool_args = queued_args
223
+                            self._tool_args_queue.pop(i)
224
+                            break
225
+                    else:
226
+                        # No match found, use FIFO
227
+                        _, tool_args = self._tool_args_queue.pop(0)
218228
 
219229
                 # Extract diff info for edit/write tools
220230
                 old_string = None