Skip to content

feat(sight): make dashboard UI bilingual (en/zh) - #2612

Merged
chengshuyi merged 3 commits into
alibaba:mainfrom
Daydreamer-Li:feature/sight/dashboard-i18n
Aug 18, 2026
Merged

feat(sight): make dashboard UI bilingual (en/zh)#2612
chengshuyi merged 3 commits into
alibaba:mainfrom
Daydreamer-Li:feature/sight/dashboard-i18n

Conversation

@Daydreamer-Li

Copy link
Copy Markdown
Collaborator

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:

  • A typed message catalog (~930 keys) with MessageKey = keyof typeof enUSMessages,
    so a key missing from either locale is a compile error rather than a runtime
    fallback. t() supports {placeholder} interpolation.
  • Constant label maps become MessageKey lookup tables resolved at render time;
    non-React helpers receive t as a parameter instead of owning strings.
  • Date formatting moves to shared utils/datetime.ts helpers taking a locale tag,
    replacing four duplicated implementations and two hardcoded locales.
  • Interruption type labels are consolidated into a single INTERRUPTION_TYPE_KEY
    map exported from i18n.tsx, replacing the Chinese-only INTERRUPTION_TYPE_CN
    in apiClient so filters and evaluation findings localize consistently.
  • Language choice persists in localStorage with browser-language fallback, and
    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

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Performance improvement
  • CI/CD or build changes

Scope

  • sight (agentsight)

Checklist

  • I have read the Contributing Guide
  • My code follows the project's code style
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the documentation accordingly
  • For sight: cargo clippy -- -D warnings and cargo fmt --check pass
  • Lock files are up to date (Cargo.lock)

Testing

Frontend:

  • npx tsc --noEmit — 0 errors
  • npm run test:i18n — 5 passed (includes a new test asserting every message key
    uses 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 new
    utils/datetime.ts helpers (locale sensitivity, for null timestamps),
    fmtTime honoring the caller-provided locale, and securityDetailRows
    returning stable ids plus message keys
  • npm run build — webpack production build succeeds

Rust:

  • cargo fmt --all --check — clean
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo test --locked token_savings — 40 passed

Manual: 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 compiled
containmentLifecycle.ts without --jsx, which fails once that file type-imports
from 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 intentional
exceptions are documented in the review: backend-provided data values in
types/optimization.ts are mapped at the presentation layer, and unknown values
fall through unchanged so the API contract stays untouched.

@qoderai qoderai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本次变更的 AgentSight Dashboard i18n 整体结构合理,typed message key 方案也符合组件规则。审查中主要看到少数调用处未完全跟进新的结构或错误信息与可读性存在小缺口,已在 3 处标注具体触发条件与建议修复方式。


🤖 Generated by QoderView workflow run

Comment thread src/agentsight/dashboard/src/pages/security/TimelineItem.tsx
Comment thread src/agentsight/dashboard/src/pages/security/utils.ts
Comment thread src/agentsight/dashboard/src/components/InterruptionBadge.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/agentsight/dashboard/src/pages/OptimizationPage.tsx Outdated
Comment thread src/agentsight/dashboard/src/pages/AtifViewerPage.tsx
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>
@Daydreamer-Li
Daydreamer-Li force-pushed the feature/sight/dashboard-i18n branch from 17834a7 to 6bcd058 Compare August 17, 2026 11:58

@chengshuyi chengshuyi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 类型安全的 i18n 架构设计合理,placeholder 一致性测试补上了 tsc 盲区,datetime.ts 消除了重复和硬编码 locale。

Follow-up suggestions (non-blocking):

  1. i18n.tsx 已达 2167 行,建议后续拆分为 messages/en-US.ts + messages/zh-CN.ts + index.tsx
  2. token_savings.rs 的 strategy_label 建议后续改为后端返回 key、前端映射展示 label
  3. t() 中 regex 替换可选改为 replaceAll(nice-to-have)

@chengshuyi
chengshuyi merged commit 298a01f into alibaba:main Aug 18, 2026
30 checks passed
@Daydreamer-Li Daydreamer-Li mentioned this pull request Aug 18, 2026
9 tasks
viron-xiao added a commit to viron-xiao/anolisa that referenced this pull request Aug 24, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:sight src/agentsight/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sight] feat: bilingual (en/zh) dashboard UI

2 participants