feat(ai): 等待气泡展示后台处理进度

- AI 聊天用工具/子代理/推理帧推断等待阶段,提示已完成步数,子代理输出不再并入主回答
- 下单弹层去掉 01-04 编号分组标题
- 同步首页设计规范与 UI 测试断言,补充首页品牌图
This commit is contained in:
lik
2026-11-18 22:31:58 +08:00
parent 3711da2496
commit 76197b838f
9 changed files with 93 additions and 69 deletions
+51
View File
@@ -42,6 +42,9 @@ Page({
// 「更多」菜单:常见问题与清空聊天收进同一个低频入口
showMoreMenu: false,
isTyping: false,
// 等待气泡的第二行:用已有的工具/子代理帧推断后台在做什么
progressLabel: '',
progressStep: 0,
// 登录态:先判完再渲染提示条,避免静默登录成功前闪一下「未登录」
authChecked: false,
isLoggedIn: false,
@@ -83,6 +86,8 @@ Page({
// 本轮请求现场与「已为重登重试过」的请求 id:服务端回「请先登录」时原样重发
this.activePayload = null
this.authRetriedRequestId = ''
// 本轮已计入步骤的帧 id:流式分片会复用同一 id,不能重复计数
this.progressStepIds = new Set()
this.loadChatHistory()
this.initSocketListeners()
this.initRecorder()
@@ -258,8 +263,12 @@ Page({
break
case 'connected':
case 'pong':
break
case 'reasoning':
this.noteProgress('reasoning', data)
break
case 'tool':
this.noteProgress('tool', data)
break
default:
console.warn('[AIChat] Unknown message type:', data.type)
@@ -274,6 +283,13 @@ Page({
handleAIReply(data) {
if (!this.activeRequestId) return
// 子代理(非主 agent)的输出不并入回答,只用来更新等待气泡的进度;
// 主 agent 没有子代理时这段不会触发,行为保持不变
if ((data.source || 'main') !== 'main') {
this.noteProgress('subagent', data)
return
}
const serverId = data.id || this.activeRequestId
const messages = this.data.messages.slice()
const lastMessage = messages[messages.length - 1]
@@ -336,6 +352,8 @@ Page({
this.activeRequestType = ''
// 请求已结束,不再保留提问现场(图片原文可能很大)
this.activePayload = null
this.progressStepIds = new Set()
this.setData({ progressLabel: '', progressStep: 0 })
},
beginRequest(requestId, userMessageId = '', type = 'chat') {
@@ -343,6 +361,39 @@ Page({
this.activeUserMessageId = userMessageId
this.activeServerId = ''
this.activeRequestType = type
this.resetProgress(type)
},
// 等待态进度:后端没有独立的进度帧,用已有的 tool / subagent / reasoning 帧
// 推断当前阶段;图片/语音识别有自己的文案,不在这里抢提示
resetProgress(type = 'chat') {
this.progressStepIds = new Set()
this.setData({
progressLabel: type === 'chat' ? '正在理解您的问题' : '',
progressStep: 0
})
},
noteProgress(kind, data) {
if (!this.activeRequestId) return
const labels = {
reasoning: '正在分析…',
tool: '正在查询资料…',
subagent: '正在处理子任务…'
}
const label = labels[kind]
if (!label) return
// 工具结果与子代理消息都按 id 计一步,主代理自己调工具也算
let step = this.data.progressStep
const id = data && data.id
if (id && (kind === 'tool' || kind === 'subagent') && !this.progressStepIds.has(id)) {
this.progressStepIds.add(id)
step += 1
}
if (label === this.data.progressLabel && step === this.data.progressStep) return
this.setData({ progressLabel: label, progressStep: step })
},
createMessageId(prefix = 'msg') {