* fix: tool call cards persist correctly after page reload Root cause: the insertion logic looked for the NEXT assistant row to insert BEFORE, but when the triggering assistant message contained only tool_use blocks (no text), it was filtered from the DOM by msgContent() and no anchor row existed. Cards were silently dropped. Fix: find the row AT the assistant_msg_idx first (exact match), fall back to the nearest preceding visible row, then insert AFTER it (not before the next). This handles both text+tool and tool-only assistant messages correctly. Closes #140 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: tool card ordering — role-filter fallback anchor, preserve order for same-anchor groups Two bugs in the initial PR: - Fallback 'nearest row' had no role filter, could anchor to a user message row causing cards to appear after a user bubble. Fixed: check role==='assistant' in the fallback loop. - Back-to-back tool-card groups sharing a filtered anchor were inserted in reverse order because each group re-read anchorRow.nextSibling from the live DOM. Fixed: track the last inserted node per anchor via anchorInsertAfter Map, so each subsequent group appends after the previous one. Also restores the 'Collect card elements before they get moved to DOM' comment explaining why Array.from() is used on frag before DOM insertion. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
48 KiB
48 KiB