fix: remove assistant event handler to prevent duplicate messages
This commit is contained in:
parent
44a8ddf458
commit
de8a7798c3
1 changed files with 3 additions and 14 deletions
|
|
@ -171,20 +171,9 @@ const App = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Claude stream-json events
|
// Claude stream-json events
|
||||||
if (type === 'assistant') {
|
// NOTE: We intentionally skip the 'assistant' event type.
|
||||||
// Full assistant message (not streaming)
|
// It contains the full message text that was ALREADY streamed via
|
||||||
const content = data.message?.content;
|
// content_block_delta events, so handling it would create a duplicate bubble.
|
||||||
let text = '';
|
|
||||||
if (Array.isArray(content)) {
|
|
||||||
text = content.filter(b => b.type === 'text').map(b => b.text).join('');
|
|
||||||
} else if (typeof content === 'string') {
|
|
||||||
text = content;
|
|
||||||
}
|
|
||||||
if (text) {
|
|
||||||
pendingAssistantRef.current += text;
|
|
||||||
upsertStreamingMessage(pendingAssistantRef.current, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'content_block_delta') {
|
if (type === 'content_block_delta') {
|
||||||
const delta = data.delta;
|
const delta = data.delta;
|
||||||
|
|
|
||||||
Reference in a new issue