Skip to content

🐛 fix: prevent first assistant message re-animation on assistantGroup transition#13320

Merged
arvinxx merged 2 commits into
canaryfrom
fix/assistant-group-streaming-re-render
Mar 26, 2026
Merged

🐛 fix: prevent first assistant message re-animation on assistantGroup transition#13320
arvinxx merged 2 commits into
canaryfrom
fix/assistant-group-streaming-re-render

Conversation

@arvinxx

@arvinxx arvinxx commented Mar 26, 2026

Copy link
Copy Markdown
Member

Summary

  • 修复流式输出中 assistant 转 assistantGroup 时,第一条 assistant 消息文本内容重新执行 fade-in 动画的问题
  • 通过 GroupGroupItemContentBlockMessageContent 传递 isFirstBlock 属性,确保 group 中第一个 content block 不执行流式动画
  • 后续 assistant 消息仍保持正常流式动画行为

根因分析

当 tool call 到达时,消息从 role: 'assistant' 转换为 role: 'assistantGroup',导致 React 组件完全卸载/重新挂载。此时 isGenerating 仍为 true(tool 执行中),使得已显示完成的文本内容重新执行 fade-in 动画。

Fixes LOBE-6414

Test plan

  • 发送一条会触发 tool call 的消息,观察 assistant 文本内容在 tool call 到达时是否不再闪烁
  • 验证多轮 tool call(assistant → tool → assistant → tool)中,后续 assistant 消息仍正常流式动画
  • 验证无 tool call 的纯文本回复流式动画不受影响

🤖 Generated with Claude Code

… transition

When tool calls arrive during streaming, the message transitions from
assistant to assistantGroup, causing a full React remount. The first
content block's text was re-animating because isGenerating was still
true. Pass isFirstBlock prop through the render chain to disable
animation for the first block, since its text is guaranteed complete
by the time the group forms.

Fixes LOBE-6414

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Canceled Canceled Mar 26, 2026 5:30pm

Request Review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

isFirstBlock already covers the first block case, and subsequent blocks
should not have animation disabled just because they are single-line
with tools — they may still be streaming.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lobehubbot

Copy link
Copy Markdown
Member

@ONLY-yours - This is a streaming animation bug fix in the AssistantGroup conversation messages. Please take a look.

@codecov

codecov Bot commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.76%. Comparing base (926de07) to head (f4efeb9).
⚠️ Report is 5 commits behind head on canary.

Additional details and impacted files
@@            Coverage Diff            @@
##           canary   #13320     +/-   ##
=========================================
  Coverage   66.76%   66.76%             
=========================================
  Files        1889     1888      -1     
  Lines      151446   151436     -10     
  Branches    14506    17264   +2758     
=========================================
- Hits       101112   101111      -1     
+ Misses      50222    50213      -9     
  Partials      112      112             
Flag Coverage Δ
app 58.20% <ø> (+<0.01%) ⬆️
database 96.64% <ø> (ø)
packages/agent-runtime 89.61% <ø> (ø)
packages/context-engine 83.22% <ø> (ø)
packages/conversation-flow 92.36% <ø> (ø)
packages/file-loaders 87.02% <ø> (ø)
packages/memory-user-memory 66.68% <ø> (ø)
packages/model-bank 99.85% <ø> (ø)
packages/model-runtime 84.48% <ø> (ø)
packages/prompts 67.76% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 90.41% <ø> (ø)
packages/web-crawler 88.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 66.07% <ø> (ø)
Services 49.56% <ø> (ø)
Server 67.37% <ø> (+0.01%) ⬆️
Libs 51.06% <ø> (ø)
Utils 91.01% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arvinxx arvinxx merged commit 9e9ba3e into canary Mar 26, 2026
34 checks passed
@arvinxx arvinxx deleted the fix/assistant-group-streaming-re-render branch March 26, 2026 17:41
@lobehubbot

Copy link
Copy Markdown
Member

❤️ Great PR @arvinxx ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants