fix(ui): keep workboard capture text truncation UTF-16 safe#102544
Conversation
Replace raw .slice(0, N - 3) with truncateUtf16Safe in clampSessionCaptureText and clampSessionCaptureTitle to prevent lone surrogates when emoji cross the truncation boundary. Completes the UTF-16 hardening started in openclaw#101685, which added the import but only covered buildCardSessionLabel.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 5:26 AM ET / 09:26 UTC. Summary PR surface: Source 0, Tests +6. Total +6 across 2 files. Reproducibility: yes. source-reproducible: current main slices at 177 and 697 code units in the Workboard capture path, so a prefix plus emoji crossing those boundaries can produce malformed UTF-16. I did not run a live UI reproduction in this read-only review. 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:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the two owner-local clamp replacements with the regression test after exact-head CI is clean and a redacted real Workboard capture proof is attached. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main slices at 177 and 697 code units in the Workboard capture path, so a prefix plus emoji crossing those boundaries can produce malformed UTF-16. I did not run a live UI reproduction in this read-only review. Is this the best way to solve the issue? Yes, this is the best narrow fix: the existing shared UTF-16 helper already serves sibling Workboard and UI truncation paths, and replacing only the two capture clamps avoids new API surface or helper exports. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4ad94febcb31. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source 0, Tests +6. Total +6 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 at exact head Maintainer review strengthened this with public Best-fix verdict: both capture-owned limits keep their existing policy and share the module's existing UTF-16-safe helper, with no new abstraction or compatibility path. |
|
Merged via squash.
|
…#102544) * fix(ui): keep workboard capture text truncation UTF-16 safe Replace raw .slice(0, N - 3) with truncateUtf16Safe in clampSessionCaptureText and clampSessionCaptureTitle to prevent lone surrogates when emoji cross the truncation boundary. Completes the UTF-16 hardening started in openclaw#101685, which added the import but only covered buildCardSessionLabel. * test(ui): cover workboard UTF-16 boundaries * docs(changelog): note Workboard UTF-16 fix * docs(changelog): leave release notes to release flow --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Workboard session-capture titles and notes used raw UTF-16 code-unit slices. If a length boundary landed between an emoji's surrogate halves, the captured card contained malformed text.
Why This Change Was Made
Both capture clamps now use the shared
truncateUtf16Safehelper already owned by the Workboard module. The reviewed patch keeps the private helpers private and covers them throughcaptureSessionToWorkboardinstead of a helper-only probe.User Impact
Long captured session labels, user prompts, and assistant notes remain valid Unicode at the Workboard limits. Short text and ASCII truncation behavior are unchanged.
Evidence
ui/src/pages/workboard/data.test.tsrun — 1 passed, 179 skipped.AI-assisted: Claude Code