Skip to content

feat(i18n): localize runtime user-facing copy - #90611

Closed
lanzhi-lee wants to merge 2 commits into
openclaw:mainfrom
lanzhi-lee:feature/runtime-i18n-user-copy
Closed

lanzhi-lee wants to merge 2 commits into
openclaw:mainfrom
lanzhi-lee:feature/runtime-i18n-user-copy

Conversation

@lanzhi-lee

@lanzhi-lee lanzhi-lee commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Localizes shared runtime/user-facing copy through the existing wizard i18n runtime translator and adds English, Simplified Chinese, and Traditional Chinese locale entries for the new runtime keys.

What changed

  • Added runtime copy keys under runtime.channel, runtime.gateway, and runtime.tui in the wizard i18n locale maps.
  • Routed shared agent/runtime reply copy through runtimeT(...), including rate limits, billing/capacity/overload errors, missing API keys, model login/switch failures, context overflow/compaction notices, fallback backend notices, gateway restart notices, memory flush failures, and LLM socket error formatting.
  • Localized gateway-facing reason strings for attachment availability, auth rate limiting, active-session reset/delete conflicts, and webchat media fallback display text.
  • Localized TUI thinking labels and session reset/new-session acknowledgements that are shared across runtime surfaces.
  • Preserved stable non-display behavior where other code consumes these strings: non-direct silent-reply routing now uses an explicit runner-failure flag, and iMessage, active-memory, and QA-lab classifiers recognize the localized runtime failure text they intentionally inspect.
  • Kept English defaults equivalent to the previous user-facing strings so existing behavior remains stable when OPENCLAW_LOCALE is unset or unsupported.

Boundary note

This PR originally scoped the implementation to core src/** runtime copy. During review, we found downstream consumers outside src that rely on static English user-visible runtime failure text as classification signals rather than stable metadata. Specifically, iMessage reflection detection, active-memory query cleanup, and QA-lab failure detection matched English runtime failure strings.

That is why the current PR includes narrow extensions/ classifier updates: they preserve existing behavior after core failure copy is localized. The PR does not migrate or rewrite plugin-owned product copy beyond those guards.

What this intentionally does not do

  • Does not migrate every command-specific response yet. /config, /plugins, /session, ACP, TTS, subagents, allowlist, export, diagnostics, and similar command help/status strings still have many command-owned literals.
  • Does not change plugin-owned product copy outside the classifier updates needed for localized shared runtime failure strings.
  • Does not introduce a new runtime i18n package or move the translator out of src/wizard/i18n; this follows the branch's existing runtime translator pattern.
  • Does not change protocol codes, gateway error type values, or behavioral branching contracts; user-visible text is translated while routing/classification decisions stay on stable metadata or explicit localized classifier contracts.
  • Does not include an agent transcript section in this PR body.

Real behavior proof

Behavior addressed: Shared runtime and gateway user-visible strings now resolve through locale-aware i18n keys for English, Simplified Chinese, and Traditional Chinese, while localized failure text still preserves existing non-direct suppression and downstream failure classifiers.

Real environment tested: Local Codex worktree on macOS after rebasing this branch onto latest upstream/main.

Exact steps or command run after this patch:

node --import tsx - <<'NODE'
import { buildKnownAgentRunFailureReplyPayload, buildPreflightCompactionFailureText } from './src/auto-reply/reply/agent-runner-execution.ts';
import { t } from './src/wizard/i18n/index.ts';
for (const locale of ['en', 'zh-CN', 'zh-TW']) {
  process.env.OPENCLAW_LOCALE = locale;
  const missingApiKey = buildKnownAgentRunFailureReplyPayload({
    err: new Error('No API key found for provider "openai". You are authenticated with OpenAI Codex OAuth.'),
    sessionCtx: { Provider: 'whatsapp', MessageSid: 'proof' },
    resolvedVerboseLevel: 'off',
  });
  console.log(`locale=${locale}`);
  console.log(`generic=${t('runtime.channel.genericExternalRunFailure')}`);
  console.log(`missingApiKey=${missingApiKey?.text}`);
  console.log(`preflight=${buildPreflightCompactionFailureText('Preflight compaction required but failed: proof reason', { includeDetails: true })}`);
  console.log('---');
}
NODE

git diff --check
./node_modules/.bin/oxfmt --check extensions/qa-lab/src/reply-failure.ts extensions/qa-lab/src/reply-failure.test.ts extensions/active-memory/index.ts extensions/active-memory/index.test.ts src/auto-reply/reply/agent-runner-execution.ts src/auto-reply/reply/agent-runner-execution.test.ts extensions/imessage/src/monitor/reflection-guard.ts extensions/imessage/src/monitor/reflection-guard.test.ts
node scripts/run-vitest.mjs extensions/qa-lab/src/reply-failure.test.ts extensions/active-memory/index.test.ts src/auto-reply/reply/agent-runner-execution.test.ts extensions/imessage/src/monitor/reflection-guard.test.ts src/wizard/i18n/index.test.ts
.agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/main

Evidence after fix: The runtime proof command printed English, zh-CN, and zh-TW output from the actual runtime translation and failure-formatting paths. Example output was:

locale=en
generic=⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.
missingApiKey=⚠️ Missing API key for OpenAI on the gateway. Use `openai/gpt-5.5` with the OpenAI OAuth profile, or set `OPENAI_API_KEY` for direct OpenAI API-key runs.
preflight=⚠️ Context is too large and auto-compaction could not recover this turn. Reason: proof reason. Try again, use /compact, or use /new to start a fresh session.
---
locale=zh-CN
generic=⚠️ 处理你的请求时出了问题。请重试,或使用 /new 开始一个新会话。
missingApiKey=⚠️ Gateway 缺少 OpenAI API Key。请使用带 OpenAI OAuth profile 的 `openai/gpt-5.5`,或为直接 OpenAI API Key 运行设置 `OPENAI_API_KEY`。
preflight=⚠️ 上下文过大,自动压缩未能恢复本轮。 原因:proof reason。 请重试,使用 /compact,或使用 /new 开始一个新会话。
---
locale=zh-TW
generic=⚠️ 處理你的請求時發生問題。請重試,或使用 /new 開始新工作階段。
missingApiKey=⚠️ Gateway 缺少 OpenAI API Key。請使用帶 OpenAI OAuth profile 的 `openai/gpt-5.5`,或為直接 OpenAI API Key 執行設定 `OPENAI_API_KEY`。
preflight=⚠️ 上下文過大,自動壓縮未能恢復本輪。 原因:proof reason。 請重試,使用 /compact,或使用 /new 開始新工作階段。
---

Observed result after fix: Default English output remains equivalent to the previous strings, zh-CN/zh-TW runtime output is localized, and the focused regression tests confirm localized failure strings still participate in silent-reply suppression, iMessage reflection detection, active-memory query cleanup, and QA-lab failure detection.

What was not tested: Full pnpm check, broad CI, live provider turns, and every command-specific text command surface were not run as part of this focused copy migration.

Verification

  • git diff --check
  • ./node_modules/.bin/oxfmt --check extensions/qa-lab/src/reply-failure.ts extensions/qa-lab/src/reply-failure.test.ts extensions/active-memory/index.ts extensions/active-memory/index.test.ts src/auto-reply/reply/agent-runner-execution.ts src/auto-reply/reply/agent-runner-execution.test.ts extensions/imessage/src/monitor/reflection-guard.ts extensions/imessage/src/monitor/reflection-guard.test.ts
  • node scripts/run-vitest.mjs extensions/qa-lab/src/reply-failure.test.ts extensions/active-memory/index.test.ts src/auto-reply/reply/agent-runner-execution.test.ts extensions/imessage/src/monitor/reflection-guard.test.ts src/wizard/i18n/index.test.ts
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/main -> clean, no accepted/actionable findings

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: L triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 5, 2026
@clawsweeper

clawsweeper Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed June 25, 2026, 7:46 PM ET / 23:46 UTC.

Summary
The PR routes shared runtime, gateway, TUI, and selected classifier-facing user copy through the existing wizard i18n maps for English, Simplified Chinese, and Traditional Chinese.

PR surface: Source +421, Tests +102. Total +523 across 35 files.

Reproducibility: not applicable. this is a localization feature PR rather than a bug report. The merge blocker is source-proven by comparing the PR head against current-main billing behavior and tests.

Review metrics: 1 noteworthy metric.

  • Runtime Locale Namespaces: 3 added across 3 locale maps. The PR adds channel, gateway, and TUI runtime copy for en, zh-CN, and zh-TW, which makes display-versus-contract boundaries important before merge.

Stored data model
Persistent data-model change detected: migration/backfill/repair: extensions/imessage/src/monitor/reflection-guard.test.ts, migration/backfill/repair: extensions/qa-lab/src/reply-failure.test.ts, serialized state: src/gateway/server-methods/sessions.ts, serialized state: src/gateway/session-reset-service.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

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

Rank-up moves:

  • Preserve the current-main authMode parameter and OAuth/token neutral billing copy while localizing both subscription and API-key branches.
  • Refresh the branch against current main and resolve the reported CONFLICTING/DIRTY merge state.
  • Get maintainer confirmation that localized gateway JSON message/reason fields are display-only, or keep those protocol-facing strings stable.

Risk before merge

  • [P1] Current PR head drops the authMode-aware billing copy contract, so OAuth/token subscription users could again see API-key top-up guidance.
  • [P1] Gateway JSON error.message and media reason fields become locale-dependent; maintainers should confirm those fields are display-only or keep protocol-facing text stable.
  • [P2] Failure classifiers in iMessage, active-memory, and QA-lab still depend on localized display strings, so future translation edits or added locales could affect suppression, reflection detection, query cleanup, or QA failure detection.
  • [P1] Live GitHub metadata reports the branch as CONFLICTING/DIRTY, so this is not yet a landable merge result.

Maintainer options:

  1. Refresh And Preserve Current Contracts (recommended)
    Rebase or otherwise refresh the branch, keep authMode-specific OAuth/token billing copy, and either keep gateway JSON message/reason strings stable or get maintainer confirmation that they are display-only.
  2. Accept Localized Display Fields
    Maintainers may intentionally accept locale-dependent gateway reason/message text if stable code/type fields are the only supported client contract and broader gates pass.
  3. Pause Runtime I18n Scope
    If runtime/gateway localization is not a confirmed product direction yet, pause this PR and continue narrower Control UI or setup-localization work in the existing i18n trackers.

Next step before merge

  • [P2] A repair worker can preserve the current-main authMode billing contract on the PR branch, but gateway display-field compatibility still needs maintainer review after that repair.

Security
Cleared: The diff changes runtime copy, locale maps, and classifier guards without new dependencies, workflow changes, package resolution changes, secret handling, or executable supply-chain surface.

Review findings

  • [P1] Preserve auth-mode billing copy while localizing — src/agents/embedded-agent-helpers/sanitize-user-facing-text.ts:39
Review details

Best possible solution:

Refresh the branch on current main, preserve localized authMode-specific billing behavior, and land runtime locale keys only after gateway display-field compatibility is either confirmed or kept stable at protocol boundaries.

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

Not applicable: this is a localization feature PR rather than a bug report. The merge blocker is source-proven by comparing the PR head against current-main billing behavior and tests.

Is this the best way to solve the issue?

No. Reusing the existing wizard translator is a plausible direction, but the submitted branch is not the best merge shape until it preserves the current authMode billing contract and resolves gateway display-field compatibility.

Full review comments:

  • [P1] Preserve auth-mode billing copy while localizing — src/agents/embedded-agent-helpers/sanitize-user-facing-text.ts:39
    Current main's formatBillingErrorMessage accepts authMode and returns neutral OAuth/token copy from fix(agents): use neutral billing copy for subscription auth #93763. This PR head rewrites the formatter back to provider/model-only localized API-key copy, and the assistant-error callers no longer pass authMode, so subscription users would again be told to top up an API key unless the authMode branch and tests are preserved.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a broad but bounded localization feature affecting runtime copy, gateway display text, and classifier behavior without evidence of an urgent production outage.
  • merge-risk: 🚨 compatibility: The branch overlaps current-main OAuth/token billing behavior and localizes gateway JSON message/reason fields that existing clients may consume.
  • merge-risk: 🚨 message-delivery: The PR changes failure text consumed by silent-reply suppression, iMessage reflection detection, active-memory cleanup, and QA-lab failure detection.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body includes after-fix terminal output from actual runtime translation and failure-formatting paths for en, zh-CN, and zh-TW, plus focused regression tests for affected classifiers.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from actual runtime translation and failure-formatting paths for en, zh-CN, and zh-TW, plus focused regression tests for affected classifiers.
Evidence reviewed

PR surface:

Source +421, Tests +102. Total +523 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 31 548 127 +421
Tests 4 102 0 +102
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 650 127 +523

Acceptance criteria:

  • [P1] git diff --check.
  • [P1] node scripts/run-vitest.mjs src/agents/embedded-agent-helpers.formatassistanterrortext.test.ts src/agents/embedded-agent-runner/run/assistant-failover.test.ts src/agents/embedded-agent-runner/run/payloads.errors.test.ts src/auto-reply/reply/agent-runner-execution.test.ts src/wizard/i18n/index.test.ts.

What I checked:

Likely related people:

  • eldar702: AuthMode-specific neutral billing behavior was authored in the merged billing-copy PR that this branch overlaps. (role: recent adjacent contributor; confidence: high; commits: 1daff3f514b1, 7c97c6da9bfa; files: src/agents/embedded-agent-helpers/sanitize-user-facing-text.ts, src/agents/embedded-agent-helpers/errors.ts, src/agents/embedded-agent-runner/run/payloads.ts)
  • vincentkoc: Live PR metadata shows vincentkoc merged the billing-copy PR, and the merge commit records Vincent Koc as co-author. (role: merger and co-author of adjacent billing behavior; confidence: high; commits: 7c97c6da9bfa; files: src/agents/embedded-agent-helpers/sanitize-user-facing-text.ts, src/agents/embedded-agent-helpers.formatassistanterrortext.test.ts)
  • GaosCode: Merged PR feat(wizard): add CLI onboarding i18n #80645 added the wizard i18n runtime and locale files reused by this PR. (role: adjacent i18n feature contributor; confidence: medium; commits: d24a847279a2; files: src/wizard/i18n/index.ts, src/wizard/i18n/locales/en.ts, src/wizard/i18n/locales/zh-CN.ts)
  • steipete: Live PR metadata shows steipete merged the CLI onboarding i18n PR that introduced the translator surface this PR extends. (role: merger of adjacent i18n work; confidence: medium; commits: d24a847279a2; files: src/wizard/i18n/index.ts, src/plugin-sdk/setup-runtime.ts, docs/start/wizard.md)
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.

@lanzhi-lee lanzhi-lee changed the title Localize runtime user-facing copy feat(i18n): localize runtime user-facing copy Jun 5, 2026
@lanzhi-lee
lanzhi-lee force-pushed the feature/runtime-i18n-user-copy branch from 20e669b to 73f5ca2 Compare June 5, 2026 09:26
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 5, 2026
@lanzhi-lee
lanzhi-lee force-pushed the feature/runtime-i18n-user-copy branch from 73f5ca2 to a6d2846 Compare June 5, 2026 11:53
@openclaw-barnacle openclaw-barnacle Bot added channel: imessage Channel integration: imessage extensions: qa-lab labels Jun 5, 2026
@lanzhi-lee

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the branch after the review:

  • Replaced localized failure silent-routing checks with an explicit runner-failure policy flag.
  • Updated iMessage reflection, active-memory query cleanup, and QA-lab failure classifiers for localized runtime failure copy.
  • Added redacted terminal output proof for en, zh-CN, and zh-TW runtime failure text in the PR body.
  • Re-ran focused tests, format/diff checks, and branch autoreview; branch autoreview is clean.

@clawsweeper

clawsweeper Bot commented Jun 5, 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.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 5, 2026
@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: 🧂 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. labels Jun 5, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 8, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 19, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 30, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: imessage Channel integration: imessage extensions: qa-lab gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant