Skip to content

fix(discord): bound component labels by UTF-16 units - #60113

Merged
teknium1 merged 1 commit into
mainfrom
salvage/54969-discord-utf16-labels
Jul 7, 2026
Merged

fix(discord): bound component labels by UTF-16 units#60113
teknium1 merged 1 commit into
mainfrom
salvage/54969-discord-utf16-labels

Conversation

@teknium1

@teknium1 teknium1 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Discord component labels (model picker select options, clarify choice buttons) are now truncated by UTF-16 code units — the unit Discord actually enforces — instead of Python code-point slices, so emoji-heavy labels can no longer exceed Discord's component field budgets and 400 the interaction.

Salvage of #54969 by @ooiuuii, cherry-picked onto current main with authorship preserved. Fixes #54968.

Changes

  • plugins/platforms/discord/adapter.py: model-picker select labels/values and clarify button labels routed through the existing utf16_len / _prefix_within_utf16_limit helpers from gateway/platforms/base.py; word/soft-boundary truncation behavior preserved
  • tests/gateway/test_discord_model_picker.py, tests/gateway/test_discord_clarify_buttons.py: emoji-heavy regression coverage

Validation

Before After
80-emoji label (160 UTF-16 units) [:100] → 160 units, over budget 100 units, no surrogate split
ASCII labels works unchanged

Targeted suites green; truncation math verified with real imports (no surrogate-pair splits).

Infographic

UTF-16 Safe Discord Labels

@teknium1
teknium1 force-pushed the salvage/54969-discord-utf16-labels branch from 97cdb1a to 0819b2c Compare July 7, 2026 09:14
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins platform/discord Discord bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 7, 2026
@teknium1
teknium1 merged commit 87be36c into main Jul 7, 2026
31 checks passed
@teknium1
teknium1 deleted the salvage/54969-discord-utf16-labels branch July 7, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have platform/discord Discord bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord component labels use code-point slicing instead of UTF-16 limits

3 participants