Skip to content

Commit 5d4f0ab

Browse files
maweibinclaude
andcommitted
fix(commitments): keep emoji / surrogate pairs intact during terminal output truncation
.use Array.from() to count full code points instead of UTF-16 code units, preventing lone surrogates in commitment list output. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent 775ef96 commit 5d4f0ab

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/commands/commitments.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { timestampMsToIsoString } from "@openclaw/normalization-core/number-coercion";
33
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
44
import { normalizeStringEntries } from "@openclaw/normalization-core/string-normalization";
5+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
56
import { sanitizeTerminalText } from "../../packages/terminal-core/src/safe-text.js";
67
import { isRich, theme } from "../../packages/terminal-core/src/theme.js";
78
import { formatCliCommand } from "../cli/command-format.js";
@@ -24,7 +25,7 @@ const STATUS_VALUES = new Set<CommitmentStatus>([
2425
]);
2526

2627
function truncate(value: string, maxChars: number): string {
27-
return value.length <= maxChars ? value : `${value.slice(0, maxChars - 1)}…`;
28+
return value.length <= maxChars ? value : `${truncateUtf16Safe(value, maxChars - 1)}…`;
2829
}
2930

3031
function safe(value: string): string {

0 commit comments

Comments
 (0)