fix(chat): large paste preview corrupts boundary emoji#106328
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 13, 2026, 10:39 AM ET / 14:39 UTC. Summary PR surface: Source 0, Tests +30. Total +30 across 2 files. Reproducibility: yes. Pasting text above the attachment threshold with an astral character crossing the 20-code-unit preview boundary produces a lone surrogate and replacement glyph on the pre-fix path, including in real Chromium. 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:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the shared-helper reuse at the pasted-preview owner with the focused regression test, preserving the full attachment payload and every non-preview behavior. Do we have a high-confidence way to reproduce the issue? Yes. Pasting text above the attachment threshold with an astral character crossing the 20-code-unit preview boundary produces a lone surrogate and replacement glyph on the pre-fix path, including in real Chromium. Is this the best way to solve the issue? Yes. Reusing the existing UTF-16-safe helper at the single preview-truncation owner is narrower and more maintainable than adding parallel Unicode logic or changing attachment semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0e96fc7e10a3. Label changesLabel justifications:
Evidence reviewedPR surface: Source 0, Tests +30. Total +30 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
Review history (1 earlier review cycle)
|
|
Land-ready proof:
No known proof gaps affecting merge safety. |
|
Merged via squash.
|
Round 2 follow-up: slim the regression test and PR body to match the sibling UTF-16-safe cohort (openclaw#106328, openclaw#102949, openclaw#102969) template. - Test: 304 -> 127 lines (-58%) - Removed LABEL_PROOF_DUMP / LABEL_RUN_LOG env vars + dumpDisplayName helper - Extracted renderRosterPrompt(nick) + parseDisplayName(prompt) helpers - Trimmed 47-line test-file header to 9 lines - Kept LABEL_TRUNCATION_MODE=baseline vi.mock for in-process control-red - All 4 emoji-boundary cases preserved - Body: ~30KB -> 10.5KB (-64%) - Dropped Round 1/2/3 rebase history - Dropped hex code-unit dump - Dropped TODO Crabbox run placeholders - Restructured to 4-section template - Production code unchanged: same 1-line + import + named constant patch. Same fix/baseline behavior (4/4 pass in fix mode, 3 fail in baseline). Co-Authored-By: Claude <[email protected]>


Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where users pasting a large plain-text note into Control UI chat could see a replacement glyph in the generated attachment preview when an emoji crossed the 20-unit display boundary.
Why This Change Was Made
The pasted-text preview owner now uses OpenClaw's existing UTF-16-safe truncation helper before adding the ellipsis. The full attachment payload, paste threshold, preview budget, restore behavior, send transport, configuration, schema, and protocol remain unchanged.
User Impact
Large pasted-text attachments keep complete emoji and other astral characters at the compact preview boundary instead of displaying
�. Short previews and boundary-safe long previews are unchanged.Evidence
Before the fix, the exact paste path failed in jsdom and real Chromium with preview code units ending in lone high surrogate
D83E; Chromium renderedaaaaaaaaaaaaaaaaaaa�....After the fix, real Chromium drove the production Control UI paste handler and rendered a well-formed preview:
The complete owning test file passed:
Targeted formatter and type-aware lint passed; production UI type-checking and the Control UI production build passed;
git diff --checkpassed.The separate UI test-type shard still reports four existing strict-indexing errors in untouched
chat-view.test.tsexpressions from the task base. This change does not modify those expressions; the new regression itself runs and passes in the owning UI test project.