Repository navigation
fix: keep emoji intact when a gateway text frame is split - #1630
Conversation
A multi-frame WebSocket message was decoded with GetChars on each chunk. A UTF-8 character split across those frames became U+FFFD on both sides, so chat and canvas text lost emoji and non-English characters. The receive loop now keeps one decoder for the message and flushes it only when the frame ends the message. The regression drives a real loopback socket: the four UTF-8 bytes of an emoji are split 2 and 2, and the next message still decodes. Signed-off-by: Sebastien Tardif <[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. Reviewed October 5, 2026, 11:32 PM ET / October 6, 2026, 03:32 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR preserves emoji and other UTF-8 characters across fragmented gateway messages and adds two real-socket regression tests. Merge readiness✅ Ready for maintainer review The fix remains necessary: current main and the latest release still decode text fragments independently. The earlier fragment-tracking finding is resolved, the real-socket evidence covers the changed receive path, and no blocking defect remains. Priority: P2 Review scores
Verification
How this fits togetherThe shared WebSocket transport receives gateway messages for both the operator and Windows node clients. It assembles text before passing complete messages to their protocol handlers. flowchart TD
A[Gateway text frames] --> B[Shared receive loop]
B --> C{Fragmented message}
C -->|No| D[Decode complete text]
C -->|Yes| E[Retain UTF-8 decoder state]
E --> F[Flush at message end]
D --> G[Operator and node handlers]
F --> G
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep UTF-8 decoder state within each fragmented message while preserving the complete-message fast path and existing transport safeguards. Do we have a high-confidence way to reproduce the issue? Yes. Splitting an emoji's UTF-8 bytes across text fragments exercises the independently decoding current-main path; the contributor reports a failing-before and passing-after real-socket run. This reviewer did not execute it. Is this the best way to solve the issue? Yes. Message-scoped decoding is a focused repair in the existing transport owner, and explicit fragment tracking handles prefixes that produce no characters without contaminating the next message. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9dedabe66187. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
The fast path treated a final frame as a new message whenever no characters had been appended yet. A leading fragment of an emoji holds bytes in the decoder and appends nothing, so the last frame was decoded alone and the leftover bytes corrupted the next message. A message now stays fragmented until its last frame, independent of how many characters that prefix produced. Signed-off-by: Sebastien Tardif <[email protected]>
The revocation job failed in wsl-create before any test body. Fresh WSL install did not register expected distro OpenClawE2E-698efb65. The decoder change does not touch setup. Signed-off-by: Sebastien Tardif <[email protected]>
Core failed two Connection migration tests that do not read WebSocket text. DeletedReceipt expected 11 preserved items and saw 2. CleanupScript clock rollback expected exit 10 and got exit 2. The sibling removeDirectory case passed. Signed-off-by: Sebastien Tardif <[email protected]>
The UI job aborted after five minutes of inactivity. The tests named at the crash were markdown list rows and theme color fallback. Those do not read WebSocket frames. Core, Tray, Setup, Network, and Revocation passed on this head. Signed-off-by: Sebastien Tardif <[email protected]>
What Problem This Solves
Chat, canvas, and config text is corrupted when one character arrives in two WebSocket frames.
User Impact
Emoji and non-English characters stay intact when the gateway splits a text message across frames.
Why This Change Was Made
Each frame was decoded on its own. A UTF-8 character cut between frames became a replacement character on both sides. The receive loop now keeps one decoder for the message and flushes it only when the frame ends the message. Explicit fragmentation tracking also handles a first fragment that produces zero characters.
Evidence
Contributor-reported before-fix loopback result:
Fresh maintainer validation at
18b0e53c51f1e77656c83fa235332991deee2450passed both real-socket regressions: splithi😀followed bynext, and an emoji-only first message whose initial fragment produces zero characters followed by another fragmented message. Neither result contains replacement characters.The contributor's earlier proof was recorded at
f43c4e2e7cc54597c58596e82a9799ce55cc3366. Its tree and the current head tree are identical (2006f05c2ce975e5feaf072addbfa4d67c7f5f04); the three later commits only retriggered CI. Historical contributor totals are not presented as this fresh run.Change Type
Scope
winnodeRequired proof pools
none: this is a shared text-decoding repair with real loopback WebSocket proof. No tray page, node command contract, installer, WSL setup, or pairing behavior changed.Validation
Fresh maintainer run on native Windows ARM64, isolated worktree, exact head
18b0e53c51f1e77656c83fa235332991deee2450.OPENCLAW_REPO_ROOTpoints to this worktree;OPENCLAW_TRAY_DATA_DIRandOPENCLAW_TRAY_LOCAL_DATA_DIRpoint to session-isolated directories. Fresh test projects were built before--no-restoreso these counts represent executed tests..\build.ps1dotnet build .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --verbosity quietdotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~WebSocketClientBaseTestsdotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet build .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --verbosity quietdotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restoreEach test command additionally used a TRX logger and session-local results directory. Local logs and
transport.trx,shared.trx, andtray.trxare retained in the landing session artifacts. No local failure or retry occurred.9dedabe66187a1438a1e6a1f9c49b98f99581218: CI run 37395675439, attempt 1 passed core/CLI, tray/setup/integration, UI/accessibility, recovery and setup E2E, plus release builds.git merge-tree --write-tree origin/main HEADproduced clean candidate tree40d9104e431d2bfc87d97fff87ee75cfa0b3fee9. Relative to current main it contains exactly the original two-file change. Neither touched file changed on main since the PR merge-base, so no speculative branch refresh was needed. The candidate combined tree was inspected, not separately executed.Real Behavior Proof
18b0e53c51f1e77656c83fa235332991deee2450.WebSocketClientBaseTestsrun listed above.SplitUtf8Character_SurvivesTwoFramesAndTheNextMessage: passed. Real HttpListener/ClientWebSocket transport sends68 69 F0 9Fthen98 80, yieldinghi😀, thennext.ZeroCharFirstFragment_DoesNotCorruptTheNextSplitMessage: passed. SendsF0 9Fthen98 80, then fragmentednext; records the emoji andnextwithout replacement characters.Security Impact
NoNoNoNoNoYes, explain the risk and mitigation:Compatibility and Migration
YesNoNoReview Conversations
Live review-thread check: zero inline threads. Contributor implementation and authorship preserved; no code changes were needed during landing.