惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
C
Check Point Blog
博客园_首页
B
Blog
D
Docker
U
Unit 42
量子位
I
InfoQ
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
GbyAI
GbyAI
L
LangChain Blog
云风的 BLOG
云风的 BLOG
博客园 - Franky
美团技术团队
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
Vercel News
Vercel News
Recent Announcements
Recent Announcements
雷峰网
雷峰网
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Google DeepMind News
Google DeepMind News

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(tts): keep final webchat audio supplemental · opencla...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -23,6 +23,10 @@ const mockState = vi.hoisted(() => ({

2323

finalPayload: null as {

2424

text?: string;

2525

mediaUrl?: string;

26+

mediaUrls?: string[];

27+

spokenText?: string;

28+

audioAsVoice?: boolean;

29+

trustedLocalMedia?: boolean;

2630

sensitiveMedia?: boolean;

2731

replyToId?: string;

2832

replyToCurrent?: boolean;

@@ -34,6 +38,8 @@ const mockState = vi.hoisted(() => ({

3438

text?: string;

3539

mediaUrl?: string;

3640

mediaUrls?: string[];

41+

spokenText?: string;

42+

audioAsVoice?: boolean;

3743

trustedLocalMedia?: boolean;

3844

replyToId?: string;

3945

replyToCurrent?: boolean;

@@ -113,6 +119,10 @@ vi.mock("../../auto-reply/dispatch.js", () => ({

113119

sendFinalReply: (payload: {

114120

text?: string;

115121

mediaUrl?: string;

122+

mediaUrls?: string[];

123+

spokenText?: string;

124+

audioAsVoice?: boolean;

125+

trustedLocalMedia?: boolean;

116126

sensitiveMedia?: boolean;

117127

replyToId?: string;

118128

replyToCurrent?: boolean;

@@ -122,6 +132,8 @@ vi.mock("../../auto-reply/dispatch.js", () => ({

122132

text?: string;

123133

mediaUrl?: string;

124134

mediaUrls?: string[];

135+

spokenText?: string;

136+

audioAsVoice?: boolean;

125137

trustedLocalMedia?: boolean;

126138

replyToId?: string;

127139

replyToCurrent?: boolean;

@@ -131,6 +143,8 @@ vi.mock("../../auto-reply/dispatch.js", () => ({

131143

text?: string;

132144

mediaUrl?: string;

133145

mediaUrls?: string[];

146+

spokenText?: string;

147+

audioAsVoice?: boolean;

134148

trustedLocalMedia?: boolean;

135149

replyToId?: string;

136150

replyToCurrent?: boolean;

@@ -257,6 +271,7 @@ function createTranscriptFixture(prefix: string) {

257271

"utf-8",

258272

);

259273

mockState.transcriptPath = transcriptPath;

274+

return dir;

260275

}

261276262277

function extractFirstTextBlock(payload: unknown): string | undefined {

@@ -579,6 +594,121 @@ describe("chat directive tag stripping for non-streaming final payloads", () =>

579594

});

580595

});

581596597+

it("persists auto-TTS final media as audio-only so webchat does not duplicate assistant text", async () => {

598+

const transcriptDir = createTranscriptFixture("openclaw-chat-send-agent-tts-final-");

599+

const audioPath = path.join(transcriptDir, "tts.mp3");

600+

fs.writeFileSync(audioPath, Buffer.from([0xff, 0xfb, 0x90, 0x00]));

601+

mockState.config = {

602+

agents: {

603+

defaults: {

604+

workspace: transcriptDir,

605+

},

606+

},

607+

};

608+

mockState.triggerAgentRunStart = true;

609+

mockState.dispatchedReplies = [

610+

{

611+

kind: "final",

612+

payload: {

613+

text: "This text is already in the model transcript.",

614+

spokenText: "This text is already in the model transcript.",

615+

mediaUrl: audioPath,

616+

mediaUrls: [audioPath],

617+

trustedLocalMedia: true,

618+

audioAsVoice: true,

619+

},

620+

},

621+

];

622+

const respond = vi.fn();

623+

const context = createChatContext();

624+625+

await runNonStreamingChatSend({

626+

context,

627+

respond,

628+

idempotencyKey: "idem-agent-tts",

629+

expectBroadcast: false,

630+

waitFor: "dedupe",

631+

});

632+633+

const assistantUpdates = mockState.emittedTranscriptUpdates.filter(

634+

(update) =>

635+

typeof update.message === "object" &&

636+

update.message !== null &&

637+

(update.message as { role?: unknown }).role === "assistant",

638+

);

639+

expect(assistantUpdates).toHaveLength(1);

640+

expect(assistantUpdates[0]).toMatchObject({

641+

message: {

642+

role: "assistant",

643+

idempotencyKey: "idem-agent-tts:assistant-media",

644+

content: [

645+

{ type: "text", text: "Audio reply" },

646+

{

647+

type: "audio",

648+

source: {

649+

type: "base64",

650+

media_type: "audio/mpeg",

651+

},

652+

},

653+

],

654+

},

655+

});

656+

expect(JSON.stringify(assistantUpdates[0]?.message)).not.toContain(

657+

"This text is already in the model transcript.",

658+

);

659+

});

660+661+

it("keeps visible text on non-agent TTS final media because no model transcript exists", async () => {

662+

const transcriptDir = createTranscriptFixture("openclaw-chat-send-command-tts-final-");

663+

const audioPath = path.join(transcriptDir, "tts.mp3");

664+

fs.writeFileSync(audioPath, Buffer.from([0xff, 0xfb, 0x90, 0x00]));

665+

mockState.config = {

666+

agents: {

667+

defaults: {

668+

workspace: transcriptDir,

669+

},

670+

},

671+

};

672+

mockState.finalPayload = {

673+

text: "Command result with TTS.",

674+

spokenText: "Command result with TTS.",

675+

mediaUrl: audioPath,

676+

mediaUrls: [audioPath],

677+

trustedLocalMedia: true,

678+

audioAsVoice: true,

679+

};

680+

const respond = vi.fn();

681+

const context = createChatContext();

682+683+

const payload = await runNonStreamingChatSend({

684+

context,

685+

respond,

686+

idempotencyKey: "idem-command-tts",

687+

});

688+689+

expect(payload?.message).toMatchObject({

690+

role: "assistant",

691+

content: [

692+

{ type: "text", text: "Command result with TTS." },

693+

{

694+

type: "audio",

695+

source: {

696+

type: "base64",

697+

media_type: "audio/mpeg",

698+

},

699+

},

700+

],

701+

});

702+

const assistantUpdates = mockState.emittedTranscriptUpdates.filter(

703+

(update) =>

704+

typeof update.message === "object" &&

705+

update.message !== null &&

706+

(update.message as { role?: unknown }).role === "assistant",

707+

);

708+

expect(assistantUpdates).toHaveLength(1);

709+

expect(JSON.stringify(assistantUpdates[0]?.message)).toContain("Command result with TTS.");

710+

});

711+582712

it("renders image reply payloads as assistant image content instead of MEDIA text", async () => {

583713

createTranscriptFixture("openclaw-chat-send-agent-image-");

584714

mockState.finalPayload = {