Skip to content

fix(ui): keep session/tool/card label truncation UTF-16 safe#101640

Closed
lsr911 wants to merge 1 commit into
openclaw:mainfrom
lsr911:fix/ui-utf16-safe-truncation
Closed

fix(ui): keep session/tool/card label truncation UTF-16 safe#101640
lsr911 wants to merge 1 commit into
openclaw:mainfrom
lsr911:fix/ui-utf16-safe-truncation

Conversation

@lsr911

@lsr911 lsr911 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Six Control UI label truncation sites use raw .slice(0, N) where the boundary can split emoji or CJK surrogate pairs:

  • view-overview: session label @20
  • view-details: session label @50
  • tool-cards: card preview text @120
  • workboard: card title + session segment @96
  • custom-theme: theme name @80

Why This Change Was Made

truncateUtf16Safe from @openclaw/normalization-core/utf16-slice is the canonical leaf helper.

Evidence

Branch prerun (commit ef303a2)

=== UI session label @20/50/120/96/80 boundaries ===
Raw .slice(0,20) ends: "x\ud83d" (dangling)
truncateUtf16Safe: len=19 | no U+FFFD: true

Files Changed

File Change
ui/src/pages/usage/view-overview.ts .slice(0, 20)truncateUtf16Safe + import
ui/src/pages/usage/view-details.ts .slice(0, 50)truncateUtf16Safe + import
ui/src/lib/chat/tool-cards.ts .slice(0, 120)truncateUtf16Safe + import
ui/src/lib/workboard/index.ts .slice()truncateUtf16Safe + import
ui/src/app/custom-theme.ts .slice(0, 80)truncateUtf16Safe + import

Replace raw .slice(0, N) with truncateUtf16Safe in six UI
label truncation paths that may contain emoji or CJK:

- view-overview: session label @20
- view-details: session label @50
- tool-cards: preview text @120
- workboard: card title markup + segment sanitize @96
- custom-theme: theme name @80
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: S and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 8:25 AM ET / 12:25 UTC.

Summary
The PR replaces several Control UI raw string truncations for session labels, tool previews, workboard labels, and custom theme labels with truncateUtf16Safe.

PR surface: Source +33. Total +33 across 5 files.

Reproducibility: yes. source inspection plus a focused Node check shows raw slicing can leave a dangling surrogate at the reported boundaries. I did not establish a live failing Control UI reproduction in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof 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 real behavior proof for one affected Control UI label path, such as a screenshot or recording showing an emoji-containing label truncating without a replacement character.
  • Refresh the branch against current main so exact-head checks cover the final merge candidate.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body includes copied branch output for the helper behavior, but it does not show the changed Control UI label paths after the fix; add redacted screenshot, recording, live output, or logs for an affected UI path, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] The submitted proof demonstrates raw slicing and helper behavior, but not the actual changed Control UI label paths rendering after the fix.
  • [P1] The PR is behind current main; it should be refreshed and checked at the exact head before landing, though no concrete three-way merge regression was found.

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused helper substitution after the contributor adds redacted real Control UI behavior proof and exact-head checks remain green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The remaining blocker is contributor-supplied real UI proof and a refreshed exact-head validation state, not an automated code repair.

Security
Cleared: The diff imports an existing internal string helper into UI code and does not touch dependencies, workflows, secrets, generated assets, or code-execution surfaces.

Review details

Best possible solution:

Land the focused helper substitution after the contributor adds redacted real Control UI behavior proof and exact-head checks remain green.

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

Yes, source inspection plus a focused Node check shows raw slicing can leave a dangling surrogate at the reported boundaries. I did not establish a live failing Control UI reproduction in this read-only review.

Is this the best way to solve the issue?

Yes, this appears to be the narrow maintainable fix: the browser-safe @openclaw/normalization-core/utf16-slice helper already exists and is exported, so a new UI-specific truncation helper would be duplicate surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2ba622ca3019.

Label changes

Label changes:

  • add P3: This is a small Control UI text-truncation polish/bugfix with limited blast radius and no broad runtime or compatibility surface.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body includes copied branch output for the helper behavior, but it does not show the changed Control UI label paths after the fix; add redacted screenshot, recording, live output, or logs for an affected UI path, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Label justifications:

  • P3: This is a small Control UI text-truncation polish/bugfix with limited blast radius and no broad runtime or compatibility surface.
  • 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 stronger real behavior proof before merge: The PR body includes copied branch output for the helper behavior, but it does not show the changed Control UI label paths after the fix; add redacted screenshot, recording, live output, or logs for an affected UI path, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +33. Total +33 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 5 52 19 +33
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 52 19 +33

What I checked:

  • repository policy read: Root and scoped UI AGENTS.md files were read fully; the review applied the root PR-depth policy and the UI scoped guide did not add extra constraints for these runtime files. (AGENTS.md:1, 2ba622ca3019)
  • live PR state: Live GitHub data shows the PR is open, non-draft, mergeable but behind, with one commit at ef303a2 and five Control UI files changed. (ef303a22ccc6)
  • current-main raw truncation sites: Current main uses raw .slice at the reported custom theme, tool preview, workboard label/session key, and usage session-label paths. (ui/src/app/custom-theme.ts:432, 2ba622ca3019)
  • helper contract: truncateUtf16Safe floors the limit, returns shorter input unchanged, and delegates truncation to sliceUtf16Safe, which avoids dangling surrogate halves at slice boundaries. (packages/normalization-core/src/utf16-slice.ts:43, 2ba622ca3019)
  • import/export contract: The proposed import path is an explicit package export and the UI package already depends on @openclaw/normalization-core. (packages/normalization-core/package.json:47, 2ba622ca3019)
  • source reproduction: A direct Node check confirms that raw .slice(0, 20) can end with a dangling high surrogate when an emoji straddles the boundary.

Likely related people:

  • shakkernerd: PR feat: refactor the Control UI architecture #100024 refactored the Control UI architecture and touched central UI files including the custom-theme surface; GitHub commit metadata maps commit 65e1232 to @shakkernerd. (role: introduced Control UI architecture; confidence: medium; commits: 65e12328aa20; files: ui/src/app/custom-theme.ts, ui/src/pages/usage/view-overview.ts, ui/src/pages/usage/view-details.ts)
  • steipete: Recent merged PRs by @steipete touched the tool-card and usage surfaces that this PR edits, including grouped tool activity and usage cost analysis work. (role: recent adjacent contributor; confidence: high; commits: a5fdc0712186, ff32076f78b2; files: ui/src/lib/chat/tool-cards.ts, ui/src/pages/usage/view-overview.ts)
  • vincentkoc: Recent Control UI/workboard cleanup commits touched the workboard module near the changed surface, making @vincentkoc a useful routing candidate for that area. (role: recent area contributor; confidence: medium; commits: 835e6a75325a, 0ecfc522db53; files: ui/src/lib/workboard/index.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.

@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 7, 2026
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Closed as superseded by #101685, landed in 176fee5d071dd03f6cbbc54b029f23380b04e911. The replacement carries this useful UTF-16 boundary fix on current main, uses the existing shared helper, expands caller-level coverage, and preserves your commit credit in the consolidated commit. Thank you, @lsr911, for finding and fixing this.

@steipete steipete closed this Jul 7, 2026
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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