fix(desktop): 修复间歇性重复渲染 assistant 回复的问题 - #70173
Closed
x7peeps wants to merge 1 commit into
Closed
Conversation
…plicate bubbles When message.interim seals an assistant bubble and message.complete arrives with the same (or a superset of) text, the live UI must collapse them into one bubble — the DB persists only one row, so rendering two is a duplicate. Previously, the dedup path required response_previewed=true to settle onto the interim. Without that flag, the fallback created a second assistant message even when the texts matched, causing intermittent duplicate rendering. Fix: broaden the interimBoundaryPending guard to cover the common case where the final text matches or extends the interim text, regardless of the response_previewed flag. Fix NousResearch#70108
Contributor
|
Thanks for the focused reproduction and regression coverage. Automated hermes-sweeper review found that current
Closing as implemented on main. |
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
修复 #70108: Desktop 间歇性地将同一个 assistant 回复渲染为两个独立的消息气泡。
根因分析
当 gateway 发送
message.interim将正在流式传输的 assistant 气泡密封(sealed)后,紧接着的message.complete在落地时会尝试找到已有的 assistant 消息进行合并。原有的去重逻辑要求
response_previewed=true才能将最终回复合并到已密封的 interim 气泡上。当 gateway 未设置response_previewed标志时(这是常见情况),即使最终回复文本与 interim 文本完全相同或是其前缀扩展,代码也会创建一个新的 assistant 消息气泡,导致同一回复在界面上出现两次。数据库只持久化了一行 assistant 消息,所以重新加载(rehydration)后重复气泡消失——这证实了问题出在实时渲染路径上。
修复方式
在
use-message-stream/index.ts的completeAssistantMessage中:response_previewed的前置要求:当interimBoundaryPending=true时,只要最终文本与已密封的 interim 文本相同或是其前缀扩展(finalText.startsWith(existingText)),就将最终回复合并到现有的 interim 气泡上。response_previewed的场景(continuation-budget 回退路径,fix(desktop, ink): don't wipe messages before final message #65919)response_previewed但最终文本与 interim 相同或扩展了 interim 的常见场景测试变更
interim-sealing.test.tsx中的同名文本测试:期望 1 个气泡(原期望 2 个)settles a prefix-matched final onto the interim even without response_previewed测试用例验证
Closes #70108