feat(aihr): harden M0-M2 mobile training flows

This commit is contained in:
2026-07-23 21:18:13 +08:00
parent 06322c994b
commit 927458b9e0
44 changed files with 1674 additions and 119 deletions
+20 -3
View File
@@ -628,6 +628,17 @@ const clearBroadcastConsultation = () => {
clearBroadcastQuestionContext();
};
// A message consultation is re-authorized on every show. When the page is
// hidden while that request (or its confirmation dialog) is still pending,
// invalidate only the in-flight work. Keep the account-bound pending message
// ID so the next onShow can restart the authorization instead of leaving the
// composer locked in a stale loading state.
const cancelPendingBroadcastConsultation = () => {
broadcastContextGeneration += 1;
broadcastContextLoading.value = false;
broadcastContextPrompting.value = false;
};
const preserveCurrentBroadcastConsultation = () => {
if (!broadcastContext.value) return;
saveBroadcastQuestionContext(broadcastContext.value.messageId, currentAccountKey());
@@ -693,12 +704,15 @@ const restoreBroadcastConsultation = async (pageGeneration: number, accountKey:
return;
}
const start = () => void activateBroadcastConsultation(pending, accountKey, pageGeneration);
if (!conversationStarted.value) {
start();
// Do not start project selection until the message context has been
// resolved. Otherwise the asynchronous handoff can briefly look like an
// ordinary empty conversation and incorrectly open the project picker.
await activateBroadcastConsultation(pending, accountKey, pageGeneration);
return;
}
const start = () => void activateBroadcastConsultation(pending, accountKey, pageGeneration);
broadcastContextPrompting.value = true;
uni.showModal({
title: '开始新的消息咨询?',
@@ -847,7 +861,8 @@ const loadProjectContext = async () => {
const identity = await fetchMobileIdentity();
availableProjects.value = identity.projects || [];
currentProject.value = reconcileCurrentProject(availableProjects.value);
if (!currentProject.value && availableProjects.value.length > 1 && !broadcastContext.value && !broadcastContextPrompting.value) {
if (!currentProject.value && availableProjects.value.length > 1
&& !broadcastContext.value && !broadcastContextLoading.value && !broadcastContextPrompting.value) {
projectPickerOpen.value = true;
}
} catch (error) {
@@ -1477,6 +1492,7 @@ onShow(() => {
onHide(() => {
showGeneration += 1;
candidateRefreshGeneration += 1;
cancelPendingBroadcastConsultation();
speechPlayback.stop();
composerRef.value?.teardown();
cancelVoiceTranscription();
@@ -1485,6 +1501,7 @@ onHide(() => {
onUnload(() => {
showGeneration += 1;
cancelPendingBroadcastConsultation();
releaseMessageResources();
speechPlayback.destroy();
composerRef.value?.teardown();