Files
openclaw/ui
zw-xysk 57db713ff7 fix(ui): keep clampText/truncateText surrogate-safe at emoji boundaries (#102225)
* 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>
2026-07-09 04:46:36 +01:00
..
2026-05-14 10:27:12 +01:00