Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): shorten voice auto-send pause to 1.5 seconds
JiangJiahao5698cd2c7a21
diff --git a/apps/desktop/src/main/voice-conversation/__tests__/service.test.ts b/apps/desktop/src/main/voice-conversation/__tests__/service.test.tsindex 19715189ab..aef3e14f19 100644--- a/apps/desktop/src/main/voice-conversation/__tests__/service.test.ts+++ b/apps/desktop/src/main/voice-conversation/__tests__/service.test.ts@@ -141,12 +141,12 @@ describe('local companion call ownership', () => {const { service, deps, provider } = fixture();await service.start(1, selection);provider.onSegment.mock.calls[0][0]({ id: 'segment', text: 'private utterance', final: true });- await vi.advanceTimersByTimeAsync(2_000);+ await vi.advanceTimersByTimeAsync(1_500);expect(deps.log.info).toHaveBeenCalledWith('input settled', {callId: selection.callId,trigger: 'silence',- inactiveMs: 2_000,- finalStableMs: 2_000,+ inactiveMs: 1_500,+ finalStableMs: 1_500,segments: 1,characters: 17,});diff --git a/docs/product-rules/companion-voice-mode.md b/docs/product-rules/companion-voice-mode.mdindex a1ca406b17..23356ee9a1 100644--- a/docs/product-rules/companion-voice-mode.md+++ b/docs/product-rules/companion-voice-mode.md@@ -4,7 +4,7 @@- 入口位于本机伙伴一对一输入框的听写按钮与发送按钮之间,使用声波图标和“开始语音对话”提示。标题栏不再提供语音入口。沿用伙伴 canonical 任务、模型、上下文、工作目录和工具权限,不创建第二条任务或切换聊天模型。- 用户点击输入框的语音对话按钮后,重新读取当前目录和该伙伴偏好;配置有效即开始连接并采集麦克风,无需再点击“开始”。模型缺失、音色未选或接口不明时直接打开“伙伴设置 → 语音”,不采集麦克风;设置完成不会自动开始,需返回输入框明确点击。使用现有语音输入的 ASR 设置和当前账号的服务模式;不启用听写润色,不修改原有听写行为。-- 最后一次声音活动或识别文字更新后,至少等待 2 秒再自动发送;期间继续说话会合并到同一段发言,只有 ASR 检出的弱声也遵守相同门槛。900ms 的声音释放只负责提前提交 ASR 缓冲,不触发发送;还须等待全部分段为最终文字及最后一次 ASR 更新后的 350ms 稳定窗口,延迟返回的识别结果可能延长等待。手动发送可跳过停顿等待,但不能发送未完成的识别文字。只有最终、非空文字能发送;声音活动检测本身不能产生消息。+- 最后一次声音活动或识别文字更新后,至少等待 1.5 秒再自动发送;期间继续说话会合并到同一段发言,只有 ASR 检出的弱声也遵守相同门槛。900ms 的声音释放只负责提前提交 ASR 缓冲,不触发发送;还须等待全部分段为最终文字及最后一次 ASR 更新后的 350ms 稳定窗口,延迟返回的识别结果可能延长等待。手动发送可跳过停顿等待,但不能发送未完成的识别文字。只有最终、非空文字能发送;声音活动检测本身不能产生消息。- 原任务空闲时正常发送,仍在运行时沿既有插话路径投递。语音是本机用户本人输入,不盖自动化或远程设备来源标签,不增加系统提示词。识别结果按普通文字发送,不执行桌面斜杠命令。- 最终回复经过持久化完成标记确认后才朗读。按本次语音发送的 clientId 关联,不朗读历史、过程文字、工具、子代理、内部协调或群来源私信。文本消息始终是对话记录的正本。- 在“伙伴设置 → 语音”中独立选择朗读模型和音色,按当前账号下的伙伴保存,不改变聊天模型。来源包括有权限的 Cindy AI,以及已连接的本地 BYOK 供应商;候选必须是 `audio_speech`、未停用且具备可用的 API key 或明确的本机免鉴权连接。同名模型按连接 ID、runtime 和上游模型 ID 区分,不能借另一连接的密钥。无候选时显示空状态,不采集麦克风。@@ -74,7 +74,7 @@## 验证-停顿与插话回归覆盖 2 秒等待、弱声识别、思考停顿后继续说话、空识别和无 ASR 结果的噪声、首轮回复在噪声期间完成、播放暂停后原位置继续,以及权限、静音、退出或明确停止后的迟到结果。日志测试确认输出只包含诊断元数据,不包含输入、回复或凭证。+停顿与插话回归覆盖 1.5 秒等待、弱声识别、思考停顿后继续说话、空识别和无 ASR 结果的噪声、首轮回复在噪声期间完成、播放暂停后原位置继续,以及权限、静音、退出或明确停止后的迟到结果。日志测试确认输出只包含诊断元数据,不包含输入、回复或凭证。自动化覆盖分段去重、乱序完成、空转写、连接轮换、权限与账号边界、取消启动、插话抢占、迟到音频、PCM 字节边界、回复关联、无模型空状态及现有 ASR 回归。BYOK 回归覆盖接口请求、SSE 断帧与结束聚合包、连接/密钥隔离、停用与账号切换、伙伴偏好重开与重置、未知接口须用户选择,以及合成失败不换供应商、不重发消息。音色与试听回归包含真实 MiniMax ID、OpenAI 型号差异、ElevenLabs 分页、账号私有列表边界、手动输入与刷新失败、改选清除旧音色、试听取消与迟到结果、窗口销毁,以及试听不启动 ASR。入口回归覆盖设置深链、输入框按钮顺序与草稿保留、缺配置转到设置、直接启动、StrictMode 不重复采集、关闭后的迟到配置结果,以及设置关闭前保存失败不离开。diff --git a/packages/voice-input-core/src/VoiceConversationInput.ts b/packages/voice-input-core/src/VoiceConversationInput.tsindex e70bddb781..0e29e34352 100644--- a/packages/voice-input-core/src/VoiceConversationInput.ts+++ b/packages/voice-input-core/src/VoiceConversationInput.ts@@ -1,7 +1,7 @@import type { AsrProvider, AsrSegment, AudioTrace } from "./types.js";import { ConversationActivity } from "./conversationActivity.js";-const AUTO_SEND_QUIET_MS = 2_000;+const AUTO_SEND_QUIET_MS = 1_500;const FINAL_STABLE_MS = 350;export type ConversationInputEvent =@@ -63,7 +63,7 @@ export class VoiceConversationInput {const activity = this.activity.push(pcm);this.speaking = activity.active;// The 900ms acoustic release only commits ASR buffers. Sending always uses- // the same two-second quiet window, including soft speech seen only by ASR.+ // the same 1.5-second quiet window, including soft speech seen only by ASR.if (activity.sound) {this.quietAfter = Date.now() + AUTO_SEND_QUIET_MS;if (!this.manual) clearTimeout(this.settleTimer);diff --git a/packages/voice-input-core/src/__tests__/VoiceConversationInput.test.ts b/packages/voice-input-core/src/__tests__/VoiceConversationInput.test.tsindex 693444fe36..06e06d9630 100644--- a/packages/voice-input-core/src/__tests__/VoiceConversationInput.test.ts+++ b/packages/voice-input-core/src/__tests__/VoiceConversationInput.test.ts@@ -50,10 +50,10 @@ describe("continuous speech input", () => {await vi.advanceTimersByTimeAsync(400);expect(events.filter((e) => e.type === "utterance")).toHaveLength(0);provider.segment({ id: "one", text: "你好。", final: true });- await vi.advanceTimersByTimeAsync(2000);+ await vi.advanceTimersByTimeAsync(1_500);provider.segment({ id: "one", text: "你好。", final: true });provider.segment({ id: "two", text: "你好。", final: true });- await vi.advanceTimersByTimeAsync(2000);+ await vi.advanceTimersByTimeAsync(1_500);expect(events.filter((e) => e.type === "utterance")).toEqual([{ type: "utterance", id: "1", text: "你好。" },{ type: "utterance", id: "2", text: "你好。" },@@ -61,7 +61,7 @@ describe("continuous speech input", () => {await input.stop();});- it("requires two quiet seconds for ASR-only soft speech and merges a thinking pause", async () => {+ it("requires 1.5 quiet seconds for ASR-only soft speech and merges a thinking pause", async () => {const provider = new Provider();const events: ConversationInputEvent[] = [];const diagnostic = vi.fn();@@ -72,7 +72,7 @@ describe("continuous speech input", () => {});await input.start();provider.segment({ id: "soft", text: "first part", final: true });- await vi.advanceTimersByTimeAsync(1_500);+ await vi.advanceTimersByTimeAsync(1_200);expect(events.some((event) => event.type === "utterance")).toBe(false);// Continue within the thinking pause. Even a provider-finalized first part// must remain in this utterance until the new activity has also settled.@@ -81,7 +81,7 @@ describe("continuous speech input", () => {await vi.advanceTimersByTimeAsync(900);input.appendAudio(pcm(0, 900));expect(provider.commitUtterance).toHaveBeenCalledOnce();- await vi.advanceTimersByTimeAsync(1_099);+ await vi.advanceTimersByTimeAsync(599);expect(events.some((event) => event.type === "utterance")).toBe(false);await vi.advanceTimersByTimeAsync(1);expect(events.filter((event) => event.type === "utterance")).toEqual([@@ -89,8 +89,8 @@ describe("continuous speech input", () => {]);expect(diagnostic).toHaveBeenCalledExactlyOnceWith({trigger: "silence",- inactiveMs: 2_000,- finalStableMs: 2_000,+ inactiveMs: 1_500,+ finalStableMs: 1_500,segments: 2,characters: 22,});@@ -109,7 +109,7 @@ describe("continuous speech input", () => {expect(emit).toHaveBeenCalledWith({ type: "speech-started" });await vi.advanceTimersByTimeAsync(900);input.appendAudio(pcm(0, 900));- await vi.advanceTimersByTimeAsync(1_099);+ await vi.advanceTimersByTimeAsync(599);expect(emit).not.toHaveBeenCalledWith({ type: "speech-idle" });await vi.advanceTimersByTimeAsync(1);expect(emit).toHaveBeenCalledWith({ type: "speech-idle" });@@ -128,7 +128,7 @@ describe("continuous speech input", () => {});await input.start();provider.segment({ id: "one", text: "soft speech", final: false });- await vi.advanceTimersByTimeAsync(1_500);+ await vi.advanceTimersByTimeAsync(1_000);provider.segment({ id: "one", text: "soft speech", final: true });await vi.advanceTimersByTimeAsync(499);expect(emit).not.toHaveBeenCalledWith(@@ -142,7 +142,7 @@ describe("continuous speech input", () => {});provider.segment({ id: "empty", text: "discarded partial", final: false });provider.segment({ id: "empty", text: "", final: true });- await vi.advanceTimersByTimeAsync(2_000);+ await vi.advanceTimersByTimeAsync(1_500);expect(emit).toHaveBeenCalledWith({ type: "speech-idle" });expect(emit.mock.calls.filter(([event]) => event.type === "utterance"),@@ -165,7 +165,7 @@ describe("continuous speech input", () => {expect.objectContaining({ type: "utterance" }),);provider.segment({ id: "a", text: "first", final: true, order: 0 });- await vi.advanceTimersByTimeAsync(2000);+ await vi.advanceTimersByTimeAsync(1_500);expect(emit).toHaveBeenCalledWith({type: "utterance",id: "1",@@ -221,8 +221,8 @@ describe("continuous speech input", () => {});await input.start();a.segment({ id: "same", text: "before", final: true });- await vi.advanceTimersByTimeAsync(2000);- await vi.advanceTimersByTimeAsync(8000);+ await vi.advanceTimersByTimeAsync(1_500);+ await vi.advanceTimersByTimeAsync(8_500);const buffered = pcm(1000, 200);input.appendAudio(buffered);finish();@@ -231,7 +231,7 @@ describe("continuous speech input", () => {a.segment({ id: "late", text: "ignore", final: true });b.segment({ id: "same", text: "after", final: true });input.appendAudio(pcm(0, 900));- await vi.advanceTimersByTimeAsync(2000);+ await vi.advanceTimersByTimeAsync(1_500);expect(emit.mock.calls.filter(([e]) => e.type === "utterance")@@ -288,9 +288,9 @@ describe("continuous speech input", () => {await input.start();p.segment({ id: "noise", text: "", final: false });p.segment({ id: "noise", text: "", final: true });- await vi.advanceTimersByTimeAsync(2000);+ await vi.advanceTimersByTimeAsync(1_500);p.segment({ id: "speech", text: "hello", final: true });- await vi.advanceTimersByTimeAsync(2000);+ await vi.advanceTimersByTimeAsync(1_500);expect(emit.mock.calls.filter(([e]) => e.type === "utterance")).toEqual([[{ type: "utterance", id: "1", text: "hello" }],]);