Skip to content

fix: keep emoji intact at remaining text truncation boundaries#101754

Merged
steipete merged 2 commits into
openclaw:mainfrom
wings1029:fix/utf16-safe-remaining-text-truncations
Jul 9, 2026
Merged

fix: keep emoji intact at remaining text truncation boundaries#101754
steipete merged 2 commits into
openclaw:mainfrom
wings1029:fix/utf16-safe-remaining-text-truncations

Conversation

@wings1029

@wings1029 wings1029 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Restart reasons and Control UI chat previews still had raw UTF-16 slicing boundaries. If an emoji crossed one of those caps, the returned or rendered string could end with a lone surrogate.

Why This Change Was Made

Use the existing truncateUtf16Safe primitive at each user-visible boundary. The maintainer fixup also makes scheduleGatewaySigusr1Restart reuse the restart module's existing reason normalizer and covers the equivalent gateway RPC boundary, so restart reasons have one consistent contract from input through persisted intent and scheduling.

User Impact

  • Gateway restart reasons stay valid when supplied through RPC, scheduling, or persisted restart intent.
  • Reply targets, reply previews, and pinned-message previews no longer render malformed emoji at their limits.
  • Ordinary text and all existing maximum lengths remain unchanged.

Evidence

  • Exact-output regression coverage: gateway RPC reason, scheduler reason, persisted restart reason, reply target, and reply preview.
  • Existing Control UI and restart code paths are exercised rather than testing the helper in isolation.
  • Fresh maintainer autoreview: clean, confidence 0.97.
  • Exact-head CI: run 28880798105, success at e5bab02257c814892936aac182fbf8a35cb93994.
  • OpenGrep and CodeQL exact-head checks: success.

Scope

Eight files; no config, protocol, dependency, migration, or compatibility change. AI-assisted; maintainer-reviewed and expanded to the complete restart boundary.

Replace .slice(0, N) with truncateUtf16Safe() in five remaining
user-visible text truncation sites that were missed by earlier
UTF-16 safety sweeps:

- restart.ts: restart reason text (2 sites)
- chat-composer.ts: reply target text preview
- chat-thread.ts: thread text preview + message text extraction

All sites truncate user-generated content where emoji or other
supplementary-plane characters could produce lone surrogates.

Co-Authored-By: Claude <[email protected]>
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 12:26 PM ET / 16:26 UTC.

Summary
The branch replaces raw UTF-16 .slice truncation with truncateUtf16Safe for restart reasons and web chat previews, adding focused restart and chat regression tests.

PR surface: Source +4, Tests +62. Total +66 across 8 files.

Reproducibility: yes. Source inspection shows current main raw-slices the affected restart and chat boundaries, and an input like x.repeat(limit - 1) + "🧠tail" crosses the cap with a surrogate pair; I did not run live browser or CLI proof in this read-only review.

Review metrics: 1 noteworthy metric.

  • Prior ClawSweeper finding: 1 fixed. The current head adds the gateway restart RPC helper replacement and regression test requested in the previous review cycle.

Stored data model
Persistent data-model change detected: serialized state: src/infra/restart-intent.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted after-fix proof showing an emoji-boundary restart or web chat case without U+FFFD.
  • Refresh the branch after proof so CI and review apply to the exact current head.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body only provides test output; add a redacted live run, terminal output, screenshot, recording, or logs showing the emoji-boundary behavior, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review.

Mantis proof suggestion
The reply and pinned-message preview changes are visible in OpenClaw web UI chat, so redacted chat proof would materially reduce the remaining proof gap. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web ui chat proof: verify reply and pinned-message previews keep an emoji intact at the truncation boundary and capture redacted evidence.

Risk before merge

  • [P1] External real behavior proof is still absent; the PR body only shows tests and does not demonstrate after-fix restart or web chat rendering without U+FFFD.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the shared-helper implementation and merge only after redacted after-fix proof demonstrates the restart or web chat emoji-boundary behavior in a real setup.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Needs contributor real-behavior proof and routine maintainer review; no repair job is appropriate because the previous code finding is fixed and automation cannot supply the contributor's setup proof.

Security
Cleared: The diff only uses an existing normalization helper and adds tests; it does not change dependencies, workflows, secrets, permissions, package resolution, or code-execution surfaces.

Review details

Best possible solution:

Keep the shared-helper implementation and merge only after redacted after-fix proof demonstrates the restart or web chat emoji-boundary behavior in a real setup.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main raw-slices the affected restart and chat boundaries, and an input like x.repeat(limit - 1) + "🧠tail" crosses the cap with a surrogate pair; I did not run live browser or CLI proof in this read-only review.

Is this the best way to solve the issue?

Yes, the current head is the right fix shape: use the existing surrogate-safe helper at each owning boundary while preserving caps. It is not merge-ready until real behavior proof is added.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 453f5968bbca.

Label changes

Label justifications:

  • P2: This is a normal-priority user-visible text correctness fix for bounded restart and chat previews with limited blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body only provides test output; add a redacted live run, terminal output, screenshot, recording, or logs showing the emoji-boundary behavior, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +4, Tests +62. Total +66 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 14 10 +4
Tests 4 62 0 +62
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 76 10 +66

What I checked:

Likely related people:

  • vincentkoc: Blame shows the current main raw restart and chat truncation boundaries were carried into the present files by commit 098b471, and recent path history also shows follow-up UI file-private export work. (role: recent area contributor; confidence: high; commits: 098b471143c1, c8d95da14c5b; files: src/gateway/server-methods/restart.ts, src/infra/restart.ts, ui/src/pages/chat/components/chat-composer.ts)
  • steipete: Recent merged UTF-16 bounded-text consolidation PRs were authored and merged by this handle, and they establish the shared helper pattern this PR extends. (role: recent consolidation owner; confidence: high; commits: a9582a1bb62a, 176fee5d071d, 87fe266c5e4d; files: packages/normalization-core/src/utf16-slice.ts, src/infra/http-body.ts, ui/src/pages/usage/view-details.ts)
  • wings1029: Beyond this PR, this handle authored the merged adjacent HTTP error-body UTF-16 truncation fix that uses the same helper and problem shape. (role: recent related UTF-16 contributor; confidence: medium; commits: d633a2df4229, 989e576f1b8f; files: src/infra/http-error-body.ts, src/infra/restart.ts, ui/src/pages/chat/components/chat-composer.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-07T15:39:26.743Z sha 989e576 :: needs real behavior proof before merge. :: [P2] Cover the gateway restart RPC reason

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Land-ready at exact head e5bab02257c814892936aac182fbf8a35cb93994.

Maintainer work completed:

  • consolidated scheduler reason handling onto the existing restart normalizer;
  • covered the equivalent gateway RPC boundary;
  • added exact-output regressions for RPC, scheduler, SQLite-backed intent consumption, reply-target interaction, and rendered reply preview;
  • formatted all eight touched files and ran git diff --check;
  • fresh structured autoreview: clean, confidence 0.97;
  • exact-head CI 28880798105: success;
  • exact-head OpenGrep 28880798361 and CodeQL 28880798259: success;
  • native review artifacts validated and OPENCLAW_TESTBOX=1 scripts/pr prepare-run 101754 passed the hosted exact-head gate.

Known gaps: none for the changed surfaces. No config, protocol, dependency, migration, or compatibility change.

@steipete
steipete merged commit 1825c9f into openclaw:main Jul 9, 2026
123 of 126 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 9, 2026
…law#101754)

* fix: keep emoji intact at remaining text truncation boundaries

Replace .slice(0, N) with truncateUtf16Safe() in five remaining
user-visible text truncation sites that were missed by earlier
UTF-16 safety sweeps:

- restart.ts: restart reason text (2 sites)
- chat-composer.ts: reply target text preview
- chat-thread.ts: thread text preview + message text extraction

All sites truncate user-generated content where emoji or other
supplementary-plane characters could produce lone surrogates.

Co-Authored-By: Claude <[email protected]>

* fix: complete UTF-16-safe restart and chat boundaries

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants