fix(status): keep emoji / surrogate pairs intact during gateway status truncation#101609
fix(status): keep emoji / surrogate pairs intact during gateway status truncation#101609maweibin wants to merge 1 commit into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. This PR is a valid narrow bug fix, but it is superseded by the broader open UTF-16 truncation sweep that carries the same gateway status change, a better caller-level regression test, maintainer proof, and contributor credit. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Use #101654 as the canonical landing path for this bug because it includes this gateway fix, caller-level coverage, broader duplicate cleanup, and contributor credit. So I’m closing this here and keeping the remaining discussion on #101654. Review detailsBest possible solution: Use #101654 as the canonical landing path for this bug because it includes this gateway fix, caller-level coverage, broader duplicate cleanup, and contributor credit. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main raw-slices the status-all gateway OAuth diagnostic message before appending an ellipsis, so a surrogate pair at that boundary can leave a dangling surrogate; I did not run the full CLI path in this read-only review. Is this the best way to solve the issue? No, this PR is no longer the best landing path. The code change is now correct, but the broader canonical PR carries the same gateway fix with better caller-level coverage and consolidates overlapping UTF-16 truncation work. Security review: Security review cleared: The current PR only changes TypeScript string truncation and tests, with no dependency, workflow, secret, permission, network, or code-execution surface added. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 60f0749b7fb3. |
…s truncation Use Array.from() to count full code points instead of UTF-16 code units, preventing lone surrogates in gateway status output. Co-Authored-By: Claude Opus 4.8 <[email protected]>
41d2533 to
244cca9
Compare
|
Thanks @maweibin. The useful behavior from this PR was consolidated with the sibling UTF-16 boundary fixes into #101654 and landed on The landed fix uses the existing |
What Problem This Solves
The
shortenhelper insrc/commands/status-all/gateway.tstruncates gateway log-tail diagnostic messages with.slice()which counts UTF-16 code units. When a surrogate-pair character (emoji) straddles the cut boundary,.slice()produces a lone surrogate (e.g.\ud83d) that renders as�inopenclaw gateway statusoutput.This is user-visible: gateway log-tail summaries include provider error messages that can contain emoji or other supplementary characters.
Why This Change Was Made
Replace
.slice()withtruncateUtf16Safe()from@openclaw/normalization-core/utf16-sliceso truncation counts full code points instead of UTF-16 code units. This matches the already-merged PR #101517 (session-cost-usage).User Impact
Gateway status log-tail summaries no longer show
�when error messages contain emoji near truncation boundaries. Existing column width caps are preserved — the broken surrogate is dropped cleanly rather than rendered as a replacement character.Evidence
Real environment tested: local OpenClaw source checkout, Node v24.13.1, PR head.
Exact steps after this patch:
Evidence after fix:
Observed result after fix:
truncateUtf16Safepreserves full code points; no lone surrogate reaches terminal output. The existingmaxLencap is unchanged — the broken surrogate is dropped cleanly rather than rendered as�.What was not tested: full
openclaw gateway statusend-to-end run on exact PR head (production CLI uses installed binary).Regression Test Plan
Includes a focused regression test ("summarizeLogTail truncation / does not split surrogate pairs") that verifies the
shortenhelper drops a broken surrogate pair cleanly.AI-assisted.