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

推荐订阅源

罗磊的独立博客
Recent Announcements
Recent Announcements
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
J
Java Code Geeks
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
U
Unit 42
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
T
Tailwind CSS Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
腾讯CDC
I
InfoQ
GbyAI
GbyAI
博客园_首页

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(googlechat): truncate approval card text on UTF-16 bo...
llagy009 · 2026-06-28 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -110,6 +110,45 @@ function createDeferred<T>(): {

110110

return { promise, reject, resolve };

111111

}

112112
113+

type CardPayloadWithTextWidgets = {

114+

cardsV2: Array<{

115+

card: {

116+

sections?: Array<{

117+

header?: string;

118+

widgets?: Array<{ textParagraph?: { text: string } }>;

119+

}>;

120+

};

121+

}>;

122+

};

123+
124+

function getTextParagraphText(payload: unknown, header: string): string {

125+

const text = (payload as CardPayloadWithTextWidgets).cardsV2[0]?.card.sections?.find(

126+

(section) => section.header === header,

127+

)?.widgets?.[0]?.textParagraph?.text;

128+

if (typeof text !== "string") {

129+

throw new Error(`Expected ${header} text paragraph`);

130+

}

131+

return text;

132+

}

133+
134+

function isUtf16WellFormed(value: string): boolean {

135+

for (let index = 0; index < value.length; index += 1) {

136+

const codeUnit = value.charCodeAt(index);

137+

if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) {

138+

const nextCodeUnit = index + 1 < value.length ? value.charCodeAt(index + 1) : -1;

139+

if (nextCodeUnit < 0xdc00 || nextCodeUnit > 0xdfff) {

140+

return false;

141+

}

142+

index += 1;

143+

continue;

144+

}

145+

if (codeUnit >= 0xdc00 && codeUnit <= 0xdfff) {

146+

return false;

147+

}

148+

}

149+

return true;

150+

}

151+
113152

describe("googleChatApprovalNativeRuntime", () => {

114153

async function preparePendingDelivery(view = createPendingView()) {

115154

const nowMs = Date.now();

@@ -149,6 +188,31 @@ describe("googleChatApprovalNativeRuntime", () => {

149188

return { pendingPayload, plannedTarget, prepared, request, view };

150189

}

151190
191+

it("keeps truncated pending command card text UTF-16 well formed", async () => {

192+

const view = createPendingView();

193+

view.commandText = `${"a".repeat(1796)}😀${"b".repeat(100)}`;

194+
195+

const { pendingPayload } = await preparePendingDelivery(view);

196+

const commandText = getTextParagraphText(pendingPayload, "Command");

197+
198+

expect(commandText.length).toBeLessThanOrEqual(1800);

199+

expect(commandText.endsWith("...")).toBe(true);

200+

expect(isUtf16WellFormed(commandText)).toBe(true);

201+

expect(JSON.stringify(pendingPayload.cardsV2)).not.toContain("\\ud83d");

202+

});

203+
204+

it("preserves a complete astral character when it fits before the truncation suffix", async () => {

205+

const view = createPendingView();

206+

view.commandText = `${"a".repeat(1795)}😀${"b".repeat(100)}`;

207+
208+

const { pendingPayload } = await preparePendingDelivery(view);

209+

const commandText = getTextParagraphText(pendingPayload, "Command");

210+
211+

expect(commandText).toBe(`${"a".repeat(1795)}😀...`);

212+

expect(commandText.length).toBe(1800);

213+

expect(isUtf16WellFormed(commandText)).toBe(true);

214+

});

215+
152216

it("sends pending cards and updates the delivered message without buttons", async () => {

153217

sendGoogleChatMessage.mockResolvedValue({ messageName: "spaces/AAA/messages/msg-1" });

154218

updateGoogleChatMessage.mockResolvedValue({ messageName: "spaces/AAA/messages/msg-1" });