Skip to content

Commit 4eb21d8

Browse files
committed
fix(qa-matrix): use truncateUtf16Safe for reply body preview
Replace .slice(0, 200) with truncateUtf16Safe() on MATRIX reply body preview to prevent UTF-16 surrogate pair corruption.
1 parent e595a8c commit 4eb21d8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

extensions/qa-matrix/src/runners/contract/scenario-runtime-shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Qa Matrix plugin module implements scenario runtime shared behavior.
22
import { randomUUID } from "node:crypto";
3+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
34
import { createMatrixQaClient, type MatrixQaRoomObserver } from "../../substrate/client.js";
45
import type { MatrixQaObservedEvent } from "../../substrate/events.js";
56
import type { MatrixQaFaultProxyObserver } from "../../substrate/fault-proxy.js";
@@ -189,7 +190,7 @@ export function buildMatrixReplyArtifact(
189190
): MatrixQaReplyArtifact {
190191
const replyBody = event.body?.trim();
191192
return {
192-
bodyPreview: replyBody?.slice(0, 200),
193+
bodyPreview: replyBody ? truncateUtf16Safe(replyBody, 200) : undefined,
193194
eventId: event.eventId,
194195
mentions: event.mentions,
195196
relatesTo: event.relatesTo,

0 commit comments

Comments
 (0)