Skip to content

fix(discord): keep thread title truncation UTF-16 safe#101307

Closed
Alix-007 wants to merge 1 commit into
openclaw:mainfrom
Alix-007:alix/utf16-discord-thread-title
Closed

fix(discord): keep thread title truncation UTF-16 safe#101307
Alix-007 wants to merge 1 commit into
openclaw:mainfrom
Alix-007:alix/utf16-discord-thread-title

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Discord thread-title prompt fields were truncated with raw UTF-16 slicing. A limit that landed between an emoji's surrogate pair could send malformed text to the title completion model.

Why This Change Was Made

All three bounded fields now use the existing plugin SDK truncateUtf16Safe helper. Maintainer cleanup keeps the prompt formatter private and tests the real generateThreadTitle completion path instead of exporting production code only for a test.

User Impact

Long Discord message text, channel names, and channel descriptions no longer produce lone UTF-16 surrogates in generated thread-title prompts. Limits and ellipsis behavior are unchanged.

Evidence

  • Blacksmith Testbox: corepack pnpm test extensions/discord/src/monitor/thread-title.generate.test.ts — 8/8 passed.
  • Blacksmith Testbox: corepack pnpm check:changed — passed for the final two-file diff.
  • Canonical oxfmt check and git diff --check — passed.
  • Fresh Codex autoreview — no findings, correctness 0.99.
  • Live PR diff verified at 2 files, +19/-2, based directly on current main.

Full Discord/provider delivery was not run: the changed behavior is deterministic prompt construction and is exercised through the production completion entry point with the completion call mocked.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: XS labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 3:51 AM ET / 07:51 UTC.

Summary
The PR updates Discord generated thread-title prompt construction to truncate message, channel name, and channel description context with the existing UTF-16-safe helper and adds focused formatter regression coverage.

PR surface: Source +1, Tests +52. Total +53 across 2 files.

Reproducibility: yes. from source inspection: current main uses raw slice at the Discord thread-title prompt truncation limits, so an emoji crossing those limits can leave a lone UTF-16 surrogate. I did not run a local before/after test in this read-only review, but the source path and submitted terminal proof cover the boundary.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P2] No repair-lane work is needed; the contributor PR has sufficient scoped proof, green relevant checks, and no blocking review findings.

Security
Cleared: The diff only changes Discord prompt text truncation and focused tests; it does not alter dependencies, workflows, secrets, auth, network, packaging, or code-execution surfaces.

Review details

Best possible solution:

Land this as a bounded Discord plugin fix after ordinary maintainer review, keeping the existing prompt caps and UTF-16 helper rather than broadening thread-title behavior or adding config.

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

Yes from source inspection: current main uses raw slice at the Discord thread-title prompt truncation limits, so an emoji crossing those limits can leave a lone UTF-16 surrogate. I did not run a local before/after test in this read-only review, but the source path and submitted terminal proof cover the boundary.

Is this the best way to solve the issue?

Yes; applying the existing truncateUtf16Safe helper at the existing Discord prompt caps is the narrowest maintainable fix. Broader alternatives like changing completion behavior, title sanitization, or unrelated truncation sites are unnecessary for this prompt-context bug.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR fixes malformed Discord thread-title prompt context with a small, channel-scoped change and no config, auth, delivery, storage, or migration impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes current-head terminal proof directly invoking the production formatter with boundary emoji inputs and focused test output for the changed path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes current-head terminal proof directly invoking the production formatter with boundary emoji inputs and focused test output for the changed path.
Evidence reviewed

PR surface:

Source +1, Tests +52. Total +53 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 7 +1
Tests 1 53 1 +52
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 61 8 +53

What I checked:

Likely related people:

  • davidguttman: Authored the merged Discord autoThreadName: generated strategy that introduced the generated thread-title surface and tests. (role: feature origin; confidence: high; commits: aa91000a5d1b; files: extensions/discord/src/monitor/thread-title.ts, extensions/discord/src/monitor/thread-title.generate.test.ts, extensions/discord/src/monitor/threading.auto-thread.ts)
  • hanamizuki: Authored the merged reasoning-model thread-title budget fix in the same generated thread-title module and tests. (role: recent area contributor; confidence: high; commits: 537479f5b07d, d2b9d918af8a; files: extensions/discord/src/monitor/thread-title.ts, extensions/discord/src/monitor/thread-title.generate.test.ts)
  • ly-wang19: Authored the merged thread-title wrapper normalization fix in the same module shortly before this PR. (role: recent area contributor; confidence: medium; commits: 2852fa7e3541; files: extensions/discord/src/monitor/thread-title.ts, extensions/discord/src/monitor/thread-title.test.ts)
  • steipete: Recent history shows multiple simple-completion/plugin-SDK and Discord thread-title refactors by this contributor around the same runtime boundary. (role: adjacent owner; confidence: medium; commits: de20d3a02412, 7785dc21e658, 827b0de0ce74; files: extensions/discord/src/monitor/thread-title.ts, src/plugin-sdk/text-utility-runtime.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 (5 earlier review cycles)
  • reviewed 2026-07-07T03:53:42.480Z sha eee9d52 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T04:54:52.694Z sha 59adc68 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T05:23:26.672Z sha b5bd0d0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T05:33:24.103Z sha f062226 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-07T05:40:31.750Z sha f062226 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@Alix-007
Alix-007 force-pushed the alix/utf16-discord-thread-title branch 3 times, most recently from 73ba19c to 59adc68 Compare July 7, 2026 04:40
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 7, 2026
@Alix-007
Alix-007 force-pushed the alix/utf16-discord-thread-title branch from 59adc68 to b337353 Compare July 7, 2026 05:05
@Alix-007

Alix-007 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

I refreshed this against latest main and updated the proof section with current-head focused validation. I avoided broadening production exports only for proof.

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Alix-007
Alix-007 force-pushed the alix/utf16-discord-thread-title branch from b337353 to b5bd0d0 Compare July 7, 2026 05:15
@Alix-007

Alix-007 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current head/proof body was refreshed after the last rebase; please re-review the latest head.

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Alix-007
Alix-007 force-pushed the alix/utf16-discord-thread-title branch from b5bd0d0 to f062226 Compare July 7, 2026 05:27
@Alix-007

Alix-007 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

I added a direct prompt formatter path, refreshed the tests, and updated the proof with a standalone Node/tsx transcript from the current head.

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 7, 2026
@steipete steipete self-assigned this Jul 7, 2026
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Superseded by #101551, landed as 9fb24032215a7f273e8ea3b90286e7d6df6d3f76.

The original fork branch had accumulated unrelated repository ancestry and could not be safely rewritten in place. The replacement preserves @Alix-007's contribution with Co-authored-by, keeps the intended three Discord thread-title truncation points, and upgrades the regression to assert the actual completion payload. Exact-head hosted CI and the native landing workflow passed.

Thank you, @Alix-007. For future PRs, keeping the fork branch narrowly based on current main helps maintainers apply fixups directly; "Allow edits by maintainers" remains useful as well.

@Alix-007

Alix-007 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@steipete is ok ,thx haha

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

Labels

channel: discord Channel integration: discord P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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