From c66d178efe7d759497b6d3ab223560aae21b6070 Mon Sep 17 00:00:00 2001 From: Blizzard Date: Sat, 25 Jul 2026 14:57:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(voice):=20=E6=80=9D=E8=80=83=E7=9C=8B?= =?UTF-8?q?=E9=97=A8=E7=8B=97=E8=A6=86=E7=9B=96=20PTT=20=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?(=E5=88=AB=E6=B0=B8=E8=BF=9C=E5=8D=A1=E5=9C=A8"=E6=80=9D?= =?UTF-8?q?=E8=80=83=E4=B8=AD")?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此前 armThinkTimer 只在连续对话模式挂,PTT 下后端不回(dispatcher 未就绪/ 模型没配/任务失败)就永远卡在"思考中",用户干等且毫无线索。 改:任何模式收到 final 转写都挂看门狗;超时后连续对话回聆听、PTT 回待命, 并明确提示可能原因 + 引导去运行页看任务状态。 Co-Authored-By: Claude Opus 5 --- sundynix-desktop/frontend/src/lib/voice.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sundynix-desktop/frontend/src/lib/voice.ts b/sundynix-desktop/frontend/src/lib/voice.ts index 5e19a37..a2f23b9 100644 --- a/sundynix-desktop/frontend/src/lib/voice.ts +++ b/sundynix-desktop/frontend/src/lib/voice.ts @@ -147,7 +147,7 @@ export class VoiceClient { if (m.final) { this.clearIdleTimer(); this.setState("thinking"); - if (this.conversation) this.armThinkTimer(); // 看门狗:任务失败/无 TTS 也能回到聆听 + this.armThinkTimer(); // 看门狗:后端不回/任务失败/无 TTS 时别永远卡在"思考中" } else if (this.conversation && this.state === "listening") { this.armIdleTimer(); // 有声音活动 → 空转计时重来 } @@ -341,12 +341,17 @@ export class VoiceClient { this.clearThinkTimer(); this.thinkTimer = window.setTimeout(() => { this.thinkTimer = null; - if (this.conversation && this.state === "thinking") { + if (this.state !== "thinking") return; + if (this.conversation) { this.cb.onError?.("等回答超时,继续聆听"); this.send({ type: "start" }); this.cb.onTurnStart?.(); this.setState("listening"); this.armIdleTimer(); + } else { + // PTT:回待命并说清可能原因,别让用户对着"思考中"干等。 + this.cb.onError?.("等了很久没有回答——可能后端任务没跑起来(dispatcher/模型未就绪)。去运行页看看这条任务的状态。"); + this.setState("ready"); } }, THINK_WATCHDOG_MS); }