首页 round_start 记录 id 实时绑定 + 用户消息重生成修复

- wsMessage 新增 RoundStart 事件与 getRecordId 解析(兼容数字/字符串)
- 普通对话:round_start 首帧把 recordId 绑定到本轮用户消息与 AI 气泡,实时即可删除/重生成
- 工作流:round_start 把 recordId 绑定到表单卡片与结果消息(共享同一记录)
- 修复用户消息重新生成时气泡消失(runChat 不补用户消息,重生成时先重新追加)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-08-18 18:04:21 +08:00
co-authored by Claude
parent c962cdd830
commit 0421adb6ac
3 changed files with 59 additions and 9 deletions
+8
View File
@@ -27,6 +27,7 @@ export const WsEventType = {
ToolResult: 'tool_result', // 工具返回结果
Answer: 'answer', // 最终回答
AnswerChunk: 'answer_chunk', // 回答内容增量(逐 chunk
RoundStart: 'round_start', // 本轮问答开始(后端收到提问后第一帧,data.recordId 为本次问答记录 id
ReasoningChunk: 'reasoning_chunk', // 思考内容增量(逐 chunk
NodeStart: 'node_start', // 工作流节点开始(进度推进)
NodeComplete: 'node_complete', // 工作流节点完成(进度推进)
@@ -61,6 +62,13 @@ export function getAnswer(msg: WsStreamMessage): string {
return typeof msg?.data?.answer === 'string' ? msg.data.answer : '';
}
/** round_start → data.recordId 本次问答记录 id(19 位雪花大整数,契约要求字符串形式,兼容数字类型防御性转 string) */
export function getRecordId(msg: WsStreamMessage): string {
const rid = msg?.data?.recordId;
if (typeof rid === 'string' || typeof rid === 'number') return String(rid);
return '';
}
/** model_call → { step, maxStep },缺失时 maxStep 为 0 */
export function getStepInfo(msg: WsStreamMessage): { step: number; maxStep: number } | null {
const step = msg?.data?.step;