Skip to content

fix: 追问时不再先闪出上一轮的推荐问题 [skip eval] - #434

Merged
HyxiaoGe merged 1 commit into
masterfrom
fix/suggested-questions-stale-previous-turn
Oct 13, 2026
Merged

HyxiaoGe merged 1 commit into
masterfrom
fix/suggested-questions-stale-previous-turn

Conversation

@HyxiaoGe

Copy link
Copy Markdown
Owner

现象

多轮对话中,回答结束时推荐区会先显示一组问题,闪一下后换成另一组。

根因

  • 后端每条消息只生成一次推荐(dev 最近 3 天的回答 revision 均为 1,pending/ready 事件一一对应),不存在重复生成。
  • 推荐区挂在哪条消息下,由 ChatMessageList.lastAssistantIndex 决定:取最后一条 assistant,不看是否有正文。
  • 推荐数据来自 useSuggestedQuestions.getLastAssistantMessage:只取 content.length > 0 的 assistant。
  • 流式期间,本轮正文存放在 streamSlice,消息本身的 content 为 [],要等 done 时由 doCompleteStream 写入。因此数据源退回到上一轮回答。suggested_questions_pending 到达后,推荐区([skip eval] fix: 推荐问题在流结束前收到 ready 时不再隐藏 #389 起流结束前即显示)先展示上一轮的推荐;封口写入正文后,数据源切回本轮,换成本轮推荐,表现为闪一下。
  • 首轮对话没有上一轮回答,所以不会出现。

改动

getLastAssistantMessage 与 lastAssistantIndex 改为同源:最后一条消息是 assistant 时取它,不再按正文过滤。本轮推荐未到时显示占位,到达后直接展示。

验证

  • 新增用例:上一轮推荐为 ready、本轮消息 content 为空并处于流式中时,推荐为空;pending 时显示 loading;ready 后显示本轮推荐,且不拉取会话详情。撤掉修复后该用例失败,收到的正是「上一轮推荐」。
  • vitest related:2 个文件 126 个用例通过;eslint 通过;tsc 与基线相比无新增错误。
  • 合并后在 dev 的多轮对话中确认不再闪出上一轮推荐。

🤖 Generated with Claude Code

推荐区挂在最后一条 assistant 上(ChatMessageList.lastAssistantIndex),
但数据源 getLastAssistantMessage 只取有正文的 assistant。流式期间本轮正文
在 streamSlice、消息 content 为空,于是退回上一轮,把上一轮推荐挂到本轮
下面;封口写入正文后再换成本轮推荐,表现为闪一下换一批。两处改为同源。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HyxiaoGe
HyxiaoGe merged commit bd56747 into master Oct 13, 2026
5 checks passed
@HyxiaoGe
HyxiaoGe deleted the fix/suggested-questions-stale-previous-turn branch October 13, 2026 14:43
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.

1 participant