* fix: correct tool call card rendering on session load Two bugs caused duplicate/incorrect tool call cards when loading sessions (especially after context compaction): 1. loadSession() sanitized messages (B9 filter) but did NOT update the session-level tool_calls array's assistant_msg_idx references. Since compact() returns only sanitized messages and recomputes tool_calls with indices into the compacted array, the original assistant_msg_idx values became stale/misaligned. 2. loadSession() then assigned the broken session-level tool_calls directly to S.toolCalls. This prevented renderMessages()'s fallback path (which derives tool_calls from per-message tool_calls using correct sanitized-array indices) from ever running. Fix: - Keep full sanitization loop with index remapping for session-level tool_calls (in case they're needed by other code paths). - Instead of assigning broken session-level tool_calls to S.toolCalls, set S.toolCalls=[] so renderMessages() uses the fallback derivation from per-message tool_calls, which already have correct indices. * test: add 8 regression tests for issue #401 tool call index remapping * docs: v0.50.29 release — version badge and CHANGELOG --------- Co-authored-by: Frank Song <franksong2702@gmail.com> Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
10 KiB
10 KiB