Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(mobile): localize run failure-reason badges (MUL-9689) (#11029)

Jiayuan Zhang6c29fcb5f4ac
diff --git a/apps/mobile/lib/run-failure-badge.test.ts b/apps/mobile/lib/run-failure-badge.test.ts
index 5f592f9cef..97b8b1b350 100644
--- a/apps/mobile/lib/run-failure-badge.test.ts
+++ b/apps/mobile/lib/run-failure-badge.test.ts
@@ -1,9 +1,18 @@
import { describe, expect, it } from "vitest";
+import issuesEn from "../locales/en/issues.json";
+import issuesZhHans from "../locales/zh-Hans/issues.json";
+import issuesZhHant from "../locales/zh-Hant/issues.json";
import { i18n } from "./i18n/singleton";
-import { runFailureBadgeLabel } from "./run-failure-badge";
+import {
+ FAILURE_BADGE_REASONS,
+ failureBadgeKey,
+ runFailureBadgeLabel,
+} from "./run-failure-badge";
const tEn = i18n.getFixedT("en", "issues");
+const tZhHans = i18n.getFixedT("zh-Hans", "issues");
+const tZhHant = i18n.getFixedT("zh-Hant", "issues");
describe("runFailureBadgeLabel", () => {
it("names the reasons the backend classifies today", () => {
@@ -24,35 +33,61 @@ describe("runFailureBadgeLabel", () => {
);
});
- it("names a deleted project folder in the reader's language", () => {
+ it("names the reason in the reader's language", () => {
expect(runFailureBadgeLabel("local_directory_missing", tEn)).toBe(
"Folder missing",
);
+ expect(runFailureBadgeLabel("local_directory_missing", tZhHans)).toBe(
+ "文件夹不存在",
+ );
+ expect(runFailureBadgeLabel("local_directory_missing", tZhHant)).toBe(
+ "資料夾不存在",
+ );
+
expect(
- runFailureBadgeLabel(
- "local_directory_missing",
- i18n.getFixedT("zh-Hans", "issues"),
- ),
- ).toBe("文件夹不存在");
+ runFailureBadgeLabel("agent_error.provider_capacity_or_rate_limit", tZhHans),
+ ).toBe("触发限流");
expect(
- runFailureBadgeLabel(
- "local_directory_missing",
- i18n.getFixedT("zh-Hant", "issues"),
- ),
- ).toBe("資料夾不存在");
+ runFailureBadgeLabel("agent_error.provider_capacity_or_rate_limit", tZhHant),
+ ).toBe("觸發限流");
+ expect(runFailureBadgeLabel("runtime_access_denied", tZhHans)).toBe(
+ "无运行时权限",
+ );
+ expect(runFailureBadgeLabel("runtime_access_denied", tZhHant)).toBe(
+ "無執行時權限",
+ );
});
it("keeps the pre-MUL-1949 coarse values readable", () => {
expect(runFailureBadgeLabel("agent_error", tEn)).toBe("Agent error");
expect(runFailureBadgeLabel("manual", tEn)).toBe("Manual");
+ expect(runFailureBadgeLabel("manual", tZhHans)).toBe("手动取消");
+ expect(runFailureBadgeLabel("manual", tZhHant)).toBe("手動取消");
});
it("degrades to no badge for a reason newer than this build", () => {
// The row renders a bare status word instead. Unlike web, a compact badge
// has no room for the raw wire value, so silence is the fallback — but it
// must be a miss on THIS map, not a value the parser threw away upstream.
- expect(runFailureBadgeLabel("some_future_reason", tEn)).toBeUndefined();
- expect(runFailureBadgeLabel(undefined, tEn)).toBeUndefined();
- expect(runFailureBadgeLabel("", tEn)).toBeUndefined();
+ for (const t of [tEn, tZhHans, tZhHant]) {
+ expect(runFailureBadgeLabel("some_future_reason", t)).toBeUndefined();
+ expect(runFailureBadgeLabel(undefined, t)).toBeUndefined();
+ expect(runFailureBadgeLabel("", t)).toBeUndefined();
+ }
+ });
+
+ // Read the raw bundles rather than going through `t`: i18next falls back to
+ // English, which would hide a reason missing from a Chinese bundle.
+ it.each([
+ ["en", issuesEn],
+ ["zh-Hans", issuesZhHans],
+ ["zh-Hant", issuesZhHant],
+ ])("translates every known reason in %s, and nothing else", (_locale, bundle) => {
+ const badges: Record<string, string> = bundle.runs.failure_badge;
+ const expected = [...FAILURE_BADGE_REASONS].map(failureBadgeKey).sort();
+ expect(Object.keys(badges).sort()).toEqual(expected);
+ for (const key of expected) {
+ expect(badges[key], key).toMatch(/\S/);
+ }
});
});
diff --git a/apps/mobile/lib/run-failure-badge.ts b/apps/mobile/lib/run-failure-badge.ts
index 4838b20d83..f8bd2bf6a1 100644
--- a/apps/mobile/lib/run-failure-badge.ts
+++ b/apps/mobile/lib/run-failure-badge.ts
@@ -1,11 +1,10 @@
-import { RUNTIME_ACCESS_DENIED_BADGE } from "./runtime-access-copy";
-
/**
* Short badge copy for a run's `failure_reason`, shown inline on the agent-runs
* row next to the status word and a timestamp.
*
* Deliberately terser than `lib/failure-reason-label.ts`, which backs a
- * full-width chat bubble; this one shares a single line.
+ * full-width chat bubble; this one shares a single line. The copy lives in the
+ * `issues` namespace under `runs.failure_badge.*`.
*
* Keyed by the raw wire value, not a closed enum: `failure_reason` is an open
* string that grows as classifier rules land, and an installed build will meet
@@ -18,54 +17,58 @@ import { RUNTIME_ACCESS_DENIED_BADGE } from "./runtime-access-copy";
* copy that no run could reach, because AgentTaskSchema was erasing every
* refined reason before the row ever looked one up. A map no test can see is
* how that goes unnoticed.
+ *
+ * Must stay in lockstep with `runs.failure_badge` in every locale bundle; the
+ * drift test in `run-failure-badge.test.ts` enforces it.
*/
-const FAILURE_REASON_BADGE: Record<string, string> = {
- queued_expired: "Queue expired",
- runtime_offline: "Runtime offline",
- runtime_access_revoked: "Access revoked",
- runtime_recovery: "Runtime recovery",
- timeout: "Timeout",
- iteration_limit: "Iteration limit",
- agent_blocked: "Needs input",
- api_invalid_request: "Request rejected",
- skill_bundle_unavailable: "Skill download failed",
- runtime_cli_timeout: "Runtime CLI timeout",
- environment_prepare_failed: "Environment setup failed",
- runtime_access_denied: RUNTIME_ACCESS_DENIED_BADGE,
+export const FAILURE_BADGE_REASONS = new Set([
+ "queued_expired",
+ "runtime_offline",
+ "runtime_access_revoked",
+ "runtime_recovery",
+ "timeout",
+ "iteration_limit",
+ "agent_blocked",
+ "api_invalid_request",
+ "skill_bundle_unavailable",
+ "runtime_cli_timeout",
+ "environment_prepare_failed",
+ "runtime_access_denied",
+ "local_directory_missing",
- "agent_error.provider_auth_or_access": "Auth failed",
- "agent_error.provider_quota_limit": "Quota exhausted",
- "agent_error.provider_capacity_or_rate_limit": "Rate limited",
- "agent_error.provider_server_error": "Provider error",
- "agent_error.provider_network": "Network error",
- "agent_error.process_failure": "Process crashed",
- "agent_error.empty_or_unparseable_output": "No usable output",
- "agent_error.agent_timeout": "Agent timeout",
- "agent_error.context_overflow": "Context overflow",
- "agent_error.missing_config": "Config missing",
- "agent_error.model_not_found_or_unavailable": "Model unavailable",
- "agent_error.runtime_version_unsupported": "CLI unsupported",
- "agent_error.runtime_missing_executable": "CLI not installed",
- "agent_error.unknown": "Agent error",
+ "agent_error.provider_auth_or_access",
+ "agent_error.provider_quota_limit",
+ "agent_error.provider_capacity_or_rate_limit",
+ "agent_error.provider_server_error",
+ "agent_error.provider_network",
+ "agent_error.process_failure",
+ "agent_error.empty_or_unparseable_output",
+ "agent_error.agent_timeout",
+ "agent_error.context_overflow",
+ "agent_error.missing_config",
+ "agent_error.model_not_found_or_unavailable",
+ "agent_error.runtime_version_unsupported",
+ "agent_error.runtime_missing_executable",
+ "agent_error.unknown",
- agent_error: "Agent error",
- codex_semantic_inactivity: "Codex inactivity",
- manual: "Manual",
-};
+ "agent_error",
+ "codex_semantic_inactivity",
+ "manual",
+]);
/**
- * Reasons whose badge copy lives in the `issues` namespace
- * (`runs.failure_badge.*`) rather than in the English-only map above.
+ * i18next treats `.` as a nesting separator, so refined wire reasons
+ * (`agent_error.provider_network`) are stored as flat snake_case keys, the
+ * same convention as `failure_reason.*` in the chat bundle.
*/
-const LOCALIZED_FAILURE_REASON_BADGE = new Set(["local_directory_missing"]);
+export function failureBadgeKey(reason: string): string {
+ return reason.replaceAll(".", "_");
+}
export function runFailureBadgeLabel(
reason: string | null | undefined,
t: (key: string) => string,
): string | undefined {
- if (!reason) return undefined;
- if (LOCALIZED_FAILURE_REASON_BADGE.has(reason)) {
- return t(`runs.failure_badge.${reason}`);
- }
- return FAILURE_REASON_BADGE[reason];
+ if (!reason || !FAILURE_BADGE_REASONS.has(reason)) return undefined;
+ return t(`runs.failure_badge.${failureBadgeKey(reason)}`);
}
diff --git a/apps/mobile/lib/runtime-access-copy.ts b/apps/mobile/lib/runtime-access-copy.ts
index df942945c2..d74e646c9d 100644
--- a/apps/mobile/lib/runtime-access-copy.ts
+++ b/apps/mobile/lib/runtime-access-copy.ts
@@ -3,5 +3,3 @@
// locale bundles.
export const RUNTIME_ACCESS_DENIED_RECOVERY_COPY =
"This agent can't run on its private runtime. Make the runtime public, or rebind/copy the agent to a runtime its owner can use.";
-
-export const RUNTIME_ACCESS_DENIED_BADGE = "No runtime access";
diff --git a/apps/mobile/locales/en/issues.json b/apps/mobile/locales/en/issues.json
index f0543568e8..be585cb7a5 100644
--- a/apps/mobile/locales/en/issues.json
+++ b/apps/mobile/locales/en/issues.json
@@ -277,7 +277,36 @@
"cancelled": "Cancelled"
},
"failure_badge": {
- "local_directory_missing": "Folder missing"
+ "queued_expired": "Queue expired",
+ "runtime_offline": "Runtime offline",
+ "runtime_access_revoked": "Access revoked",
+ "runtime_recovery": "Runtime recovery",
+ "timeout": "Timeout",
+ "iteration_limit": "Iteration limit",
+ "agent_blocked": "Needs input",
+ "api_invalid_request": "Request rejected",
+ "skill_bundle_unavailable": "Skill download failed",
+ "runtime_cli_timeout": "Runtime CLI timeout",
+ "environment_prepare_failed": "Environment setup failed",
+ "runtime_access_denied": "No runtime access",
+ "local_directory_missing": "Folder missing",
+ "agent_error_provider_auth_or_access": "Auth failed",
+ "agent_error_provider_quota_limit": "Quota exhausted",
+ "agent_error_provider_capacity_or_rate_limit": "Rate limited",
+ "agent_error_provider_server_error": "Provider error",
+ "agent_error_provider_network": "Network error",
+ "agent_error_process_failure": "Process crashed",
+ "agent_error_empty_or_unparseable_output": "No usable output",
+ "agent_error_agent_timeout": "Agent timeout",
+ "agent_error_context_overflow": "Context overflow",
+ "agent_error_missing_config": "Config missing",
+ "agent_error_model_not_found_or_unavailable": "Model unavailable",
+ "agent_error_runtime_version_unsupported": "CLI unsupported",
+ "agent_error_runtime_missing_executable": "CLI not installed",
+ "agent_error_unknown": "Agent error",
+ "agent_error": "Agent error",
+ "codex_semantic_inactivity": "Codex inactivity",
+ "manual": "Manual"
}
},
"header_filter": "Filter",
diff --git a/apps/mobile/locales/zh-Hans/issues.json b/apps/mobile/locales/zh-Hans/issues.json
index 50d7939dee..dda0f006d1 100644
--- a/apps/mobile/locales/zh-Hans/issues.json
+++ b/apps/mobile/locales/zh-Hans/issues.json
@@ -273,7 +273,36 @@
"cancelled": "已取消"
},
"failure_badge": {
- "local_directory_missing": "文件夹不存在"
+ "queued_expired": "排队超时",
+ "runtime_offline": "运行时离线",
+ "runtime_access_revoked": "权限已撤销",
+ "runtime_recovery": "运行时重启",
+ "timeout": "超时",
+ "iteration_limit": "迭代达上限",
+ "agent_blocked": "需要输入",
+ "api_invalid_request": "请求被拒",
+ "skill_bundle_unavailable": "skill 下载失败",
+ "runtime_cli_timeout": "运行时 CLI 超时",
+ "environment_prepare_failed": "环境准备失败",
+ "runtime_access_denied": "无运行时权限",
+ "local_directory_missing": "文件夹不存在",
+ "agent_error_provider_auth_or_access": "认证失败",
+ "agent_error_provider_quota_limit": "配额已用尽",
+ "agent_error_provider_capacity_or_rate_limit": "触发限流",
+ "agent_error_provider_server_error": "提供商出错",
+ "agent_error_provider_network": "网络错误",
+ "agent_error_process_failure": "进程崩溃",
+ "agent_error_empty_or_unparseable_output": "无可用输出",
+ "agent_error_agent_timeout": "智能体超时",
+ "agent_error_context_overflow": "上下文超限",
+ "agent_error_missing_config": "缺少配置",
+ "agent_error_model_not_found_or_unavailable": "模型不可用",
+ "agent_error_runtime_version_unsupported": "CLI 版本不支持",
+ "agent_error_runtime_missing_executable": "未安装 CLI",
+ "agent_error_unknown": "智能体出错",
+ "agent_error": "智能体出错",
+ "codex_semantic_inactivity": "Codex 无进展",
+ "manual": "手动取消"
}
},
"header_filter": "筛选",
diff --git a/apps/mobile/locales/zh-Hant/issues.json b/apps/mobile/locales/zh-Hant/issues.json
index 35e59387bf..40b5d938e5 100644
--- a/apps/mobile/locales/zh-Hant/issues.json
+++ b/apps/mobile/locales/zh-Hant/issues.json
@@ -273,7 +273,36 @@
"cancelled": "已取消"
},
"failure_badge": {
- "local_directory_missing": "資料夾不存在"
+ "queued_expired": "排隊超時",
+ "runtime_offline": "執行時離線",
+ "runtime_access_revoked": "權限已撤銷",
+ "runtime_recovery": "執行時重啟",
+ "timeout": "超時",
+ "iteration_limit": "迭代達上限",
+ "agent_blocked": "需要輸入",
+ "api_invalid_request": "請求被拒",
+ "skill_bundle_unavailable": "skill 下載失敗",
+ "runtime_cli_timeout": "執行時 CLI 超時",
+ "environment_prepare_failed": "環境準備失敗",
+ "runtime_access_denied": "無執行時權限",
+ "local_directory_missing": "資料夾不存在",
+ "agent_error_provider_auth_or_access": "認證失敗",
+ "agent_error_provider_quota_limit": "配額已用盡",
+ "agent_error_provider_capacity_or_rate_limit": "觸發限流",
+ "agent_error_provider_server_error": "提供商出錯",
+ "agent_error_provider_network": "網路錯誤",
+ "agent_error_process_failure": "程序崩潰",
+ "agent_error_empty_or_unparseable_output": "無可用輸出",
+ "agent_error_agent_timeout": "AI 代理超時",
+ "agent_error_context_overflow": "上下文超限",
+ "agent_error_missing_config": "缺少配置",
+ "agent_error_model_not_found_or_unavailable": "模型不可用",
+ "agent_error_runtime_version_unsupported": "CLI 版本不支援",
+ "agent_error_runtime_missing_executable": "未安裝 CLI",
+ "agent_error_unknown": "AI 代理出錯",
+ "agent_error": "AI 代理出錯",
+ "codex_semantic_inactivity": "Codex 無進展",
+ "manual": "手動取消"
}
},
"header_filter": "篩選",