fix(imessage): coalesce merged text on UTF-16 code-point boundary

This commit is contained in:
llagy009
2026-06-29 10:08:39 +08:00
committed by GitHub
parent 1841c4caf5
commit 352f47f888

View File

@@ -1,4 +1,5 @@
// Imessage plugin module implements the same-sender inbound debounce merge.
import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
import type { IMessagePayload } from "./types.js";
// Keep the merge contract narrow (caps, ID tracking, reply-context preference)
@@ -136,7 +137,7 @@ export function combineIMessagePayloads(payloads: IMessagePayload[]): CoalescedI
}
let combinedText = textParts.join(" ");
if (combinedText.length > MAX_COALESCED_TEXT_CHARS) {
combinedText = `${combinedText.slice(0, MAX_COALESCED_TEXT_CHARS)}…[truncated]`;
combinedText = `${sliceUtf16Safe(combinedText, 0, MAX_COALESCED_TEXT_CHARS)}…[truncated]`;
}
// Merge attachments across bounded entries, capped to keep downstream media