feat(sight): make dashboard UI bilingual (en/zh) - #2612
Conversation
There was a problem hiding this comment.
本次变更的 AgentSight Dashboard i18n 整体结构合理,typed message key 方案也符合组件规则。审查中主要看到少数调用处未完全跟进新的结构或错误信息与可读性存在小缺口,已在 3 处标注具体触发条件与建议修复方式。
🤖 Generated by Qoder • View workflow run
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17834a770a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Replace hardcoded UI strings across dashboard pages, security views and
shared components with t() lookups backed by a ~470-key en-US/zh-CN
catalog. t() gains {placeholder} interpolation and useLocaleTag() drives
locale-aware date formatting, so switching language updates text and
dates without reload.
Constant label maps become MessageKey lookup tables resolved at render
time; non-React helpers receive t as a parameter instead of owning
hardcoded strings. Server-side token savings labels switch to English
because the API cannot know the client locale.
Known limitation: OptimizationPage, RiskEnforcementPage, SystemAuditPage,
SkillMetricsPage, AgentSessionsPage and related components still contain
hardcoded Chinese and will be migrated in a follow-up.
Signed-off-by: liyuqing <liyuqing@alibaba-inc.com>
Extend the i18n catalog to the optimization, sessions, risk enforcement, system audit, skill metrics and settings pages, plus the flame chart, containment and notifier components (~460 new keys). Interruption type labels move into a single INTERRUPTION_TYPE_KEY map exported from i18n.tsx, replacing the Chinese-only INTERRUPTION_TYPE_CN in apiClient so evaluation findings and filter dropdowns localize consistently. Backend-provided literal values (e.g. confidence grades) are mapped at render time only; unknown values fall through unchanged since the API contract stays untouched. LLM-generated analysis text (symptoms, root causes) remains in its original language — localizing it requires locale-aware generation on the server side. Signed-off-by: liyuqing <liyuqing@alibaba-inc.com>
Review follow-ups for the dashboard i18n work: consolidate four
copies of nanosecond timestamp formatting into utils/datetime.ts, drop
the last hardcoded zh-CN locale in the security fmtTime helper, and
localize the security detail-row labels via MessageKey instead of raw
lowercase field names.
Also unify inconsistent zh translations, remove the unused common.saved
key, and add a placeholder-consistency regression test: tsc already
guarantees key alignment across locales, but a missing {n} in one
translation is invisible to the type system.
Signed-off-by: liyuqing <liyuqing@alibaba-inc.com>
17834a7 to
6bcd058
Compare
chengshuyi
left a comment
There was a problem hiding this comment.
LGTM. 类型安全的 i18n 架构设计合理,placeholder 一致性测试补上了 tsc 盲区,datetime.ts 消除了重复和硬编码 locale。
Follow-up suggestions (non-blocking):
- i18n.tsx 已达 2167 行,建议后续拆分为 messages/en-US.ts + messages/zh-CN.ts + index.tsx
- token_savings.rs 的 strategy_label 建议后续改为后端返回 key、前端映射展示 label
- t() 中 regex 替换可选改为 replaceAll(nice-to-have)
Resolve merge conflicts in 4 AgentSight dashboard files after upstream main added i18n (alibaba#2612), LLM latency metrics (alibaba#2586), agent grouping, and no_port health handling. Union-merge preserves both sides: - ContainmentDialog: keep i18n rendering with brand-neutral kernelDeny key - AgentHealthPage: keep protection APIs + one-click enable/disable + default protection dir guard alongside LatencyMetricsRow and grouping - RiskEnforcementPage: keep mode badge coloring + pagination + cross-page linking on top of upstream i18n - SystemAuditPage: keep process tree + case filters + protection badges + pagination while adopting upstream localeTag/MessageKey APIs Verified: tsc --noEmit clean; product-branding, i18n, and api-client regression suites all pass.
Description
Makes the AgentSight dashboard fully bilingual (en-US / zh-CN). Previously every
page was hardcoded in Chinese, so non-Chinese users could not read agent health,
token savings, security observability, optimization, audit or settings pages.
Key implementation decisions:
MessageKey = keyof typeof enUSMessages,so a key missing from either locale is a compile error rather than a runtime
fallback.
t()supports{placeholder}interpolation.MessageKeylookup tables resolved at render time;non-React helpers receive
tas a parameter instead of owning strings.utils/datetime.tshelpers taking a locale tag,replacing four duplicated implementations and two hardcoded locales.
INTERRUPTION_TYPE_KEYmap exported from
i18n.tsx, replacing the Chinese-onlyINTERRUPTION_TYPE_CNin
apiClientso filters and evaluation findings localize consistently.switching updates
<html lang>plus the document title without a reload.Known trade-offs: server-generated token-savings labels switch to English because
the API cannot know the client locale, and LLM-generated analysis text keeps the
model's original language. Localizing either requires a locale-aware API contract,
which is intentionally out of scope here.
Related Issue
closes #2610
Type of Change
Scope
sight(agentsight)Checklist
sight:cargo clippy -- -D warningsandcargo fmt --checkpassCargo.lock)Testing
Frontend:
npx tsc --noEmit— 0 errorsnpm run test:i18n— 5 passed (includes a new test asserting every message keyuses an identical placeholder set across locales; tsc guarantees key alignment
but placeholder drift is invisible to the type system)
npm run test:api-client— 14 passed, up from 10: added unit tests for the newutils/datetime.tshelpers (locale sensitivity,—for null timestamps),fmtTimehonoring the caller-provided locale, andsecurityDetailRowsreturning stable ids plus message keys
npm run build— webpack production build succeedsRust:
cargo fmt --all --check— cleancargo clippy --all-targets -- -D warnings— cleancargo test --locked token_savings— 40 passedManual: deployed to a test host and verified switching EN/中文 updates all pages
(agent health, sessions, token savings, trajectory viewer, security, optimization,
risk enforcement, system audit, skill metrics, settings) without reload.
Also fixes a pre-existing break in
test:api-client: the runner compiledcontainmentLifecycle.tswithout--jsx, which fails once that file type-importsfrom
i18n.tsx, and one assertion still expected the pre-i18n Chinese literal.Additional Notes
Residual scanning confirms no UI-facing Chinese literals remain outside
i18n.tsx(the translation catalog itself) and code comments. Two intentionalexceptions are documented in the review: backend-provided data values in
types/optimization.tsare mapped at the presentation layer, and unknown valuesfall through unchanged so the API contract stays untouched.