fix(twitch): truncate message preview on UTF-16 boundary#98008
Conversation
Replace String.prototype.slice() with sliceUtf16Safe() when truncating the debug-log message preview so that emoji, CJK, and other surrogate-pair characters are not split into lone surrogates. Co-Authored-By: Claude <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed June 30, 2026, 3:21 AM ET / 07:21 UTC. Summary PR surface: Source +1, Tests +70. Total +71 across 2 files. Reproducibility: yes. source inspection gives a high-confidence reproduction path: current main uses 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 detailsBest possible solution: Land the localized helper reuse with the focused Twitch regression tests after ordinary maintainer review. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence reproduction path: current main uses Is this the best way to solve the issue? Yes. Reusing the existing public AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 56c2d637d940. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1, Tests +70. Total +71 across 2 files. View PR surface stats
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
|
fe60ea1 to
f0e51da
Compare
Add two tests for the debug-log preview truncation: - Lone-surrogate check: an emoji at position 100 is not split - Plain ASCII: short messages pass through unchanged Co-Authored-By: Claude <[email protected]>
f0e51da to
73eefe2
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Closing this as superseded by the broader UTF-16-safe truncation fix now on main: c16bb87. I kept this as one canonical pass instead of landing the one-off PRs separately so Browser, Discord, Feishu, iMessage, MS Teams, Signal, Twitch, and Voice Call preview/error truncation all use the shared UTF-16 helpers consistently. Thanks for flagging this surface. Proof for the landed commit:
|
What Problem This Solves
The Twitch inbound-message debug-log preview truncates the message body
with
messageText.slice(0, 100). When an emoji or other astral characterstraddles position 100, the raw slice keeps only the high-surrogate half,
producing a lone
\uD83Din the debug log — malformed UTF-16.Why This Change Was Made
The plugin SDK provides
sliceUtf16Safefor this exact pattern. Otherchannel plugins (Discord, Feishu, Telegram, Signal, Mattermost, Slack)
already use it for the same purpose.
User Impact
No user-facing behavior change. The verbose debug log now emits valid
UTF-16 previews regardless of where emoji fall in the truncated message.
Evidence
git diff --check origin/main...HEADpnpm test extensions/twitch— 5 files, 43 tests passedAfter-fix Proof
Boundary probe on this PR branch:
Tests
extensions/twitch/src/twitch-client.test.ts— 2 new tests coveringthe straddling-emoji boundary (lone-surrogate assertion) and plain ASCII
pass-through.