Skip to content

fix(i18n): emit bot expected-result codes from producers - #4639

Open
orangeCatDeveloper wants to merge 5 commits into
apache:mainfrom
orangeCatDeveloper:fix/locale-bot-codes
Open

fix(i18n): emit bot expected-result codes from producers#4639
orangeCatDeveloper wants to merge 5 commits into
apache:mainfrom
orangeCatDeveloper:fix/locale-bot-codes

Conversation

@orangeCatDeveloper

@orangeCatDeveloper orangeCatDeveloper commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Bot producers (bot-test error/hint pairs, bot-events replies and status reasons, wechat-bridge setup hints, bot onboarding) emitted zh-only strings, so English users either saw Chinese or — where the bot settings pages guarded with /[㐀-鿿]/ content sniffing — silently lost the information. Producers now emit stable machine codes; settings-bot-copy maps each union exhaustively per locale with an explicit unknown-code fallback, and the zh-passthrough gates in the bot settings pages are gone. zh copy moved verbatim, en copy is new. Bot platform display names and zh command keyword sets are protocol/matching data and are untouched; bot-channel notices follow the bot audience language and are annotated rather than re-plumbed.

packages/core/redaction.ts is restructured on the way: the keyword classifier becomes classifyGeneralizedError() → GeneralizedErrorClass (bot onboarding emits the class as its code), and the two hand-mirrored en/zh message maps collapse into one UiCatalog<Record<GeneralizedErrorClass, string>> behind generalizedErrorMessageForLocale(…, locale). generalizedErrorMessage stays as the en wrapper for its callers; the zh-CN and zh-TW wrappers are removed and their last caller goes through the locale form. Adding a locale now means adding one catalog block, not a third classifier.

Split out of #4551 so each PR is one reviewer context. main now ships generalizedErrorMessageForLocale; this PR keeps its signature and adds the exported classifier and code union.

Allowlist warnings and help text are complete per-locale formatters rather than UI-assembled fragments. Each locale owns the three-ID preview and count wording: Chinese retains its total-count phrasing, while English now reports only the omitted IDs as remaining. The adjacent limit-reached help follows the same complete-message rule.

Refs #2672

Verification

workspace typecheck:                    0 errors
desktop main tests (dist):              1995 pass / 0 fail
packages/core tests:                    775 pass / 0 fail (incl. en+zh render via generalizedErrorMessageForLocale)
packages/runtime tests:                 3177 pass (5 sandbox-only filesystem-worker failures, unrelated)
CJK-sniff regexes in touched files:     0 remaining
rendered-output tests (en+zh):          bot connection-test codes — pass
biome (changed files):                  clean

Follow-up verification: 26 bot-detail rendering and settings-copy tests pass, including all three locales, empty lists, overflow counts, and the allowlist limit. Desktop build and all four typechecks, repository format/lint, and the renderer architecture check pass.

Four invalid IDs, with the first three shown:

Before:
These entries are not numeric IDs and may be usernames, so they will not match anyone: @alice, @bob, @carol and 4 more

After:
These entries are not numeric IDs and may be usernames, so they will not match anyone: @alice, @bob, @carol and 1 more

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code — analysis, implementation, tests, and this description, under the contributor's direction; the commit carries a Generated-by: Claude Code trailer.

OpenCode implemented the complete allowlist messages and count fix, added rendering tests, and updated this description; the follow-up commit carries Generated-by: OpenCode.

Checklist

  • Tests cover the change and fail without it

@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Sep 3, 2026
@orangeCatDeveloper
orangeCatDeveloper force-pushed the fix/locale-bot-codes branch 12 times, most recently from 1518efa to 560790e Compare September 5, 2026 04:58
@orangeCatDeveloper
orangeCatDeveloper force-pushed the fix/locale-bot-codes branch 2 times, most recently from dbe95db to ae17f95 Compare September 5, 2026 08:07
Bot test, onboarding, and bridge producers emitted zh prose that reached
en users verbatim, and the renderer sniffed CJK to decide whether to
show it. Producers now return stable codes; the settings-bot catalog
maps each code per locale with an explicit unknown fallback, and each
locale owns its complete allowlist warning and help messages.

Generated-by: Claude Code
Claude-Session: https://claude.ai/code/session_01AqdSkg56F2x55wEGRWvzcB
Keep platform-specific credential failures and transient errors distinct across probes, status updates, and onboarding. Present stable codes with localized fallbacks while retaining redacted diagnostics in logs.

Generated-by: OpenCode
Bridges reported missing credentials with legacy kebab reasons while the
connection test used snake codes for the same failures, so the presenter
carried alias entries for both spellings.

Generated-by: Claude Code
@orangeCatDeveloper
orangeCatDeveloper marked this pull request as ready for review September 5, 2026 12:19
@github-actions github-actions Bot added effort/XL Under 2500 readable lines and removed effort/L Under 1000 readable lines labels Sep 5, 2026
knip lists the desktop workspace's dependencies, and `typeof import()`
of undici and the Slack SDKs counted as unlisted ones.

Generated-by: Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant