Commit 70e7290
Yogthos
fix(ui): track last_tool_call_id; paint fresh chamber on parallel-result mismatch
Closes dirge-jzj.
The UI's chamber state model was single-slot (one `tool_chamber_open:
bool` + one `last_tool_name: Option<String>`). Under parallel tool
execution — the default per `agent_loop/types.rs:402` since this
matches pi — the `execute_tool_calls_parallel` loop fires
`ToolExecutionStart` for ALL tool calls in a turn back-to-back before
any `ToolExecutionEnd`. Each new ToolCall passively closes the
prior chamber via the close at line 2137. ToolResults arrive in
completion order, which often differs from call order.
Symptoms before this fix (after 7403792's passive-close change):
- `╭─ READ ─ "/foo" ─╮ ╰────╯` empty chamber for the displaced call
- `↳ first_line` trailer painted below an unrelated chamber when the
displaced call's result finally arrives
- Pre-7403792 the same race produced false "⚠ tool denied · aborted ·
no result" wording instead of empty chambers; same root cause, just
a different visible symptom.
Fix: track `last_tool_call_id: Option<String>` alongside the existing
`last_tool_name`. Set at ToolCall, cleared at ToolResult end and
chamber-close-during-result paths. At ToolResult, if the result's id
doesn't match `last_tool_call_id`, the chamber on screen belongs to
a sibling call — paint a fresh complete chamber for THIS id below
the current scroll position (close current passive, look up
name+args from `tool_calls_buf`, paint TOP, set chamber_open=true).
The existing render paths (a/b/c) then handle the body for the
newly-opened chamber.
Each parallel ToolResult lands in its own correctly-labeled frame,
rendered in completion order. The display can appear out of source
order when tools finish at different speeds — that's accurate to
what happened.
Trade-off: deny flow with parallel calls + alert response now paints
a fresh chamber containing the deny error text below the existing
`↳ denied: tool args` trailer line. Slightly redundant but
informative. Threading call_id through the ask flow would let us
suppress the redundancy; deferred to a follow-up since the
parallel-deny intersection is rare.
The id-matches case (sequential / single-tool-per-turn, which is
the common path) falls through to existing path (a) unchanged.
Tests: existing 192 ui:: tests still pass. The multi-chamber
behavior is event-stream-sequenced and not easily covered by the
current unit-test harness (which tests chamber close helpers in
isolation, not full event loops); integration test is a follow-up.1 parent 2124feb commit 70e7290
2 files changed
Lines changed: 80 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
689 | 689 | | |
690 | 690 | | |
691 | 691 | | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
692 | 714 | | |
693 | 715 | | |
694 | 716 | | |
| |||
2136 | 2158 | | |
2137 | 2159 | | |
2138 | 2160 | | |
| 2161 | + | |
2139 | 2162 | | |
2140 | 2163 | | |
2141 | 2164 | | |
| |||
2201 | 2224 | | |
2202 | 2225 | | |
2203 | 2226 | | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
2204 | 2282 | | |
2205 | 2283 | | |
2206 | 2284 | | |
| |||
2410 | 2488 | | |
2411 | 2489 | | |
2412 | 2490 | | |
| 2491 | + | |
2413 | 2492 | | |
2414 | 2493 | | |
2415 | 2494 | | |
| |||
0 commit comments