From d89639dbb3f5d3c7a1b87e5f4459a17110c83ecb Mon Sep 17 00:00:00 2001 From: Nathan Esquenazi Date: Mon, 6 Apr 2026 14:10:33 -0700 Subject: [PATCH] fix: tool call cards persist across page reload (#140) (#149) Tool cards disappeared on page refresh because assistant messages with only tool_use content (no text) were filtered out of the visible messages list. Since tool cards anchor to DOM rows via data-msg-idx, removing the anchor row meant cards had nothing to attach to. Fix: keep assistant messages in the render list if they contain tool_use blocks, even when they have no text content. The row renders with the role label but empty body, providing an anchor point for the tool card insertion pass. Fixes #140 Co-authored-by: Claude Opus 4.6 (1M context) --- static/ui.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/static/ui.js b/static/ui.js index 7eec8df..d10f756 100644 --- a/static/ui.js +++ b/static/ui.js @@ -465,6 +465,9 @@ function renderMessages(){ const inner=$('msgInner'); const vis=S.messages.filter(m=>{ if(!m||!m.role||m.role==='tool')return false; + // Keep assistant messages with tool_use content even if they have no text, + // so tool cards can be anchored to their DOM rows on page reload (#140). + if(m.role==='assistant'&&Array.isArray(m.content)&&m.content.some(p=>p&&p.type==='tool_use'))return true; return msgContent(m)||m.attachments?.length; }); $('emptyState').style.display=vis.length?'none':'';