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

推荐订阅源

大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
Last Week in AI
Last Week in AI
罗磊的独立博客
量子位
Jina AI
Jina AI
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
美团技术团队
雷峰网
雷峰网
爱范儿
爱范儿
S
SegmentFault 最新的问题
小众软件
小众软件
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

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(qqbot): truncate reminder job name on code-point boun...
llagy009 · 2026-06-28 · via Recent Commits to openclaw:main

File tree

  • extensions/qqbot/src/engine/tools

Original file line numberDiff line numberDiff line change

@@ -97,11 +97,45 @@ describe("engine/tools/remind-logic", () => {

9797

expect(generateJobName("drink water")).toBe("Reminder: drink water");

9898

});

9999
100-

it("truncates long content", () => {

101-

const long = "a very long reminder content that exceeds twenty characters";

102-

const name = generateJobName(long);

103-

expect(name.length).toBeLessThan(40);

104-

expect(name).toContain("…");

100+

it("truncates long content to a 20 UTF-16-unit budget with an ellipsis", () => {

101+

expect(generateJobName("a very long reminder content")).toBe(

102+

"Reminder: a very long reminder…",

103+

);

104+

});

105+
106+

it("keeps an exactly-fitting all-emoji content unchanged", () => {

107+

// 10 emoji = 20 UTF-16 units, exactly at the budget, so no truncation.

108+

expect(generateJobName("😀".repeat(10))).toBe(`Reminder: ${"😀".repeat(10)}`);

109+

});

110+
111+

it("does not split surrogate pairs when truncating", () => {

112+

const hasLoneSurrogate = (value: string): boolean => {

113+

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

114+

const code = value.charCodeAt(index);

115+

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

116+

const next = value.charCodeAt(index + 1);

117+

if (!(next >= 0xdc00 && next <= 0xdfff)) {

118+

return true;

119+

}

120+

index++;

121+

} else if (code >= 0xdc00 && code <= 0xdfff) {

122+

return true;

123+

}

124+

}

125+

return false;

126+

};

127+
128+

// 11 emoji = 22 UTF-16 units > 20; the 11th emoji straddles the cap and is

129+

// dropped whole rather than split into a lone surrogate.

130+

const allEmoji = generateJobName("😀".repeat(11));

131+

expect(allEmoji).toBe(`Reminder: ${"😀".repeat(10)}…`);

132+

expect(hasLoneSurrogate(allEmoji)).toBe(false);

133+
134+

// 19 ASCII + emoji: the emoji's high surrogate would land at unit 20, so the

135+

// whole pair is dropped to stay within the 20-unit budget.

136+

const name = generateJobName(`${"x".repeat(19)}😀tail`);

137+

expect(name).toBe(`Reminder: ${"x".repeat(19)}…`);

138+

expect(hasLoneSurrogate(name)).toBe(false);

105139

});

106140

});

107141
Original file line numberDiff line numberDiff line change

@@ -1,5 +1,6 @@

11

// Qqbot plugin module implements remind logic behavior.

22

import { resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";

3+

import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";

34
45

/**

56

* QQBot reminder tool core logic.

@@ -171,7 +172,7 @@ export function isCronExpression(timeStr: string): boolean {

171172

*/

172173

export function generateJobName(content: string): string {

173174

const trimmed = content.trim();

174-

const short = trimmed.length > 20 ? `${trimmed.slice(0, 20)}…` : trimmed;

175+

const short = trimmed.length > 20 ? `${truncateUtf16Safe(trimmed, 20)}…` : trimmed;

175176

return `Reminder: ${short}`;

176177

}

177178