Skip to content

fix(chat): large paste preview corrupts boundary emoji#106328

Merged
steipete merged 2 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-pasted-text-preview-utf16
Jul 13, 2026
Merged

fix(chat): large paste preview corrupts boundary emoji#106328
steipete merged 2 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-pasted-text-preview-utf16

Conversation

@zhangguiping-xydt

Copy link
Copy Markdown
Contributor
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 rendered aaaaaaaaaaaaaaaaaaa�....

  • After the fix, real Chromium drove the production Control UI paste handler and rendered a well-formed preview:

    {"kind":"daily-fix.pasted-preview-live-proof.v1","execution_ok":true,"expected_preview":"aaaaaaaaaaaaaaaaaaa...","problem_present":false,"user_path":"Control UI chat large plain-text paste rendered in real Chromium","code_units_hex":["61","61","61","61","61","61","61","61","61","61","61","61","61","61","61","61","61","61","61","2e","2e","2e"],"preview":"aaaaaaaaaaaaaaaaaaa...","well_formed":true}
    
  • The complete owning test file passed:

    Test Files  1 passed (1)
         Tests  184 passed (184)
    
  • Targeted formatter and type-aware lint passed; production UI type-checking and the Control UI production build passed; git diff --check passed.

  • The separate UI test-type shard still reports four existing strict-indexing errors in untouched chat-view.test.ts expressions from the task base. This change does not modify those expressions; the new regression itself runs and passes in the owning UI test project.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 13, 2026
@clawsweeper

clawsweeper Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 13, 2026, 10:39 AM ET / 14:39 UTC.

Summary
The PR changes large pasted-text attachment previews to use UTF-16-safe truncation and adds a regression test for an emoji crossing the 20-code-unit preview boundary.

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: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] The PR is mergeable but behind current main, so maintainers should gate the exact three-way merge result with the normal required checks before landing.

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No repair lane is needed; maintainers can review and merge the current head after normal base-refresh and required-check gating.

Security
Cleared: The two-file UI and test patch adds no dependency, workflow, permission, secret, download, publishing, or supply-chain surface.

Review details

Best 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 changes

Label justifications:

  • P2: The PR fixes a visible Control UI preview-corruption bug with narrow scope and limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Real Chromium output through the production paste handler demonstrates the corrupt preview before the fix and a well-formed preview afterward, supplemented by before-and-after screenshots.
  • proof: sufficient: Contributor real behavior proof is sufficient. Real Chromium output through the production paste handler demonstrates the corrupt preview before the fix and a well-formed preview afterward, supplemented by before-and-after screenshots.
Evidence reviewed

PR surface:

Source 0, Tests +30. Total +30 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 30 0 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 31 1 +30

What I checked:

  • Runtime fix: The preview owner replaces raw String.slice truncation with the existing UTF-16-safe helper while preserving normalization, trimming, ellipsis, attachment thresholds, payloads, and transport behavior. (ui/src/pages/chat/components/chat-composer.ts:1178, 27a61fed076b)
  • Regression coverage: The test dispatches the production paste event with 19 ASCII code units followed by an astral emoji, then verifies that the rendered attachment preview contains neither a replacement glyph nor a partial surrogate. (ui/src/pages/chat/chat-view.test.ts:3669, 27a61fed076b)
  • Real behavior proof: The PR records the pre-fix lone high surrogate and replacement glyph in real Chromium, followed by after-fix production-handler output showing a well-formed preview; the contributor also supplied before-and-after screenshots. (27a61fed076b)
  • Re-review continuity: The prior ClawSweeper review found no defects at d0b2277. The subsequent head commit only merged main, and the reported current-head CI set is successful. (27a61fed076b)
  • Related-item check: The provided closed macOS omnibus PR concerns native image paste and unrelated application flows; it neither implements nor supersedes this Control UI pasted-text preview fix.

Likely related people:

  • steipete: Merged history ties this person to substantial Control UI and chat-surface restructuring, making them the strongest available routing candidate for the composer boundary. (role: major Control UI refactor author and recent area contributor; confidence: medium; commits: e3ff8c4d288b; files: ui/src/pages/chat/components/chat-composer.ts, ui/src/pages/chat/chat-view.test.ts)
  • BunsDev: Recent merged work on Control UI chat composer behavior makes this person a useful secondary reviewer for the affected surface. (role: recent adjacent Control UI chat contributor; confidence: low; files: 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-13T12:24:04.174Z sha d0b2277 :: needs maintainer review before merge. :: none

@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

before:
before

after:
after

@steipete steipete self-assigned this Jul 13, 2026
@steipete

Copy link
Copy Markdown
Contributor

Land-ready proof:

  • Reviewed the full paste event -> attachment conversion -> preview rendering path against current main; the shared UTF-16 helper is the correct owner boundary.
  • Blacksmith Testbox run 29291263741: ui/src/ui/chat/chat-view.test.ts passed 182 tests; pnpm check:changed passed.
  • Fresh full-branch Codex Sol autoreview: clean, confidence 0.94.
  • Existing screenshots show the replacement glyph disappearing. They use an i prefix rather than the exact a fixture; the real paste-event DOM test covers the exact boundary fixture.
  • scripts/pr prepare-run 106328 passed exact-head/recent-rebase hosted gates at 27a61fed076bafb0b4f5dc833f95a89daed2fd70.

No known proof gaps affecting merge safety.

@steipete
steipete merged commit 88a45fe into openclaw:main Jul 13, 2026
78 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

wm0018 pushed a commit to wm0018/openclaw that referenced this pull request Jul 14, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 14, 2026
wangmiao0668000666 added a commit to wangmiao0668000666/openclaw that referenced this pull request Jul 14, 2026
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]>
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants