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') {
+15 -5
View File
@@ -133,12 +133,22 @@
</view>
<view class="message-content">
<view class="message-bubble typing-bubble">
<view class="typing-indicator">
<view class="dot"></view>
<view class="dot"></view>
<view class="dot"></view>
<view class="typing-lines">
<view class="typing-main">
<text class="typing-text">{{isRecognizing ? '正在识别,请稍候' : '正在为您整理'}}</text>
<!-- 动态点跟在文字后面,作为文字的省略号 -->
<view class="typing-indicator">
<view class="dot"></view>
<view class="dot"></view>
<view class="dot"></view>
</view>
</view>
<!-- 后台进度:工具/子代理有动作时这行会变化,避免只剩一个等待动画 -->
<text
class="typing-progress"
wx:if="{{!isRecognizing && progressLabel}}"
>{{progressLabel}}{{progressStep ? ' · 已完成 ' + progressStep + ' 步' : ''}}</text>
</view>
<text class="typing-text">{{isRecognizing ? '正在识别,请稍候' : '正在为您整理'}}</text>
</view>
</view>
</view>
+4 -1
View File
@@ -75,11 +75,14 @@
.system-message { max-width: 100%; padding: 8rpx 16rpx; color: var(--muted); font-size: var(--fs-26); line-height: 1.7; text-align: center; }
.system-login-link { display: inline-block; padding: 16rpx; color: var(--brand-ink); font-size: var(--fs-28); }
.message-item.ai .typing-bubble { display: flex; align-items: center; gap: 20rpx; width: auto; min-height: 88rpx; }
.typing-indicator { display: flex; align-items: center; gap: 8rpx; }
.typing-main { display: flex; align-items: center; gap: 12rpx; }
.typing-indicator { display: flex; align-items: center; gap: 8rpx; flex-shrink: 0; }
.typing-lines { display: flex; flex-direction: column; gap: 2rpx; }
.dot { width: 10rpx; height: 10rpx; border-radius: 50%; background: var(--brand-ink); animation: typing 1.4s infinite ease-in-out both; }
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
.typing-text { font-size: var(--fs-26); color: var(--muted); line-height: 1.6; }
.typing-progress { font-size: 22rpx; color: var(--muted); line-height: 1.5; opacity: 0.85; }
/* 统一白色输入面板,语音/图片/更多在左,发送在右,所有操作横向展开。
position: relative 供「更多」菜单定位(菜单从按钮上方展开) */