mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-18 03:31:37 +00:00
* fix(ui): keep clampText/truncateText surrogate-safe at emoji boundaries clampText and truncateText in format.ts used String.prototype.slice(0, N) to truncate user-visible text. When the truncation boundary falls inside a UTF-16 surrogate pair (emoji, CJK extended, etc.), the resulting string contains a dangling surrogate that browsers render as U+FFFD (�). Replace .slice(0, ...) with truncateUtf16Safe(...) which skips past incomplete surrogate pairs so the truncation point always falls on a code-point boundary. Affected UI surfaces: markdown rendering, command descriptions, skill summaries, exec-approval rules, tool-stream output previews. Add surrogate-safe truncation test cases for both functions using a real emoji at the exact truncation boundary. * test(ui): tighten UTF-16 truncation coverage --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>