From 1de99654fc50891dd36f89b78e461dd48184c47a Mon Sep 17 00:00:00 2001 From: Zac Gaetano Date: Sun, 5 Apr 2026 12:09:39 -0400 Subject: [PATCH] fix: dynamic col names + no-duplicate assistant/result event handling --- frontend/src/App.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index d8c0bdb..47c938d 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -41,6 +41,7 @@ const App = () => { const [wsConnected, setWsConnected] = useState(false); const [wsError, setWsError] = useState(null); const pendingAssistantRef = useRef(''); + const messageFinalizedRef = useRef(false); // true when assistant event already finalized the bubble const reconnectTimerRef = useRef(null); // Tasks state @@ -201,25 +202,32 @@ const App = () => { } if (text) { pendingAssistantRef.current = text; + messageFinalizedRef.current = true; // already final, don't re-render on result upsertStreamingMessage(text, false); } + } else { + // Deltas already built the text — mark as final so result doesn't duplicate + messageFinalizedRef.current = true; } - // If deltas already built the text, skip — no duplicate } if (type === 'result') { const sub = data.subtype; if (sub === 'success' || sub === 'error_max_turns') { - if (pendingAssistantRef.current) { + // Only call upsertStreamingMessage if the message is still streaming (from deltas) + // If messageFinalizedRef is true, the bubble is already rendered as final + if (pendingAssistantRef.current && !messageFinalizedRef.current) { upsertStreamingMessage(pendingAssistantRef.current, false); - pendingAssistantRef.current = ''; } + pendingAssistantRef.current = ''; + messageFinalizedRef.current = false; if (data.session_id) setClaudeSessionId(data.session_id); setChatWaiting(false); fetchChatSessions(); } if (sub === 'error' || sub === 'error_during_execution') { pendingAssistantRef.current = ''; + messageFinalizedRef.current = false; setChatWaiting(false); appendErrorMsg(data.error || 'Claude returned an error'); } @@ -271,6 +279,7 @@ const App = () => { setChatInput(''); setChatWaiting(true); pendingAssistantRef.current = ''; + messageFinalizedRef.current = false; if (!wsRef.current || wsRef.current.readyState !== 1) { appendErrorMsg('Not connected — reconnecting...');