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

推荐订阅源

Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
量子位
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
Y
Y Combinator Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog
B
Blog
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
博客园 - 聂微东
腾讯CDC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks

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
perf(utils): preserve message identity in stripInlineDire...
willamhou · 2026-05-23 · via Recent Commits to openclaw:main

@@ -240,6 +240,99 @@ describe("stripInlineDirectiveTagsFromMessageForDisplay", () => {

240240

content: "plain text",

241241

};

242242

const result = stripInlineDirectiveTagsFromMessageForDisplay(input);

243-

expect(result).toEqual(input);

243+

expect(result).toBe(input);

244+

});

245+246+

test("returns original message reference when no directives are present", () => {

247+

const input = {

248+

role: "assistant",

249+

content: [{ type: "text", text: "plain text without directives" }],

250+

};

251+

const result = stripInlineDirectiveTagsFromMessageForDisplay(input);

252+

expect(result).toBe(input);

253+

});

254+255+

test("returns original message reference when content has only non-text parts", () => {

256+

const input = {

257+

role: "assistant",

258+

content: [{ type: "image", url: "https://example.test/x.png" }],

259+

};

260+

const result = stripInlineDirectiveTagsFromMessageForDisplay(input);

261+

expect(result).toBe(input);

262+

});

263+264+

test("preserves unchanged text-part references when only some parts change", () => {

265+

const unchangedPart = { type: "text" as const, text: "plain text" };

266+

const changedPart = { type: "text" as const, text: "with [[reply_to_current]] tag" };

267+

const nonTextPart = { type: "image" as const, url: "https://example.test/x.png" };

268+

const input = {

269+

role: "assistant",

270+

content: [unchangedPart, changedPart, nonTextPart],

271+

};

272+

const result = stripInlineDirectiveTagsFromMessageForDisplay(input);

273+

expect(result).not.toBe(input);

274+

const content = result?.content as Array<Record<string, unknown>>;

275+

expect(content[0]).toBe(unchangedPart);

276+

expect(content[1]).not.toBe(changedPart);

277+

expect(content[1]).toEqual({ type: "text", text: "with tag" });

278+

expect(content[2]).toBe(nonTextPart);

279+

});

280+281+

test("preserves trailing references when only the first part changes", () => {

282+

const changedPart = { type: "text" as const, text: "first [[reply_to_current]]" };

283+

const unchangedText = { type: "text" as const, text: "second" };

284+

const unchangedImage = { type: "image" as const, url: "https://example.test/x.png" };

285+

const input = {

286+

role: "assistant",

287+

content: [changedPart, unchangedText, unchangedImage],

288+

};

289+

const result = stripInlineDirectiveTagsFromMessageForDisplay(input);

290+

expect(result).not.toBe(input);

291+

const content = result?.content as Array<Record<string, unknown>>;

292+

expect(content).toHaveLength(3);

293+

expect(content[0]).not.toBe(changedPart);

294+

expect(content[0]).toEqual({ type: "text", text: "first " });

295+

expect(content[1]).toBe(unchangedText);

296+

expect(content[2]).toBe(unchangedImage);

297+

});

298+299+

test("preserves leading references when only the last part changes", () => {

300+

const unchangedText = { type: "text" as const, text: "first" };

301+

const unchangedImage = { type: "image" as const, url: "https://example.test/x.png" };

302+

const changedPart = { type: "text" as const, text: "last [[reply_to_current]]" };

303+

const input = {

304+

role: "assistant",

305+

content: [unchangedText, unchangedImage, changedPart],

306+

};

307+

const result = stripInlineDirectiveTagsFromMessageForDisplay(input);

308+

expect(result).not.toBe(input);

309+

const content = result?.content as Array<Record<string, unknown>>;

310+

expect(content).toHaveLength(3);

311+

expect(content[0]).toBe(unchangedText);

312+

expect(content[1]).toBe(unchangedImage);

313+

expect(content[2]).not.toBe(changedPart);

314+

expect(content[2]).toEqual({ type: "text", text: "last " });

315+

});

316+317+

test("preserves arbitrary extra fields on rebuilt text parts", () => {

318+

const input = {

319+

role: "assistant",

320+

content: [

321+

{

322+

type: "text",

323+

text: "with [[reply_to_current]] tag",

324+

id: "part-1",

325+

cache_control: { type: "ephemeral" },

326+

},

327+

],

328+

};

329+

const result = stripInlineDirectiveTagsFromMessageForDisplay(input);

330+

const content = result?.content as Array<Record<string, unknown>>;

331+

expect(content[0]).toEqual({

332+

type: "text",

333+

text: "with tag",

334+

id: "part-1",

335+

cache_control: { type: "ephemeral" },

336+

});

244337

});

245338

});