diff --git a/scripts/regression-chat-input-area-voice.mjs b/scripts/regression-chat-input-area-voice.mjs new file mode 100644 index 0000000..88de922 --- /dev/null +++ b/scripts/regression-chat-input-area-voice.mjs @@ -0,0 +1,39 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const scriptDir = dirname(fileURLToPath(import.meta.url)); +const componentPath = resolve( + scriptDir, + "../src/pages/ChatMain/ChatInputArea/index.vue" +); +const source = readFileSync(componentPath, "utf8"); + +const handlerMatch = source.match( + /const\s+handleVoiceTouchEndFromContainer\s*=\s*\(\)\s*=>\s*{([\s\S]*?)\n};/ +); + +assert.ok( + handlerMatch, + "ChatInputArea should define handleVoiceTouchEndFromContainer" +); + +const handlerBody = handlerMatch[1]; + +assert.ok( + !/speechProvider\s*!==\s*["']app["']/.test(handlerBody), + "container touchend must not ignore WeChat recordings because the pressed button can unmount while RecordingWaveBtn is shown" +); + +assert.ok( + /hasActiveVoiceRecognition\(\)/.test(handlerBody), + "container touchend should only stop when a voice recognition session is active" +); + +assert.ok( + /stopActiveVoiceRecognition\(\{\s*shouldSend:\s*true\s*\}\)/s.test( + handlerBody + ), + "container touchend should stop the active recognition and send recognized text" +); diff --git a/src/pages/ChatMain/ChatInputArea/index.vue b/src/pages/ChatMain/ChatInputArea/index.vue index b9d1e1b..f3c2984 100644 --- a/src/pages/ChatMain/ChatInputArea/index.vue +++ b/src/pages/ChatMain/ChatInputArea/index.vue @@ -185,6 +185,7 @@ let appStopFallbackTimer = null; let hasSentAppRecognition = false; const resetUI = () => { + isVoicePressing.value = false; isRecording.value = false; visibleWaveBtn.value = false; try { @@ -418,7 +419,6 @@ const handleVoiceTouchEnd = () => { }; const handleVoiceTouchEndFromContainer = () => { - if (speechProvider !== "app") return; if (!hasActiveVoiceRecognition()) return; stopActiveVoiceRecognition({ shouldSend: true }); };