chore:更新 AI 服务会话管理逻辑,优化用户状态切换时的 key 迁移与会话隔离,确保 H5 端 elicitResponse 请求正常处理
This commit is contained in:
@@ -1668,24 +1668,34 @@ async submitQuestionAnswer(msg) {
|
||||
uni.showToast({ title: 'rpc_id 缺失, 无法回传', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.$set(msg, 'questionAnswered', true)
|
||||
// PR-FA-PRE (2026-09-18): 仅在 elicitResponse 真返回 true 时才置 questionAnswered=true
|
||||
// 老逻辑先置 true 再 await,后端返回 false (H5 后端未就绪) 时也已被 UI 标记为已答,
|
||||
// 用户看不到正确答案的继续流 → 体感"假性中断"。修:成功后才标记;失败提示并保留未答状态
|
||||
// 由 30s pending_stale 兜底超时。
|
||||
this.$set(msg, 'questionTimedOut', false)
|
||||
if (msg.id && this.questionTimers[msg.id]) {
|
||||
clearInterval(this.questionTimers[msg.id])
|
||||
this.$delete(this.questionTimers, msg.id)
|
||||
}
|
||||
let ok = false
|
||||
try {
|
||||
await aiService.elicitResponse({
|
||||
ok = await aiService.elicitResponse({
|
||||
conversation_id: msg.questionConversationId || aiService.getConversationId(),
|
||||
message_id: msg.questionMessageId,
|
||||
tool_call_id: msg.pendingQuestion && msg.pendingQuestion.tool_call_id,
|
||||
rpc_id: msg.rpc_id,
|
||||
answers: msg.selectedAnswers
|
||||
})
|
||||
// 后端会接着上次的 tool_call 上下文继续流, 无需前端额外处理
|
||||
} catch (e) {
|
||||
ok = false
|
||||
uni.showToast({ title: '选项提交失败: ' + (e.message || ''), icon: 'none' })
|
||||
this.$set(msg, 'questionAnswered', false)
|
||||
}
|
||||
if (ok) {
|
||||
this.$set(msg, 'questionAnswered', true)
|
||||
// 后端会接着上次的 tool_call 上下文继续流, 无需前端额外处理
|
||||
} else {
|
||||
// H5 后端暂未就绪 或 网络失败:保留 questionAnswered=false,30s 由 pending_stale 兜底
|
||||
uni.showToast({ title: '选项已展示,等待后端确认…', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user