fix(gateway): use truncateUtf16Safe for voice-wake trigger truncation#103210
Conversation
|
Codex review: needs changes before merge. Reviewed July 10, 2026, 8:06 AM ET / 12:06 UTC. Summary PR surface: Source +1, Tests +46. Total +47 across 3 files. Reproducibility: yes. Current main’s 64-unit slice can split a surrogate pair, and the existing helper implementation plus the focused regression case establish the exact failing boundary with high confidence. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review findings
Review detailsBest possible solution: Retain the canonical UTF-16-safe substitution and focused Vitest regression, delete the duplicate standalone proof script, and preserve its useful terminal evidence in the PR body. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s 64-unit slice can split a surrogate pair, and the existing helper implementation plus the focused regression case establish the exact failing boundary with high confidence. Is this the best way to solve the issue? Yes for the runtime behavior: using the existing UTF-16-safe helper is the narrowest maintainable fix. The standalone proof script is not part of that best solution because the maintained regression and PR-body terminal transcript already cover it. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a238dead67bd. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1, Tests +46. Total +47 across 3 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
ClawSweeper review: the console-sanitization proof script belongs to openclaw#103226, not this gateway voice-wake fix. Remove it to keep the branch clean. Ref: openclaw#103210 review
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Replace naive .slice(0, 64) with truncateUtf16Safe() in normalizeVoiceWakeTriggers to prevent surrogate pair splitting in user-configured voice wake trigger phrases. Voice wake triggers are user-configurable text strings that may contain emoji or non-BMP characters. A naive .slice(0, 64) at a surrogate pair boundary produces a lone surrogate, which corrupts the trigger text. Co-Authored-By: Claude <[email protected]>
ClawSweeper review: the console-sanitization proof script belongs to openclaw#103226, not this gateway voice-wake fix. Remove it to keep the branch clean. Ref: openclaw#103210 review
2c38b02 to
52dcaa5
Compare
|
Land-ready at exact head Maintainer cleanup:
Proof:
Known proof gaps: none for this bounded Gateway normalization change. |
|
Merged via squash.
|
…openclaw#103210) * fix(gateway): use truncateUtf16Safe for voice-wake trigger truncation Replace naive .slice(0, 64) with truncateUtf16Safe() in normalizeVoiceWakeTriggers to prevent surrogate pair splitting in user-configured voice wake trigger phrases. Voice wake triggers are user-configurable text strings that may contain emoji or non-BMP characters. A naive .slice(0, 64) at a surrogate pair boundary produces a lone surrogate, which corrupts the trigger text. Co-Authored-By: Claude <[email protected]> * test: add proof scripts for C1 sanitize and voice-wake UTF-16 * chore: remove unrelated proof script from voice-wake PR ClawSweeper review: the console-sanitization proof script belongs to openclaw#103226, not this gateway voice-wake fix. Remove it to keep the branch clean. Ref: openclaw#103210 review * fix(gateway): harden voice wake unicode boundary --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
normalizeVoiceWakeTriggers()insrc/gateway/server-utils.tstruncates user-configured voice wake trigger phrases to 64 characters with naive.slice(0, 64). Voice wake triggers are user-configurable text strings that may contain emoji or non-BMP characters. A.slice(0, 64)at a surrogate pair boundary produces a lone high surrogate (0xD83D), which corrupts the trigger text sent to the speech recognition service.Why This Change Was Made
Replace
.slice(0, 64)withtruncateUtf16Safe(value, 64)— the standard UTF-16-safe truncation helper already used across the gateway module (same pattern as assistant-identity.ts, chat-display-projection.ts, ws-log.ts).User Impact
Voice wake trigger phrases containing emoji or CJK supplementary characters near the 64-char limit now remain valid UTF-16, without lone surrogates that could break downstream speech recognition or display.
Evidence
Standalone proof (production helper, same head)
Negative control (revert and verify test catches the bug)
Files Changed (2 files, +20/-1)
🤖 Generated with Claude Code