Skip to content

Commit 14ba5fa

Browse files
committed
fix(queue-helpers): use truncateUtf16Safe for queue overflow summary truncation
Replace raw UTF-16 slice in summarizeDroppedItem with truncateUtf16Safe to prevent surrogate pair splitting in queue overflow summary text. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 6ad8a77 commit 14ba5fa

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/utils/queue-helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* debounce drains, and force individual collection when cross-channel ordering matters.
66
*/
77
/** Mutable summary state for a capped queue. */
8+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
9+
810
type QueueSummaryState = {
911
dropPolicy: "summarize" | "old" | "new";
1012
droppedCount: number;
@@ -75,7 +77,7 @@ function elideQueueText(text: string, limit = 140): string {
7577
if (text.length <= limit) {
7678
return text;
7779
}
78-
return `${text.slice(0, Math.max(0, limit - 1)).trimEnd()}…`;
80+
return `${truncateUtf16Safe(text, Math.max(0, limit - 1)).trimEnd()}…`;
7981
}
8082

8183
/** Normalize whitespace and elide one dropped item for queue summaries. */

0 commit comments

Comments
 (0)