
























@@ -573,7 +573,7 @@ describe("DiscordVoiceManager", () => {
573573}
574574).scheduleCaptureFinalize(entry, "u1", "test");
575575576-await vi.advanceTimersByTimeAsync(1_200);
576+await vi.advanceTimersByTimeAsync(2_500);
577577578578expect(firstStream.destroy).toHaveBeenCalledTimes(1);
579579expect(entry?.capture.activeSpeakers.has("u1")).toBe(false);
@@ -600,6 +600,41 @@ describe("DiscordVoiceManager", () => {
600600}
601601});
602602603+it("uses configured silence grace before finalizing voice capture", async () => {
604+vi.useFakeTimers();
605+try {
606+const manager = createManager({
607+voice: {
608+enabled: true,
609+captureSilenceGraceMs: 4_000,
610+},
611+});
612+const stream = { destroy: vi.fn() };
613+const entry = {
614+guildId: "g1",
615+channelId: "1001",
616+capture: createVoiceCaptureState(),
617+};
618+entry.capture.activeSpeakers.add("u1");
619+entry.capture.captureGenerations.set("u1", 1);
620+entry.capture.activeCaptureStreams.set("u1", { generation: 1, stream });
621+622+(
623+manager as unknown as {
624+scheduleCaptureFinalize: (entry: unknown, userId: string, reason: string) => void;
625+}
626+).scheduleCaptureFinalize(entry, "u1", "test");
627+628+await vi.advanceTimersByTimeAsync(3_999);
629+expect(stream.destroy).not.toHaveBeenCalled();
630+631+await vi.advanceTimersByTimeAsync(1);
632+expect(stream.destroy).toHaveBeenCalledTimes(1);
633+} finally {
634+vi.useRealTimers();
635+}
636+});
637+603638it("passes senderIsOwner=true for allowlisted voice speakers", async () => {
604639const client = createClient();
605640client.fetchMember.mockResolvedValue({
@@ -702,6 +737,7 @@ describe("DiscordVoiceManager", () => {
702737expect(commandArgs?.messageChannel).toBe("discord");
703738expect(commandArgs?.messageProvider).toBe("discord-voice");
704739expect(commandArgs?.message).toContain("Do not call the tts tool");
740+expect(commandArgs?.message).toContain("repair obvious transcription artifacts");
705741expect(textToSpeechMock).toHaveBeenCalledWith(
706742expect.objectContaining({
707743channel: "discord",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。