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

推荐订阅源

C
Check Point Blog
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
U
Unit 42
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
美团技术团队
雷峰网
雷峰网
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
D
DataBreaches.Net
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
罗磊的独立博客
MyScale Blog
MyScale Blog
博客园_首页
IT之家
IT之家
F
Fortinet All Blogs
博客园 - Franky

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
refactor: share webchat media audio fixture · openclaw/op...
vincentkoc · 2026-06-01 · via Recent Commits to openclaw:main

@@ -20,14 +20,19 @@ describe("buildWebchatAudioContentBlocksFromReplyPayloads", () => {

2020

tmpDir = undefined;

2121

});

222223-

it("exposes a local audio file as a media-ticketed attachment when it is under localRoots", async () => {

23+

function writeAudioFixture(bytes = [0xff, 0xfb, 0x90, 0x00]) {

2424

tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-webchat-audio-"));

2525

const audioPath = path.join(tmpDir, "clip.mp3");

26-

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

26+

fs.writeFileSync(audioPath, Buffer.from(bytes));

27+

return { audioPath, localRoot: tmpDir };

28+

}

29+30+

it("exposes a local audio file as a media-ticketed attachment when it is under localRoots", async () => {

31+

const { audioPath, localRoot } = writeAudioFixture();

27322833

const blocks = await buildWebchatAudioContentBlocksFromReplyPayloads(

2934

[{ mediaUrl: audioPath, trustedLocalMedia: true }],

30-

{ localRoots: [tmpDir] },

35+

{ localRoots: [localRoot] },

3136

);

32373338

expect(blocks).toHaveLength(1);

@@ -45,13 +50,11 @@ describe("buildWebchatAudioContentBlocksFromReplyPayloads", () => {

4550

});

46514752

it("preserves voice-note metadata on local audio attachments", async () => {

48-

tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-webchat-audio-"));

49-

const audioPath = path.join(tmpDir, "clip.mp3");

50-

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

53+

const { audioPath, localRoot } = writeAudioFixture();

51545255

const blocks = await buildWebchatAudioContentBlocksFromReplyPayloads(

5356

[{ mediaUrl: audioPath, trustedLocalMedia: true, audioAsVoice: true }],

54-

{ localRoots: [tmpDir] },

57+

{ localRoots: [localRoot] },

5558

);

56595760

expect(blocks).toHaveLength(1);

@@ -64,9 +67,7 @@ describe("buildWebchatAudioContentBlocksFromReplyPayloads", () => {

6467

});

65686669

it("suppresses reasoning payload audio", async () => {

67-

tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-webchat-audio-"));

68-

const audioPath = path.join(tmpDir, "clip.mp3");

69-

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

70+

const { audioPath, localRoot } = writeAudioFixture();

70717172

const blocks = await buildWebchatAudioContentBlocksFromReplyPayloads(

7273

[

@@ -77,7 +78,7 @@ describe("buildWebchatAudioContentBlocksFromReplyPayloads", () => {

7778

isReasoning: true,

7879

},

7980

],

80-

{ localRoots: [tmpDir] },

81+

{ localRoots: [localRoot] },

8182

);

82838384

expect(blocks).toHaveLength(0);

@@ -104,30 +105,26 @@ describe("buildWebchatAudioContentBlocksFromReplyPayloads", () => {

104105

});

105106106107

it("dedupes repeated paths", async () => {

107-

tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-webchat-audio-"));

108-

const audioPath = path.join(tmpDir, "clip.mp3");

109-

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

108+

const { audioPath, localRoot } = writeAudioFixture([0x00]);

110109111110

const blocks = await buildWebchatAudioContentBlocksFromReplyPayloads(

112111

[

113112

{ mediaUrl: audioPath, trustedLocalMedia: true },

114113

{ mediaUrl: audioPath, trustedLocalMedia: true },

115114

],

116-

{ localRoots: [tmpDir] },

115+

{ localRoots: [localRoot] },

117116

);

118117

expect(blocks).toHaveLength(1);

119118

});

120119121120

it("embeds file:// URLs pointing at a local file within localRoots", async () => {

122-

tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-webchat-audio-"));

123-

const audioPath = path.join(tmpDir, "clip.mp3");

124-

fs.writeFileSync(audioPath, Buffer.from([0x01]));

121+

const { audioPath, localRoot } = writeAudioFixture([0x01]);

125122126123

const fileUrl = pathToFileURL(audioPath).href;

127124

const blocks = await buildWebchatAudioContentBlocksFromReplyPayloads(

128125

[{ mediaUrl: fileUrl, trustedLocalMedia: true }],

129126

{

130-

localRoots: [tmpDir],

127+

localRoots: [localRoot],

131128

},

132129

);

133130

@@ -194,27 +191,23 @@ describe("buildWebchatAudioContentBlocksFromReplyPayloads", () => {

194191

});

195192196193

it("skips local audio when the opened file stat is over the cap", async () => {

197-

tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-webchat-audio-"));

198-

const audioPath = path.join(tmpDir, "huge.mp3");

199-

fs.writeFileSync(audioPath, Buffer.from([0x02]));

194+

const { audioPath, localRoot } = writeAudioFixture([0x02]);

200195

fs.truncateSync(audioPath, 16 * 1024 * 1024);

201196202197

const blocks = await buildWebchatAudioContentBlocksFromReplyPayloads(

203198

[{ mediaUrl: audioPath, trustedLocalMedia: true }],

204-

{ localRoots: [tmpDir] },

199+

{ localRoots: [localRoot] },

205200

);

206201207202

expect(blocks).toHaveLength(0);

208203

});

209204210205

it("rejects untrusted local audio paths", async () => {

211-

tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-webchat-audio-"));

212-

const audioPath = path.join(tmpDir, "clip.mp3");

213-

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

206+

const { audioPath, localRoot } = writeAudioFixture();

214207215208

const blocks = await buildWebchatAudioContentBlocksFromReplyPayloads(

216209

[{ mediaUrl: audioPath }],

217-

{ localRoots: [tmpDir] },

210+

{ localRoots: [localRoot] },

218211

);

219212220213

expect(blocks).toHaveLength(0);