Repository navigation
Conversation
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]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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 😀.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +13, Docs +2. Total +17 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 23, 2026, 12:10 AM ET / 04:10 UTC (Revision 3). |
…tf16-safe-widget-script-snippet-e997 Co-authored-by: NIO <[email protected]>
…eway Co-authored-by: NIO <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Observed public 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. mainline-boundaryDecoded 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-boundaryDecoded 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."candidateline-boundaryDecoded 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-boundaryDecoded 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 |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 6332bd1. Thanks @hugenshen. show_widget diagnostics no longer split emoji or Unicode identifiers. |
…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]>
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)
What Problem This Solves
show_widgetsyntax 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
truncateUtf16Safeowner from@openclaw/normalization-core/utf16-slicefor both diagnostic fields instead of rawslice. No widget-specific Unicode helper, API, configuration, or plugin SDK change.Evidence
Built main
cc16d8d655332a71b13bd505c0b738de87ecd6bdand the candidate in isolated Docker. Loaded the served, built Control UI, observed its genuine authenticated WebSocket handshake advertisinginline-widgets, and invoked the publictools.invokemethod over that connection. The Gateway ran the realshow_widgetvalidator; no validator/helper invocation or mocked Gateway was used. State came from shipped configuration/session commands and tool RPCs.U+D83D; the parser-message case returns a loneU+D835.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.