Skip to content

fix(twitch): preserve UTF-16 pairs in outbound chunks#104030

Merged
steipete merged 1 commit into
mainfrom
codex/fix-twitch-utf16-chunking
Jul 11, 2026
Merged

fix(twitch): preserve UTF-16 pairs in outbound chunks#104030
steipete merged 1 commit into
mainfrom
codex/fix-twitch-utf16-chunking

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Twitch outbound text had two raw UTF-16 splitters. OpenClaw's markdown-aware planner could bisect an emoji at its 500-unit hard boundary, and the Twurple 8.1.4 ChatClient.say() fallback uses the same unsafe raw slicing when a caller sends more than 500 units.

Why This Change Was Made

Reuse the public surrogate-safe outbound chunker in both places that own the invariant:

  • the Twitch markdown planner strips formatting, then delegates its word/hard boundaries to the shared helper;
  • TwitchClientManager.sendMessage pre-chunks every transport send before Twurple receives it.

The monitor fallback now routes through that canonical manager path instead of calling ChatClient.say() directly. A single Twitch limit constant keeps adapter metadata and transport enforcement aligned.

User Impact

Emoji and other supplementary-plane characters remain intact when Twitch replies cross the 500-unit boundary. Chunk order is deterministic, and all normal outbound, message-adapter, direct internal, and inbound-reply fallback sends share the same transport guard.

Evidence

  • Direct dependency inspection: @twurple/chat 8.1.4 ChatClient.say() delegates to splitOnSpaces(text, 500), whose hard fallback uses raw slice().
  • Blacksmith Testbox tbx_01kx7a49qv2xqp9yt3dbrt1mmh: three focused Twitch suites — 44/44 passed.
  • Same Testbox: path-scoped pnpm check:changed — extension production/test typechecks, lint, import-cycle, and repository guards passed.
  • Fresh autoreview — clean, correctness 0.94.
  • Regressions cover markdown planning, exact transport calls at the 499 ASCII units + emoji boundary, and fallback routing through the guarded sender.
  • Production code is net smaller; git diff --check passed.

@openclaw-barnacle openclaw-barnacle Bot added channel: twitch Channel integration: twitch size: S maintainer Maintainer-authored PR labels Jul 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 44384c44fb42b11c218504cb36c5c415e3087851:

  • GitHub Actions run 29134172200 completed successfully for this exact SHA.
  • Blacksmith Testbox lease tbx_01kx7a49qv2xqp9yt3dbrt1mmh: all 44 focused Twitch tests passed across the markdown planner, transport manager, and monitor fallback suites.
  • Path-scoped changed-file gates passed: extension production/test type checks, lint, import-cycle checks, and repository guards. The only emitted warning was an unrelated latest-main temporary-directory test warning.
  • Fresh autoreview completed with no actionable findings (correctness confidence 0.94).
  • Direct dependency contract checked against @twurple/chat 8.1.4: ChatClient.say splits at 500 UTF-16 code units, and its final fallback uses raw slicing. This change pre-chunks through OpenClaw's surrogate-safe planner and centralizes the same 500-unit transport limit.
  • Native review artifacts validated with zero findings; OPENCLAW_TESTBOX=1 scripts/pr prepare-run 104030 passed and verified the exact PR head.

The resulting path is single-owner: markdown normalization plans safe chunks, every transport send passes through the manager, and the monitor fallback no longer bypasses that invariant.

@steipete
steipete merged commit 790cd2a into main Jul 11, 2026
111 of 115 checks passed
@steipete
steipete deleted the codex/fix-twitch-utf16-chunking branch July 11, 2026 01:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: twitch Channel integration: twitch maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant