Skip to content

Commit 352f47f

Browse files
authored
fix(imessage): coalesce merged text on UTF-16 code-point boundary
1 parent 1841c4c commit 352f47f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

extensions/imessage/src/monitor/coalesce.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Imessage plugin module implements the same-sender inbound debounce merge.
2+
import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
23
import type { IMessagePayload } from "./types.js";
34

45
// Keep the merge contract narrow (caps, ID tracking, reply-context preference)
@@ -136,7 +137,7 @@ export function combineIMessagePayloads(payloads: IMessagePayload[]): CoalescedI
136137
}
137138
let combinedText = textParts.join(" ");
138139
if (combinedText.length > MAX_COALESCED_TEXT_CHARS) {
139-
combinedText = `${combinedText.slice(0, MAX_COALESCED_TEXT_CHARS)}…[truncated]`;
140+
combinedText = `${sliceUtf16Safe(combinedText, 0, MAX_COALESCED_TEXT_CHARS)}…[truncated]`;
140141
}
141142

142143
// Merge attachments across bounded entries, capped to keep downstream media

0 commit comments

Comments
 (0)