Skip to content

fix(canvas): keep emoji whole in widget script error lines - #176207

Merged
obviyus merged 6 commits into
openclaw:mainfrom
hugenshen:cursor/utf16-safe-widget-script-snippet-e997
Oct 23, 2026
Merged

obviyus merged 6 commits into
openclaw:mainfrom
hugenshen:cursor/utf16-safe-widget-script-snippet-e997

Conversation

@hugenshen

@hugenshen hugenshen commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

show_widget syntax diagnostics can retain only the high surrogate of an astral character when the offending line reaches 160 UTF-16 units or the parser message reaches 200. The resulting RPC tool error contains half an emoji or identifier character.

Thanks to @hugenshen for the report and original fix.

User Impact

Diagnostics stop before a character that cannot fit whole. Both existing limits, syntax rejection, error positions and tool eligibility remain unchanged. ASCII errors are identical and valid widget code is still accepted.

Why This Change Was Made

Use the existing truncateUtf16Safe owner from @openclaw/normalization-core/utf16-slice for both diagnostic fields instead of raw slice. No widget-specific Unicode helper, API, configuration, or plugin SDK change.

Evidence

Built main cc16d8d655332a71b13bd505c0b738de87ecd6bd and the candidate in isolated Docker. Loaded the served, built Control UI, observed its genuine authenticated WebSocket handshake advertising inline-widgets, and invoked the public tools.invoke method over that connection. The Gateway ran the real show_widget validator; no validator/helper invocation or mocked Gateway was used. State came from shipped configuration/session commands and tool RPCs.

  • Main twice: the offending-line case returns a lone U+D83D; the parser-message case returns a lone U+D835.
  • Candidate twice: both decoded RPC errors are well-formed. The boundary snippets/messages are 159/199 UTF-16 units rather than splitting a character at 160/200.
  • Short ASCII syntax errors are byte-identical between arms; valid widget code succeeds on both.
  • Parser regressions fail on main (2 failed, 65 passed) and all 67 pass on the candidate. Changed TypeScript passed Oxfmt and Oxlint.
  • Real-provider built agent smoke returned WIDGET_DIAGNOSTIC_LIVE_OK.

Exact before/after RPC diagnostic text, JSON-escaped so the unmatched UTF-16 units are visible rather than replaced by a display glyph.

Simplification

Removed the 119-line one-off proof runner from the product tree and the inaccurate display-width comment. Kept the shared truncation owner and focused regressions for both independently bounded fields. Runtime production delta: +6/-4 lines; tests +13/-0; documentation +2/-0. No new helper or test-only production seam.

Merge Risk

Two-way door: reverting restores the previous diagnostic clipping; no persisted state or schema changes. Blast radius is the syntax-error text returned by Gateway inline-widget validation, not widget execution or presentation permissions.

show_widget echoes the offending line at a 160-unit cap. String.slice
could split an emoji and return that half in the tool error.

Co-authored-by: NIO <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S labels Oct 18, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves UTF-16 surrogate pairs when clipping widget syntax-error snippets and parser messages.

Example: An invalid script contains 151 ASCII characters after <script>, followed by 😀.

  • Before: The 160-unit offending-line snippet ends with the emoji's lone U+D83D surrogate.
  • After: The snippet stops at 159 units before the emoji, preserving the existing limit.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful repair with direct Gateway before/after evidence, distinct regressions, and no actionable findings; broad CI is still pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied built-Gateway tools.invoke responses exercise both changed diagnostic fields through the actual authenticated Control UI connection in isolated Docker, showing broken main boundaries and intact candidate prefixes with ASCII and valid-script controls.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A widget syntax error can contain half an emoji or astral identifier character, corrupting the diagnostic returned to the agent.
Reason: The patch restores intact diagnostic characters with minimal code and no new policy, configuration, API, or persistent state.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current diagnostic corruption bug with a focused shared-helper change; no actionable defects were found, and exact-head CI remains pending.

Priority: P3
Reviewed head: ca16b16599b392104207db922c87105e24561213

Before merge

None.

Findings

None.

Agent review details

How this fits together

The core show_widget validator parses inline JavaScript before hosting or presentation and returns bounded syntax diagnostics through Gateway tool errors.

flowchart LR
  A[Control UI client] --> B[Gateway tools invoke]
  B --> C[Core show_widget tool]
  C --> D[Inline script parser]
  D --> E[Shared UTF16 truncation]
  E --> F[Bounded tool error]
Loading

Technical review

Best possible solution:

Land the focused shared-helper fix once the existing exact-head checks pass.

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

Current-main source exposes both unsafe clipping boundaries, and supplied built-Gateway responses demonstrate the matching failures; this read-only review ran no target code.

Is this the best way to solve the issue?

Using the existing surrogate-safe truncation owner at both diagnostic producers is the smallest complete fix and preserves the established limits and parser behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 54dd1c6d9a56.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2d6dcab adds src/canvas/widget-script-syntax.ts:199 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2d6dcabc3ecf; files: src/canvas/widget-script-syntax.ts)

PR surface

Source +2, Tests +13, Docs +2. Total +17 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 4 +2
Tests 1 13 0 +13
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 21 4 +17

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +6/-4 lines; tests +13/-0 lines The small growth reuses one established owner and covers two distinct diagnostic clipping failures without new scaffolding.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: The defect corrupts bounded syntax-error text but does not change script rejection, widget execution, or delivery.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-18T13:05:54.749Z sha c2cc592 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-19T07:40:13.820Z sha fda7218 :: needs maintainer review before merge. :: none

Reviewed October 23, 2026, 12:10 AM ET / 04:10 UTC (Revision 3).

@hugenshen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@hugenshen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 19, 2026
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Observed public tools.invoke responses from built Gateway artifacts, through the actual authenticated Control UI WebSocket (its real connect request advertises inline-widgets; the connection receives the normal successful handshake). No validator/helper invocation and no mocked Gateway. State was created by shipped configuration/session commands and tool RPCs.

Main was exercised twice, then candidate twice, with both boundary inputs and ASCII/valid-code controls. Invalid scripts remain rejected on both arms; valid widget code remains accepted. ASCII diagnostic text is unchanged.

main

line-boundary

Decoded RPC error message, JSON-escaped to expose UTF-16 values exactly:

"widget_code has a JavaScript syntax error in inline script 1 at line 1, column 159: Unexpected character '\ud83d\ude00'. Offending line: <script>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ud83d. Fix the script and call show_widget again."

message-boundary

Decoded RPC error message, JSON-escaped to expose UTF-16 values exactly:

"widget_code has a JavaScript syntax error in inline script 1 at line 1, column 208: Identifier 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ud835. Offending line: <script>let aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. Fix the script and call show_widget again."

candidate

line-boundary

Decoded RPC error message, JSON-escaped to expose UTF-16 values exactly:

"widget_code has a JavaScript syntax error in inline script 1 at line 1, column 159: Unexpected character '\ud83d\ude00'. Offending line: <script>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. Fix the script and call show_widget again."

message-boundary

Decoded RPC error message, JSON-escaped to expose UTF-16 values exactly:

"widget_code has a JavaScript syntax error in inline script 1 at line 1, column 208: Identifier 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. Offending line: <script>let aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. Fix the script and call show_widget again."

Main retains lone U+D83D at the 160-unit offending-line cap and lone U+D835 at the 200-unit parser-message cap. Candidate returns complete strings: 159-unit offending-line prefix and 199-unit parser-message prefix, without increasing either limit. Both repetitions agree.

@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS and removed scripts Repository scripts size: S labels Oct 23, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@obviyus
obviyus merged commit 6332bd1 into openclaw:main Oct 23, 2026
128 of 132 checks passed
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Landed in 6332bd1. Thanks @hugenshen. show_widget diagnostics no longer split emoji or Unicode identifiers.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…176207)

fix(gateway): don't split an emoji or Unicode identifier in show_widget diagnostics

Gateway show_widget syntax diagnostics cut the offending line at 160 UTF-16 units and the parser message at 200, which could split an emoji or a non-BMP identifier and return a lone surrogate (invalid Unicode). Both cuts now use the existing truncateUtf16Safe owner, so they stop at a whole character.

Evidence: built Gateway, authenticated Control UI tools.invoke with a malformed widget. On main the line snippet split an emoji (lone U+D83D) and the parser message split an identifier (lone U+D835) (twice); with this change they are 159 and 199 units of valid text (twice). An ASCII error is identical, and a valid widget is still accepted. A live gpt-5.4-mini run passes. Production +6/-4 (a 119-line committed proof runner was removed).

Thanks @hugenshen.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
fix(gateway): don't split an emoji or Unicode identifier in show_widget diagnostics

Gateway show_widget syntax diagnostics cut the offending line at 160 UTF-16 units and the parser message at 200, which could split an emoji or a non-BMP identifier and return a lone surrogate (invalid Unicode). Both cuts now use the existing truncateUtf16Safe owner, so they stop at a whole character.

Evidence: built Gateway, authenticated Control UI tools.invoke with a malformed widget. On main the line snippet split an emoji (lone U+D83D) and the parser message split an identifier (lone U+D835) (twice); with this change they are 159 and 199 units of valid text (twice). An ASCII error is identical, and a valid widget is still accepted. A live gpt-5.4-mini run passes. Production +6/-4 (a 119-line committed proof runner was removed).

Thanks @hugenshen.

Co-authored-by: Ayaan Zaidi <[email protected]>

Beta.5 adaptation: Apply the source behavior to the c11c9d3 baseline; preserve baseline-native producer/consumer seams and include focused regression and registration adaptations for this group. See expanded-implementation-0/receipts.json for closure and qualification.

(cherry picked from commit 6332bd1)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c487ec963f5cdae5d67c35dc9d8b1d7950bfffa9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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