fix(discord): prevent approval command previews from splitting emoji when truncated#99539
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 10:15 AM ET / 14:15 UTC. Summary PR surface: Source +28, Tests +47. Total +75 across 2 files. Reproducibility: yes. Source inspection shows current main slices Discord approval command previews by UTF-16 code units, and the PR body includes before/after proof for the exact emoji-boundary failure mode. Review metrics: none identified. Stored data model 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: Merge the focused Discord plugin formatter fix after ordinary maintainer review and exact-head gates remain green. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main slices Discord approval command previews by UTF-16 code units, and the PR body includes before/after proof for the exact emoji-boundary failure mode. Is this the best way to solve the issue? Yes. The fix is in the private Discord presentation formatter used by approval payloads, and the shared UTF-16 helper would not preserve multi-code-point graphemes like flags. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ed5ccda79c8b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +28, Tests +47. Total +75 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
|
a13acac
into
openclaw:main
Related: problem-mode user report; no public issue number
What Problem This Solves
Fixes an issue where Discord approval command previews could split emoji characters when a long command was truncated exactly at an emoji boundary. The broken preview could render a replacement character or a partial emoji instead of preserving readable Discord text.
Why This Change Was Made
Discord approval previews now truncate command text on grapheme boundaries while preserving the existing preview length budget and backtick escaping behavior. The truncation stops as soon as the next grapheme would exceed the budget, so long commands do not need to be expanded into a full character array.
User Impact
Users reviewing long command approvals in Discord will see stable previews that do not contain half emoji, lone surrogate replacement characters, or partial flag emoji when truncation occurs.
Evidence
Base checked: origin/main 0cc9927 still used raw UTF-16
.slice(0, maxChars)for Discord command previews.Before-fix proof on the old truncation logic:
After-fix runtime proof through the Discord approval presentation payload:
Live Discord message rendering proof after this patch:
The live proof built the approval payload from this branch, posted it as real Discord Components V2 messages in a Discord test channel, fetched each message back from Discord, verified the rendered Command text display contained the expected truncated preview, and deleted the proof messages afterwards.
Regression and changed-file checks: