Skip to content

fix(whatsapp): keep echo tracker log truncation UTF-16 safe#102603

Merged
steipete merged 2 commits into
openclaw:mainfrom
Pandah97:fix/echo-truncate-utf16
Jul 9, 2026
Merged

fix(whatsapp): keep echo tracker log truncation UTF-16 safe#102603
steipete merged 2 commits into
openclaw:mainfrom
Pandah97:fix/echo-truncate-utf16

Conversation

@Pandah97

@Pandah97 Pandah97 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

WhatsApp's echo tracker included the first 50 UTF-16 code units of a sent message in verbose diagnostics using raw .slice(0, 50). An emoji or another supplementary Unicode character crossing that boundary left a dangling surrogate in the log preview.

Why This Change Was Made

The WhatsApp-owned logger now uses the existing plugin-SDK truncateUtf16Safe helper at the same 50-code-unit bound. The regression test drives the public echo-tracker behavior, places an emoji across the exact boundary, asserts the complete log message, and verifies that the unmodified full text remains in the echo-detection set.

User Impact

Verbose WhatsApp diagnostics stay valid and readable for emoji-bearing messages. Echo matching, storage, limits, configuration, and message delivery are unchanged.

Evidence

  • node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extension-whatsapp.config.ts extensions/whatsapp/src/auto-reply/monitor/echo.test.ts — 1 test passed.
  • oxfmt, focused oxlint, and git diff --check passed for the touched files.
  • The behavioral assertion proves both the exact UTF-16-safe preview and unchanged full-text echo tracking.

No external WhatsApp call is required for this isolated verbose-log formatting path; the channel transport and delivery path are not changed.

AI-assisted

This PR was generated with Claude Code and improved/reviewed with Codex.

Replace `.slice(0, 50)` with `truncateUtf16Safe(text, 50)` in
echo tracker verbose log message to prevent surrogate pair corruption.

Ref. lsr911 pattern — mechanical substitution, no behavior change.
@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: XS labels Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:39 AM ET / 10:39 UTC.

Summary
The PR replaces the WhatsApp echo tracker verbose preview’s raw text.slice(0, 50) with truncateUtf16Safe(text, 50) from the plugin SDK and adds a focused regression test.

PR surface: Source +1, Tests +18. Total +19 across 2 files.

Reproducibility: yes. by source inspection and a focused JavaScript probe: current main uses text.slice(0, 50), and a 49-code-unit prefix followed by an emoji leaves a dangling high surrogate in the preview. I did not run a live WhatsApp connection during this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup 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 terminal/log/live output that exercises createEchoTracker with the emoji boundary case and shows the logged preview after the fix.
  • Update the PR body after adding proof so ClawSweeper can re-review the current head.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR has focused unit/mock evidence but no redacted after-fix terminal output, copied live output, or logs showing the echo preview behavior; the contributor should add proof with private data redacted and update the PR body to trigger re-review, or ask a maintainer for @clawsweeper re-review if needed.

Risk before merge

  • [P1] Contributor-facing real behavior proof is still mock/test-only; merging before proof would rely on source inspection for the verbose log path rather than observed after-fix output.

Maintainer options:

  1. Decide the mitigation before merge
    Land the helper substitution and regression test once the proof gate is satisfied, while keeping echo matching, storage, limits, and delivery behavior unchanged.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No automated repair is needed; the remaining action is contributor-provided real behavior proof or an explicit maintainer proof override before normal merge review.

Security
Cleared: The diff only calls an existing plugin-SDK text helper and adds a focused test; no dependency, secret, workflow, package, or code-execution security concern was found.

Review details

Best possible solution:

Land the helper substitution and regression test once the proof gate is satisfied, while keeping echo matching, storage, limits, and delivery behavior unchanged.

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

Yes, by source inspection and a focused JavaScript probe: current main uses text.slice(0, 50), and a 49-code-unit prefix followed by an emoji leaves a dangling high surrogate in the preview. I did not run a live WhatsApp connection during this read-only review.

Is this the best way to solve the issue?

Yes for the code shape: the owner-local verbose preview should reuse the existing plugin-SDK truncateUtf16Safe helper at the same bound. Merge readiness is blocked by proof, not by a better fix location.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This is a small verbose-diagnostic correctness fix with limited blast radius and no config, protocol, storage, delivery, availability, or security surface change.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR has focused unit/mock evidence but no redacted after-fix terminal output, copied live output, or logs showing the echo preview behavior; the contributor should add proof with private data redacted and update the PR body to trigger re-review, or ask a maintainer for @clawsweeper re-review if needed.
Evidence reviewed

PR surface:

Source +1, Tests +18. Total +19 across 2 files.

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

What I checked:

Likely related people:

  • obviyus: Current blame for the echo tracker preview and the helper/export context points to commit 28e53b6, whose live GitHub metadata maps to obviyus. (role: introduced current behavior; confidence: medium; commits: 28e53b681717; files: extensions/whatsapp/src/auto-reply/monitor/echo.ts, packages/normalization-core/src/utf16-slice.ts, src/plugin-sdk/text-utility-runtime.ts)
  • mcaxtr: Recent merged history shows major WhatsApp monitor and inbound-state work, including verbose inbound diagnostics, in the same plugin surface. (role: recent WhatsApp monitor area contributor; confidence: medium; commits: 458a52610a4d, aa023e428306; files: extensions/whatsapp/src/auto-reply/monitor.ts, extensions/whatsapp/src)
  • scoootscooob: The WhatsApp implementation was moved into extensions/whatsapp by the larger channel-to-extensions migration, which is relevant to plugin-boundary review. (role: adjacent migration owner; confidence: low; commits: 16505718e827; files: extensions/whatsapp/src)
  • steipete: The latest PR head includes a focused regression test commit authored by steipete, making them a likely follow-up owner for proof or merge-readiness handling. (role: current PR test contributor; confidence: medium; commits: 9a014cfad4e4; files: extensions/whatsapp/src/auto-reply/monitor/echo.test.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-09T09:36:57.234Z sha b6ec833 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Land-ready proof for exact head 9a014cfad4e4137197a720e9d766b4d0032b79d0:

  • Reviewed the WhatsApp echo tracker from outbound rememberText through inbound echo matching; only the verbose presentation preview is truncated, while the full message remains the detection key.
  • Added an exact emoji-boundary regression test that asserts the complete diagnostic string and unchanged full-text tracking; the focused WhatsApp test passes.
  • oxfmt, focused oxlint, git diff --check, and a fresh branch autoreview pass clean with no actionable findings.
  • Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 102603 accepted exact-head hosted CI/Testbox.

No live send is needed because transport, delivery, and echo identity are unchanged; this is isolated verbose-log formatting. No changelog entry or known proof gaps.

@steipete
steipete merged commit 0a8677e into openclaw:main Jul 9, 2026
95 of 96 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
…#102603)

* fix(whatsapp): keep echo tracker log truncation UTF-16 safe

Replace `.slice(0, 50)` with `truncateUtf16Safe(text, 50)` in
echo tracker verbose log message to prevent surrogate pair corruption.

Ref. lsr911 pattern — mechanical substitution, no behavior change.

* test(whatsapp): cover UTF-16-safe echo previews

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS 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