Commit cdd438b
authored
🤖 fix: show nested tool calls during code_execution streaming (#1366)
## Problem
When using `code_execution` (PTC), nested tool calls (e.g.,
`mux.bash()`, `mux.file_read()`) didn't appear in the UI until they
completed. Users expected to see "executing..." while long-running
nested tools were in progress, just like regular top-level tool calls.
## Root Cause
Two issues combined:
### 1. MessageId Mismatch
The backend was emitting nested tool events with the wrong `messageId`:
- `aiService.ts` created `assistantMessageId` for history and the
`emitNestedEvent` callback
- `streamManager.ts` created a **separate** `messageId` for all stream
events
- Frontend aggregator looked up messages by `messageId` - nested events
with `assistantMessageId` couldn't find the message stored under
`streamInfo.messageId`
- Events were silently dropped
### 2. React Reactivity
Even after fixing the messageId, the UI didn't update when nested tools
completed:
- `handleToolCallEnd` mutated `nestedCall` objects in place
- React didn't detect changes because object references stayed the same
- Fix: use immutable update pattern (create new array + new objects)
## Solution
1. **Thread messageId through**: Pass `assistantMessageId` from
`aiService.ts` to `streamManager.startStream()` so both use the same ID
2. **Immutable updates**: Replace in-place mutation with immutable
update pattern in `handleToolCallEnd`
## Testing
- All existing tests pass
- Manual testing confirms nested tools now show "executing..." and
update to completed state in real-time
---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking:
`high`_1 parent 1c10fa2 commit cdd438b
File tree
4 files changed
+22
-7
lines changed- src
- browser/utils/messages
- node/services
4 files changed
+22
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1269 | 1269 | | |
1270 | 1270 | | |
1271 | 1271 | | |
1272 | | - | |
| 1272 | + | |
1273 | 1273 | | |
1274 | 1274 | | |
1275 | 1275 | | |
| 1276 | + | |
1276 | 1277 | | |
1277 | | - | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1281 | 1289 | | |
1282 | 1290 | | |
1283 | 1291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1735 | 1735 | | |
1736 | 1736 | | |
1737 | 1737 | | |
| 1738 | + | |
1738 | 1739 | | |
1739 | 1740 | | |
1740 | 1741 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
280 | 282 | | |
281 | 283 | | |
282 | 284 | | |
| 285 | + | |
283 | 286 | | |
284 | 287 | | |
285 | 288 | | |
| |||
291 | 294 | | |
292 | 295 | | |
293 | 296 | | |
| 297 | + | |
294 | 298 | | |
295 | 299 | | |
296 | 300 | | |
| |||
302 | 306 | | |
303 | 307 | | |
304 | 308 | | |
| 309 | + | |
305 | 310 | | |
306 | 311 | | |
307 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
| 623 | + | |
623 | 624 | | |
624 | 625 | | |
625 | 626 | | |
| |||
720 | 721 | | |
721 | 722 | | |
722 | 723 | | |
723 | | - | |
724 | | - | |
725 | 724 | | |
726 | 725 | | |
727 | 726 | | |
| |||
1512 | 1511 | | |
1513 | 1512 | | |
1514 | 1513 | | |
| 1514 | + | |
1515 | 1515 | | |
1516 | 1516 | | |
1517 | 1517 | | |
| |||
1568 | 1568 | | |
1569 | 1569 | | |
1570 | 1570 | | |
| 1571 | + | |
1571 | 1572 | | |
1572 | 1573 | | |
1573 | 1574 | | |
| |||
0 commit comments