Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(i18n): 完善 Studio 简体中文界面文案 (#4297)

Axiomothf926353e3ea2
diff --git a/web-studio/CONTRIBUTING.md b/web-studio/CONTRIBUTING.md
new file mode 100644
index 000000000..d23913418
--- /dev/null
+++ b/web-studio/CONTRIBUTING.md
@@ -0,0 +1,132 @@
+# Contributing to Web Studio Internationalization
+
+Web Studio supports English and Simplified Chinese. This guide is for contributors who add or change user-visible text in `web-studio`. A change is complete only when both languages are usable.
+
+Start by identifying where the text comes from:
+
+| Text Source | Required Treatment |
+| ----------------------------------------------------------- | -------------------------------------------------------------------------------------- |
+| Static interface copy | Add matching English and Simplified Chinese keys, then render with `t()` or `<Trans>`. |
+| Stable server enum, status, metric, or display header | Map the known value to an i18n key in a localization adapter. |
+| Model name, path, URI, identifier, command, or user content | Preserve the original value unless the product defines a display name. |
+| Raw server error or diagnostic payload | Localize the user-facing summary and keep the original detail available for diagnosis. |
+
+## Translation Resources
+
+From the repository root, translation resources live under:
+
+```text
+web-studio/src/i18n/locales/en/
+web-studio/src/i18n/locales/zh-CN/
+```
+
+`web-studio/src/i18n/locales/en.ts` and `web-studio/src/i18n/locales/zh-CN.ts` combine the module files. Put new text in the existing namespace that owns the page or feature. If a feature needs a new module, create matching English and Chinese files and register both modules in the locale entry points.
+
+Use semantic keys that describe ownership and purpose:
+
+```ts
+settings.connection.userHint
+monitoringPage.detail.columns.status
+resources.retrieval.emptyTitle
+```
+
+Do not use the English sentence as the key. Do not reuse a short key when the same word has a different meaning elsewhere.
+
+## Adding Interface Text
+
+Add the key to both locale resources before using it in a component:
+
+```ts
+// web-studio/src/i18n/locales/en/workspace.ts
+refresh: 'Refresh'
+
+// web-studio/src/i18n/locales/zh-CN/workspace.ts
+refresh: '刷新'
+```
+
+Use `t()` for ordinary text and component properties:
+
+```tsx
+const { t } = useTranslation('monitoringPage')
+
+<Button aria-label={t('refresh')}>{t('refresh')}</Button>
+```
+
+Use `<Trans>` only when a sentence contains nested React elements. Keep interpolation names and their meaning identical in every locale:
+
+```ts
+updatedAt: 'Updated at {{time}}'
+updatedAt: '更新于 {{time}}'
+```
+
+Do not add language branches with hard-coded phrases:
+
+```tsx
+// Do not add this pattern.
+i18n.language.startsWith('zh') ? '刷新' : 'Refresh'
+```
+
+Language branches are appropriate for locale-specific behavior such as documentation URLs or date formatting, not for choosing interface copy.
+
+## Text Received from the Server
+
+Do not translate arbitrary server output. A server value may be a model name, provider value, path, URI, identifier, command, or error detail.
+
+Prefer structured server fields. Map stable enums or protocol labels to i18n keys at the UI boundary. Keep the raw value for requests, comparisons, logs, and error handling.
+
+When an endpoint returns display-oriented text such as an ASCII table:
+
+1. Parse the transport format into a typed UI model.
+2. Localize only allowlisted headers, metrics, statuses, and enum values.
+3. Render the localized model in a component.
+4. Return unknown values unchanged unless the product defines a safe display label.
+
+The monitoring page provides the local pattern:
+
+- [`parse-status.ts`](./src/routes/monitoring/-lib/parse-status.ts) parses the wire format.
+- [`localize-observer-status.ts`](./src/routes/monitoring/-lib/localize-observer-status.ts) maps stable server tokens to i18n keys.
+- [`observer-status-content.tsx`](./src/routes/monitoring/-components/observer-status-content.tsx) renders the localized model.
+
+Do not copy localization mappings into route components.
+
+## What to Translate
+
+| Translate | Preserve unless the product defines a display label |
+| ---------------------------------------------------------- | --------------------------------------------------- |
+| Page titles, buttons, form labels, help text, empty states | API key values, protocol field names, commands |
+| Table headers and status labels intended for users | Model names, provider values, collection names |
+| Known queue, role, metric, and enum display names | IDs, paths, URIs, filenames, operation identifiers |
+| User-facing validation and error summaries | Raw error details and diagnostic payloads |
+
+Project terms such as `Agent`, `Root`, `Trusted`, `VikingBot`, `VLM`, and `Embedding` may remain in English when they name a product role or technical concept. Keep the same choice across pages.
+
+## Pull Request Checklist
+
+Before requesting review, check the following:
+
+- Every new user-visible phrase has an English and a Simplified Chinese entry.
+- Components use `t()` or `<Trans>` instead of hard-coded language branches.
+- Placeholders, plural variables, links, and technical identifiers are unchanged across locales.
+- Server-provided labels use a context-aware allowlist and preserve unknown values.
+- Both languages have been opened in the affected interface. Check empty, loading, success, and error states that the change can reach.
+- Longer Chinese labels fit at the supported widths without hiding values or controls.
+- Focused tests cover any parser or localization adapter whose mapping affects runtime output.
+
+The configured `i18next/no-literal-string` ESLint rule warns about many JSX literals, but it does not cover every TypeScript helper, conditional expression, server response, or generated label. Treat lint as one check, not proof that a feature is fully localized.
+
+## Validation
+
+Run checks that match the changed scope:
+
+```bash
+cd web-studio
+npm run format
+npm run lint
+npm test -- <relevant-test-files>
+```
+
+Run `npm test` and `npm run build` when the change affects shared localization code, parsing, routing, or multiple pages. Report any skipped check and the reason.
+
+## Related Documentation
+
+- [Contributing to OpenViking](../CONTRIBUTING.md) - contribution workflow and repository-wide requirements.
diff --git a/web-studio/CONTRIBUTING_CN.md b/web-studio/CONTRIBUTING_CN.md
new file mode 100644
index 000000000..9800d6c76
--- /dev/null
+++ b/web-studio/CONTRIBUTING_CN.md
@@ -0,0 +1,132 @@
+# 参与 Web Studio 国际化维护
+
+Web Studio 支持英文和简体中文。本文面向在 `web-studio` 中新增或修改用户可见文本的贡献者。两种语言都能正常使用,这项改动才算完成。
+
+先确认文本来自哪里:
+
+| 文本来源 | 处理方式 |
+| ------------------------------------------- | ---------------------------------------------------------- |
+| 固定界面文案 | 同时添加英文和简体中文键,再通过 `t()` 或 `<Trans>` 渲染。 |
+| 稳定的服务端枚举、状态、指标或显示表头 | 在本地化适配器中把已知值映射到 i18n 键。 |
+| 模型名称、路径、URI、标识符、命令或用户内容 | 除非产品定义了显示名称,否则保留原值。 |
+| 服务端原始错误或诊断数据 | 翻译面向用户的错误摘要,同时保留可供排查的原始详情。 |
+
+## 翻译资源
+
+从仓库根目录看,语言资源位于:
+
+```text
+web-studio/src/i18n/locales/en/
+web-studio/src/i18n/locales/zh-CN/
+```
+
+`web-studio/src/i18n/locales/en.ts` 和 `web-studio/src/i18n/locales/zh-CN.ts` 负责汇总各模块。新增文案应放入负责该页面或功能的现有命名空间。确实需要拆分模块时,应同时建立对应的英文和中文文件,并在两个语言入口中注册。
+
+内部键名应表达所属模块和用途:
+
+```ts
+settings.connection.userHint
+monitoringPage.detail.columns.status
+resources.retrieval.emptyTitle
+```
+
+不要直接把英文句子作为键名。同一个短词在不同位置含义不同时,也不要为了复用而共用一个含糊的键。
+
+## 新增界面文案
+
+组件使用文案前,先在两种语言资源中添加相同的键:
+
+```ts
+// web-studio/src/i18n/locales/en/workspace.ts
+refresh: 'Refresh'
+
+// web-studio/src/i18n/locales/zh-CN/workspace.ts
+refresh: '刷新'
+```
+
+普通文本和组件属性使用 `t()`:
+
+```tsx
+const { t } = useTranslation('monitoringPage')
+
+<Button aria-label={t('refresh')}>{t('refresh')}</Button>
+```
+
+只有句子中包含嵌套 React 元素时才使用 `<Trans>`。所有语言中的插值名称和含义必须一致:
+
+```ts
+updatedAt: 'Updated at {{time}}'
+updatedAt: '更新于 {{time}}'
+```
+
+不要用语言判断和写死的字符串选择界面文案:
+
+```tsx
+// 不要新增这种写法。
+i18n.language.startsWith('zh') ? '刷新' : 'Refresh'
+```
+
+语言判断可以用于不同语言的文档链接或日期格式,但不应代替语言包。
+
+## 服务端返回的文本
+
+不要直接翻译任意服务端输出。服务端值可能是模型名称、Provider 值、路径、URI、标识符、命令或原始错误详情。
+
+优先使用结构化字段。在界面边界将稳定的枚举值或协议标签映射到 i18n 键,请求、比较、日志和错误处理仍使用原始值。
+
+接口返回 ASCII 表格等面向显示的文本时,按以下方式处理:
+
+1. 将传输格式解析成有类型的界面数据。
+2. 只转换明确登记的表头、指标、状态和枚举值。
+3. 由组件渲染转换后的数据。
+4. 未登记的值保持原样;只有产品已经定义安全显示名称时才转换。
+
+监控页面已经采用这一结构:
+
+- [`parse-status.ts`](./src/routes/monitoring/-lib/parse-status.ts) 负责解析传输格式。
+- [`localize-observer-status.ts`](./src/routes/monitoring/-lib/localize-observer-status.ts) 负责把稳定的服务端文本映射到 i18n 键。
+- [`observer-status-content.tsx`](./src/routes/monitoring/-components/observer-status-content.tsx) 负责渲染本地化后的数据。
+
+不要把本地化映射重新写进路由组件。
+
+## 翻译范围
+
+| 应翻译 | 除非产品定义了显示名称,否则保持原样 |
+| ------------------------------------------ | ------------------------------------ |
+| 页面标题、按钮、表单标签、帮助文字、空状态 | API 密钥值、协议字段名称、命令 |
+| 面向用户的表头和状态 | 模型名称、Provider 值、集合名称 |
+| 已知队列、角色、指标和枚举的显示名称 | ID、路径、URI、文件名、操作标识符 |
+| 面向用户的校验提示和错误摘要 | 原始错误详情和诊断数据 |
+
+`Agent`、`Root`、`Trusted`、`VikingBot`、`VLM` 和 `Embedding` 等词在表示产品角色或技术概念时可以保留英文,但各页面必须保持一致。
+
+## PR 审查清单
+
+提交审查前逐项确认:
+
+- 每条新增的用户可见文本都有英文和简体中文。
+- 组件使用 `t()` 或 `<Trans>`,没有新增写死的语言判断。
+- 不同语言中的占位符、复数变量、链接和技术标识符保持一致。
+- 服务端标签通过带上下文的白名单转换,未登记的值保持原样。
+- 已在受影响的界面切换并查看两种语言,同时检查功能涉及的空、加载、成功和错误状态。
+- 较长的中文在支持的页面宽度下不会遮挡数值或控件。
+- 解析器或本地化适配器会影响运行结果时,有对应的目标测试。
+
+当前配置的 `i18next/no-literal-string` ESLint 规则可以发现不少 JSX 字面量,但无法覆盖所有 TypeScript 工具函数、条件表达式、服务端响应和动态生成的标签。因此,Lint 只是检查项之一,不能证明功能已经完整本地化。
+
+## 验证
+
+按改动范围运行检查:
+
+```bash
+cd web-studio
+npm run format
+npm run lint
+npm test -- <relevant-test-files>
+```
+
+改动涉及共享本地化代码、解析逻辑、路由或多个页面时,再运行 `npm test` 和 `npm run build`。未执行的检查及原因应如实说明。
+
+## 相关文档
+
+- [OpenViking 贡献指南](../CONTRIBUTING_CN.md):仓库通用的贡献流程和要求。
diff --git a/web-studio/README.md b/web-studio/README.md
index a2a459e91..b79216844 100644
--- a/web-studio/README.md
+++ b/web-studio/README.md
@@ -156,7 +156,7 @@ src/styles.css Global CSS and design tokens
types/ov-server/ Supplemental typed server-result subsets
```
-Keep route-specific implementation colocated under the corresponding route directory. Cross-route consumers must import an explicit public feature entry point instead of reaching into a `-*` module. User-visible copy belongs in both `src/i18n/locales/en.ts` and `src/i18n/locales/zh-CN.ts`.
+Keep route-specific implementation colocated under the corresponding route directory. Cross-route consumers must import an explicit public feature entry point instead of reaching into a `-*` module. Follow the [Web Studio internationalization contribution guide](./CONTRIBUTING.md) whenever a feature adds or changes user-visible text.
## Deployment
@@ -382,5 +382,6 @@ The API key is missing or invalid, the key belongs to a different server, or the
## Related Docs
+- [Web Studio internationalization contribution guide](./CONTRIBUTING.md): translation ownership, dynamic server text, and the review checklist.
- [OpenViking server deployment](../docs/en/guides/03-deployment.md): server-side deployment details.
- [VikingBot validation with OpenViking Server](../bot/docs/vikingbot-phase1-validation-with-openviking-server.md): bot proxy validation flow.
diff --git a/web-studio/README_CN.md b/web-studio/README_CN.md
index 6a2f540e7..0bd8fe1ae 100644
--- a/web-studio/README_CN.md
+++ b/web-studio/README_CN.md
@@ -155,7 +155,7 @@ src/styles.css 全局样式和设计 token
types/ov-server/ 手工补充的服务端 typed result 子集
```
-页面私有实现应放在对应路由目录下。所有用户可见文案都应同步维护 `src/i18n/locales/en.ts` 和 `src/i18n/locales/zh-CN.ts`。
+页面私有实现应放在对应路由目录下。新增或修改用户可见文本时,应遵循 [Web Studio 国际化贡献指南](./CONTRIBUTING_CN.md)。
## 部署
@@ -381,5 +381,6 @@ openviking-server --with-bot
## 相关文档
+- [Web Studio 国际化贡献指南](./CONTRIBUTING_CN.md):翻译归属、服务端动态文本和审查清单。
- [OpenViking server deployment](../docs/en/guides/03-deployment.md):服务端部署说明。
- [VikingBot validation with OpenViking Server](../bot/docs/vikingbot-phase1-validation-with-openviking-server.md):Bot proxy 验证流程。
diff --git a/web-studio/src/hooks/use-app-connection.test.ts b/web-studio/src/hooks/use-app-connection.test.ts
index 3ac000911..f3687d4b7 100644
--- a/web-studio/src/hooks/use-app-connection.test.ts
+++ b/web-studio/src/hooks/use-app-connection.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest'
import {
+ createConnectionError,
createManagementAccountConnection,
createIdentityScopeKey,
createConnectionRoleProbeKey,
@@ -11,10 +12,29 @@ import {
synchronizeConnectionRuntime,
synchronizeResolvedDataIdentity,
} from './use-app-connection'
+import i18n from '#/i18n'
import { ovClient } from '#/lib/ov-client'
const acceptClientError = () => true
+describe('createConnectionError', () => {
+ it('reads the active locale when the asynchronous error is created', async () => {
+ const originalLanguage = i18n.resolvedLanguage || i18n.language
+ try {
+ await i18n.changeLanguage('en')
+ const english = createConnectionError('credentialMismatch').message
+
+ await i18n.changeLanguage('zh-CN')
+ const chinese = createConnectionError('credentialMismatch').message
+
+ expect(chinese).toBe('所选凭证与目标账号和用户不匹配。')
+ expect(chinese).not.toBe(english)
+ } finally {
+ await i18n.changeLanguage(originalLanguage)
+ }
+ })
+})
+
describe('createConnectionRoleProbeKey', () => {
it('matches the connection produced by an internal identity synchronization', () => {
const connection = {
diff --git a/web-studio/src/hooks/use-app-connection.tsx b/web-studio/src/hooks/use-app-connection.tsx
index 483f1b7e8..10eca5b21 100644
--- a/web-studio/src/hooks/use-app-connection.tsx
+++ b/web-studio/src/hooks/use-app-connection.tsx
@@ -2,6 +2,7 @@ import * as React from 'react'
import { useQueryClient } from '@tanstack/react-query'
import { useNavigate, useRouterState } from '@tanstack/react-router'
+import i18n from '#/i18n'
import { fetchAdminAccounts } from '#/lib/admin'
import { isOvClientError, ovClient } from '#/lib/ov-client'
@@ -58,6 +59,15 @@ type AppConnectionContextValue = {
const CONNECTION_STORAGE_KEY = 'ov_console_connection'
const AUTH_PROMPT_SUPPRESSION_MS = 10000
+type ConnectionErrorKey =
+ | 'credentialMismatch'
+ | 'identitySwitchUnsupported'
+ | 'rootRequired'
+
+export function createConnectionError(key: ConnectionErrorKey): Error {
+ return new Error(i18n.t(`connection:errors.${key}`))
+}
+
const ENV_BASE_URL =
typeof import.meta.env.VITE_OV_BASE_URL === 'string'
? import.meta.env.VITE_OV_BASE_URL.trim()
@@ -700,9 +710,7 @@ export function AppConnectionProvider({
userId,
}) => {
if (serverMode === 'dev' || serverMode === 'checking') {
- throw new Error(
- 'The current server mode does not support identity switching.',
- )
+ throw createConnectionError('identitySwitchUnsupported')
}
const requested = normalizeConnectionDraft({
@@ -718,9 +726,7 @@ export function AppConnectionProvider({
allowLegacyIdentityFallback,
)
if (!resolvedIdentity) {
- throw new Error(
- 'The selected credential does not match the target account and user.',
- )
+ throw createConnectionError('credentialMismatch')
}
if (pathname === '/playground') {
@@ -737,9 +743,7 @@ export function AppConnectionProvider({
},
switchManagementAccount: async (accountId) => {
if (connectionRole !== 'root') {
- throw new Error(
- 'Only a validated Root credential can switch management accounts.',
- )
+ throw createConnectionError('rootRequired')
}
commitConnection(
createManagementAccountConnection(connection, accountId),
diff --git a/web-studio/src/i18n/locales/en/resources.ts b/web-studio/src/i18n/locales/en/resources.ts
index a845737cf..a88c0bff7 100644
--- a/web-studio/src/i18n/locales/en/resources.ts
+++ b/web-studio/src/i18n/locales/en/resources.ts
@@ -331,6 +331,11 @@ const resources = {
title: 'File Processing Tasks',
empty: 'No processing tasks',
toggleError: 'Toggle error details',
+ errors: {
+ tempUploadMissingId: 'The temporary upload did not return a file ID.',
+ cancelled: 'Processing cancelled',
+ failed: 'Processing failed',
+ },
columns: {
fileName: 'File Name',
status: 'Status',
diff --git a/web-studio/src/i18n/locales/en/workspace.ts b/web-studio/src/i18n/locales/en/workspace.ts
index 4528fda65..041d20710 100644
--- a/web-studio/src/i18n/locales/en/workspace.ts
+++ b/web-studio/src/i18n/locales/en/workspace.ts
@@ -83,6 +83,25 @@ const workspace = {
unhealthy: 'Some components need attention',
components: '{{healthy}} of {{total}} components healthy',
},
+ queue: {
+ title: 'Task queue',
+ noData: 'No queue data',
+ queueName: 'Queue',
+ processing: 'Active',
+ pending: 'Pending',
+ completed: 'Completed',
+ processed: 'Processed',
+ requeued: 'Requeued',
+ errors: 'Errors',
+ totalRow: 'Total',
+ embedding: 'Embedding',
+ semanticNodes: 'Semantic nodes',
+ semantic: 'Semantic processing',
+ externalParse: 'External parsing',
+ addResource: 'Add resource',
+ sessionCommit: 'Session commit',
+ userDeletion: 'Delete user',
+ },
tabs: {
label: 'Monitoring type',
overview: 'Overview',
@@ -95,6 +114,28 @@ const workspace = {
},
detail: {
noData: 'No monitoring data',
+ columns: {
+ averageMs: 'Avg (ms)',
+ calls: 'Calls',
+ collection: 'Collection',
+ completion: 'Completion',
+ contextType: 'Context Type',
+ count: 'Count',
+ indexCount: 'Index Count',
+ lastUpdated: 'Last Updated',
+ maximumMs: 'Max (ms)',
+ metric: 'Metric',
+ minimumMs: 'Min (ms)',
+ model: 'Model',
+ operation: 'Operation',
+ prompt: 'Prompt',
+ provider: 'Provider',
+ queries: 'Queries',
+ status: 'Status',
+ total: 'Total',
+ value: 'Value',
+ vectorCount: 'Vector Count',
+ },
descriptions: {
queue: 'Resource processing, semantic generation, and session queues.',
vikingdb: 'Vector storage and indexing service.',
@@ -103,6 +144,48 @@ const workspace = {
lock: 'Transaction locks and concurrency control.',
retrieval: 'Context retrieval service.',
},
+ metrics: {
+ averageLatency: 'Avg Latency (ms)',
+ averageResults: 'Avg Results/Query',
+ averageScore: 'Avg Score',
+ maximumLatency: 'Max Latency (ms)',
+ overallAverage: 'Overall Avg (ms)',
+ rerankFallback: 'Rerank Fallback',
+ rerankUsed: 'Rerank Used',
+ scoreRange: 'Score Range',
+ totalOperations: 'Total Operations',
+ totalQueries: 'Total Queries',
+ totalResults: 'Total Results',
+ totalTime: 'Total Time (s)',
+ zeroResultQueries: 'Zero-Result Queries',
+ zeroResultRate: 'Zero-Result Rate',
+ },
+ statusText: {
+ activeLocks: 'Active locks: {{count}}',
+ conflicts: 'Conflicts: {{count}}',
+ embeddingModels: 'Embedding Models:',
+ filesystemError: 'Error retrieving filesystem statistics: {{error}}',
+ filesystemUnavailable: 'No filesystem statistics available.',
+ modelUsageUnavailable: 'No model usage data available.',
+ mount: 'Mount: {{path}} (plugin: {{plugin}})',
+ noCollections: 'No collections found.',
+ noFilesystemOperations: 'No operation statistics recorded yet.',
+ notInitialized: 'Not initialized.',
+ queueUnavailable: 'No queue status data available.',
+ rerankModels: 'Rerank Models:',
+ retrievalUnavailable: 'No retrieval queries recorded.',
+ staleLocksRemoved: 'Stale locks removed: {{count}}',
+ vikingdbUnavailable: 'VikingDB manager not initialized.',
+ vlmModels: 'VLM Models:',
+ waitingLocks: 'Waiting locks: {{count}}',
+ },
+ values: {
+ configured: 'Configured',
+ error: 'Error',
+ ok: 'OK',
+ total: 'Total',
+ unknown: 'Unknown',
+ },
},
offline: {
title: 'OpenViking is not connected',
@@ -434,6 +517,14 @@ const workspace = {
placeholder: 'default',
},
},
+ errors: {
+ identitySwitchUnsupported:
+ 'The current server mode does not support identity switching.',
+ credentialMismatch:
+ 'The selected credential does not match the target account and user.',
+ rootRequired:
+ 'Only a validated Root credential can switch management accounts.',
+ },
},
settings: {
actions: {
@@ -566,6 +657,16 @@ const workspace = {
health: {
admin: 'Admin control',
data: 'Data access',
+ detail: {
+ accountAdminAvailable: 'Account admin control available',
+ adminModeRequired: 'Admin API requires API-key or trusted mode',
+ controlKeyRequired: 'A root or account-admin API key is required',
+ dataKeyRequired: 'A user or account-admin API key is required',
+ rootAvailable: 'Root admin control available',
+ tenantDataAvailable: 'Tenant data access available',
+ trustedIdentityRequired:
+ 'Trusted mode data access requires account and user',
+ },
state: {
checking: 'Checking',
error: 'Error',
diff --git a/web-studio/src/i18n/locales/zh-CN/activity.ts b/web-studio/src/i18n/locales/zh-CN/activity.ts
index 4189e8050..57712e007 100644
--- a/web-studio/src/i18n/locales/zh-CN/activity.ts
+++ b/web-studio/src/i18n/locales/zh-CN/activity.ts
@@ -1,12 +1,13 @@
const activity = {
sessions: {
page: {
- placeholder: '会话与 Bot 工作区能力尚未接入。',
+ placeholder: '会话和 VikingBot 工作区功能正在开发中。',
},
threadList: {
title: '会话',
newSession: '新建会话',
count: '{{count}} 个会话',
+ count_other: '{{count}} 个会话',
loading: '正在加载会话...',
emptyTitle: '还没有会话',
emptyDescription: '点击右上角的加号开始一段新对话。',
@@ -36,8 +37,11 @@ const activity = {
relativeTime: {
justNow: '刚刚',
minutesAgo: '{{count}} 分钟前',
+ minutesAgo_other: '{{count}} 分钟前',
hoursAgo: '{{count}} 小时前',
+ hoursAgo_other: '{{count}} 小时前',
daysAgo: '{{count}} 天前',
+ daysAgo_other: '{{count}} 天前',
},
toolStatus: {
completed: '完成',
@@ -77,16 +81,16 @@ const activity = {
identityPicker: {
useCurrent: '以当前身份授权',
noCurrent:
- '尚未配置身份。请先在“连接与身份”中登录,或在下方临时粘贴一个 API key。',
+ '尚未配置身份。请先在“连接设置”中配置身份凭证,或在下方临时粘贴一个 API 密钥。',
useSelect: '授权指定的账号 / 用户',
selectAccountLabel: '账号',
selectUserLabel: '用户',
selectNoKey:
- '该用户没有 API key,请选择其他用户,或在“连接与身份”中重新生成。',
+ '该用户没有 API 密钥,请选择其他用户,或在“连接设置”中重新生成 API 密钥。',
selectAccountAdminHint: '你只能为本账号下的用户授权。',
- useCustom: '使用其他 API key',
- customKeyLabel: 'API key',
- customKeyPlaceholder: '粘贴一个 API key(不会持久化)',
+ useCustom: '使用其他 API 密钥',
+ customKeyLabel: 'API 密钥',
+ customKeyPlaceholder: '粘贴一个 API 密钥(不会持久化)',
},
consent: {
title: '授权 {{clientName}}',
@@ -98,8 +102,8 @@ const activity = {
scopesLabel: '权限范围',
scopesNone: '(无)',
signInRequired:
- '请先在“连接与身份”中登录 OpenViking Studio,或在下方临时粘贴 API key 完成授权。',
- openConnectionSettings: '打开连接与身份',
+ '请先在“连接设置”中配置 OpenViking Studio 身份凭证,或在下方临时粘贴 API 密钥完成授权。',
+ openConnectionSettings: '打开连接设置',
authorize: '授权',
deny: '拒绝',
useAnotherDevice: '在另一台设备上授权 →',
@@ -108,7 +112,7 @@ const activity = {
denying: '正在拒绝…',
denied: '已拒绝,可以关闭此页。',
verifyError: '授权失败:{{message}}',
- noApiKey: '没有可用的 API key。请选择一个身份或粘贴 key。',
+ noApiKey: '没有可用的 API 密钥。请选择一个身份或粘贴密钥。',
},
verify: {
title: '跨设备验证',
@@ -119,17 +123,17 @@ const activity = {
success: '已为 {{clientName}} 授权,可以关闭此页并回到原设备。',
successUnknownClient: '已授权,可以关闭此页并回到原设备。',
verifyError: '授权失败:{{message}}',
- noApiKey: '没有可用的 API key。请选择一个身份或粘贴 key。',
+ noApiKey: '没有可用的 API 密钥。请选择一个身份或粘贴密钥。',
signInRequired:
- '请先在“连接与身份”中登录 OpenViking Studio,或在下方临时粘贴 API key 完成授权。',
+ '请先在“连接设置”中配置 OpenViking Studio 身份凭证,或在下方临时粘贴 API 密钥完成验证。',
},
},
playground: {
copyUri: '复制当前 URI',
copied: '已复制 URI',
copyFailed: '复制失败',
- resizeContext: '调整上下文目录宽度',
- resizeAction: '调整 Terminal 和 Agent 宽度',
+ resizeContext: '调整上下文树宽度',
+ resizeAction: '调整终端和 Agent 面板宽度',
readFailed: '无法读取 {{uri}}',
tabs: {
terminal: '终端',
@@ -137,19 +141,18 @@ const activity = {
},
addResource: {
title: '添加资源',
- description:
- '添加完成后左侧目录树会刷新,右侧 Terminal 可继续定位新资源。',
+ description: '添加完成后左侧上下文树会刷新,右侧终端可继续定位新资源。',
submitted: '资源添加任务已提交',
},
explorer: {
- title: '上下文目录',
+ title: '上下文树',
addResource: '添加资源',
abstractLevel: 'L0',
empty: '空',
loading: '加载中',
overviewLevel: 'L1',
search: '搜索上下文',
- refresh: '刷新目录',
+ refresh: '刷新上下文树',
namespaces: {
agent: 'Agent 的能力、工具和经验',
user: '用户个性化记忆',
@@ -159,28 +162,28 @@ const activity = {
agent: {
history: '历史会话',
newSession: '新建会话',
- creating: '正在创建 Playground 会话...',
- detectingBot: '正在检测 bot 模式...',
+ creating: '正在创建工作台会话...',
+ detectingBot: '正在检查 VikingBot 是否可用...',
createFailed: '创建会话失败:{{error}}',
retry: '重试',
- botDisabledFooter: '开启 bot 模式后可使用 Agent 对话',
+ botDisabledFooter: '启用 VikingBot 后即可与 Agent 对话',
historyTitle: 'Agent 会话历史',
historyDescription:
- '这里只展示实验场右侧 Agent 使用过的会话;新建会话会开启一个空白 Agent 上下文。',
+ '这里只显示 Agent 面板使用过的会话。新建会话会创建一段空白的 Agent 上下文。',
loadingSessions: '正在加载会话...',
noSessions: '暂无历史会话',
- createTimeout: '创建 Playground 会话超时,请检查连接设置后重试。',
- newSessionTitle: '新建 Playground 会话',
+ createTimeout: '创建工作台会话超时,请检查连接设置后重试。',
+ newSessionTitle: '新建工作台会话',
botPrompt: {
- title: '请开启 bot 模式',
+ title: '请启用 VikingBot',
description:
- '当前服务未启用 Agent 对话能力,请使用 bot 模式启动服务后重试。',
+ '当前服务未启用 Agent 对话功能。请使用以下参数启动服务后重试。',
command: 'openviking-server --with-bot',
retry: '重新检测',
},
empty: {
- heading: 'Agent 动作会和左侧目录联动',
- body: '发送问题后,tool call 输出里的 `viking://` 文件会变成可点击链接,点击即可在左侧定位并在中间打开。',
+ heading: 'Agent 操作会与左侧目录联动',
+ body: '发送问题后,工具调用输出里的 `viking://` 文件会变成可点击链接,点击即可在左侧定位并在中间打开。',
prompts: [
'总结当前目录',
'递归查找相关文档',
@@ -195,7 +198,7 @@ const activity = {
historyDescription: '查看当前浏览器中执行过的命令。',
clearHistory: '清空命令历史',
noHistory: '暂无命令历史',
- welcomeTitle: 'Terminal 已连接上下文目录',
+ welcomeTitle: '终端已连接上下文树',
welcomeBody:
'可执行 /status、/ls、/search、/read、/add-resource。/search 默认全局检索,可通过 --scope . 使用当前目录,或通过 --scope viking://resources/... 指定目录。',
scopeLabel: '目录:{{uri}}',
@@ -214,7 +217,7 @@ const activity = {
currentScopeAction: '使用当前目录',
readUsage: '用法:/read viking://resources/...',
enterUri: '请输入 viking:// URI',
- hits: '命中 resources {{resources}} 条,memory {{memories}} 条,skill {{skills}} 条。',
+ hits: '命中资源 {{resources}} 条、记忆 {{memories}} 条、技能 {{skills}} 条。',
addResourceBody:
'已打开添加资源弹窗。提交后左侧目录会刷新,也可以用 /ls 或 /search 继续定位新内容。',
addResourceTitle: '添加资源',
@@ -222,13 +225,13 @@ const activity = {
'用法:/session [current|list|create|switch|get|context|messages|archive|commit|extract|message|used|tool-results|tool-result|tool-search|delete] ...',
sessionDeleteUsage: '用法:/session delete <session_id>',
sessionMissing:
- '当前没有 active session,请先打开 Agent 面板创建会话,或指定 session_id。',
- sessionCurrentBody: '当前 active session:{{id}}',
- sessionListBody: '共有 {{count}} 个 session。',
- sessionCreatedBody: '已创建并切换到 session:{{id}}',
- sessionSwitchedBody: '已切换到 session:{{id}}',
- sessionDeletedBody: '已删除 session:{{id}}',
- sessionMessageAddedBody: '已向 session {{id}} 添加消息。',
+ '当前没有会话,请先打开 Agent 面板创建会话,或指定 session_id。',
+ sessionCurrentBody: '当前会话:{{id}}',
+ sessionListBody: '共有 {{count}} 个会话。',
+ sessionCreatedBody: '已创建并切换到会话:{{id}}',
+ sessionSwitchedBody: '已切换到会话:{{id}}',
+ sessionDeletedBody: '已删除会话:{{id}}',
+ sessionMessageAddedBody: '已向会话 {{id}} 添加消息。',
unknownCommand:
'未知命令。可用命令:/status、/ls、/search、/find、/read、/session、/add-resource。',
commandFailed: '命令失败',
@@ -245,7 +248,7 @@ const activity = {
},
addMemory: {
title: '添加记忆',
- command: 'Agent 对话后自动沉淀',
+ command: '通过 Agent 会话提取记忆',
code: '在 Agent 面板发送消息,然后提交会话',
},
find: {
@@ -270,7 +273,7 @@ const activity = {
scope: {
name: '--scope <.|uri>',
description:
- '可选。不填则全局搜索;传 . 使用当前目录;传 uri 使用指定目录。',
+ '可选。不填则全局搜索;传入 . 使用当前目录,传入 URI 使用指定目录。',
},
sessionAction: {
name: '子命令',
@@ -280,19 +283,19 @@ const activity = {
sessionId: {
name: 'session_id',
description:
- '可选。省略时多数子命令使用当前 Agent session;delete 必须显式指定。',
+ '可选。省略时,多数子命令使用当前 Agent 会话;delete 必须显式指定。',
},
archiveId: {
name: 'archive_id',
- description: '读取 archive 时必填。',
+ description: '读取会话归档时必填。',
},
messageRole: {
name: 'role',
- description: 'message 子命令使用,支持 user 或 assistant。',
+ description: '用于 message 子命令,角色值支持 user 或 assistant。',
},
messageContent: {
name: 'content',
- description: 'message 子命令使用,要追加到 session 的文本内容。',
+ description: '用于 message 子命令,指定要追加到会话的文本内容。',
},
contexts: {
name: '--context uri',
@@ -300,15 +303,15 @@ const activity = {
},
skillJson: {
name: '--skill-json JSON',
- description: 'used 子命令使用,记录实际使用的 skill 信息。',
+ description: 'used 子命令使用,记录实际使用的技能信息。',
},
keepRecent: {
name: '--keep-recent 数量',
- description: 'commit 子命令使用,提交后保留最近 N 条 live messages。',
+ description: '用于 commit 子命令,提交后保留最近 N 条未归档消息。',
},
tokenBudget: {
name: '--token-budget 数量',
- description: 'context 子命令使用,限制组装上下文的 token 预算。',
+ description: '用于 context 子命令,限制组装上下文的 Token 预算。',
},
toolName: {
name: '--tool-name 名称',
@@ -316,11 +319,11 @@ const activity = {
},
toolResultId: {
name: 'tool_result_id',
- description: '读取或搜索外部化 tool result 时必填。',
+ description: '读取或搜索外部化工具结果时必填。',
},
limit: {
name: '--limit 数量',
- description: 'tool result 列表、读取或搜索时限制返回数量。',
+ description: '用于限制工具结果列表、读取或搜索的返回数量。',
},
offset: {
name: '--offset 数量',
@@ -343,7 +346,7 @@ const activity = {
status: {
default: {
code: '/status',
- description: '检查 Agent 和 API 连通状态',
+ description: '检查 Agent 和 API 的连通状态',
},
},
ls: {
@@ -399,15 +402,15 @@ const activity = {
session: {
current: {
code: '/session',
- description: '查看当前 active session',
+ description: '查看当前会话',
},
list: {
code: '/session list',
- description: '列出所有 session',
+ description: '列出所有会话',
},
create: {
code: '/session create [session_id]',
- description: '创建并切换到新 session',
+ description: '创建并切换到新会话',
},
switch: {
code: '/session switch <session_id>',
@@ -415,19 +418,19 @@ const activity = {
},
get: {
code: '/session get [session_id]',
- description: '查看 session 元信息',
+ description: '查看会话元数据',
},
context: {
code: '/session context [session_id] --token-budget 8000',
- description: '读取组装后的 session context',
+ description: '读取组装后的会话上下文',
},
messages: {
code: '/session messages [session_id]',
- description: '读取 session 消息列表',
+ description: '读取会话消息列表',
},
archive: {
code: '/session archive [session_id] <archive_id>',
- description: '读取指定 archive',
+ description: '读取指定会话归档',
},
commit: {
code: '/session commit [session_id] --keep-recent 10',
@@ -435,31 +438,31 @@ const activity = {
},
extract: {
code: '/session extract [session_id]',
- description: '从 session 中提取记忆',
+ description: '从会话中提取记忆',
},
message: {
code: '/session message [session_id] user hello',
- description: '向 session 追加消息',
+ description: '向会话追加消息',
},
used: {
code: '/session used [session_id] --context viking://resources/...',
- description: '记录实际使用的上下文或 skill',
+ description: '记录实际使用的上下文或技能',
},
toolResults: {
code: '/session tool-results [session_id] --limit 20',
- description: '列出外部化 tool results',
+ description: '列出外部化工具结果',
},
toolResult: {
code: '/session tool-result [session_id] <tool_result_id>',
- description: '读取一个 tool result',
+ description: '读取一项外部化工具结果',
},
toolSearch: {
code: '/session tool-search [session_id] <tool_result_id> query',
- description: '在 tool result 中搜索',
+ description: '在外部化工具结果中搜索',
},
delete: {
code: '/session delete <session_id>',
- description: '删除指定 session',
+ description: '删除指定会话',
},
},
tree: {
diff --git a/web-studio/src/i18n/locales/zh-CN/resources.ts b/web-studio/src/i18n/locales/zh-CN/resources.ts
index fef182bf4..f4f3a63ea 100644
--- a/web-studio/src/i18n/locales/zh-CN/resources.ts
+++ b/web-studio/src/i18n/locales/zh-CN/resources.ts
@@ -7,14 +7,14 @@ const resources = {
requestLogs: {
accessRequired: {
description:
- '当前连接未获取到 admin/root 权限,无法显示请求日志。请在连接与身份中配置具备 Console Usage/Audit 权限的 API Key。',
- title: '需要 admin 权限',
+ '当前连接没有管理员或 Root 权限,无法显示请求日志。请在“连接设置”中配置具备控制台用量和审计权限的 API 密钥。',
+ title: '需要管理员权限',
},
clear: '清空',
description:
'查看当前身份下服务端审计到的 API 请求,包括状态、耗时和请求标识。',
disabled: {
- description: 'Usage/Audit 未初始化,暂无服务端请求日志。',
+ description: '用量和审计功能尚未初始化,暂无服务端请求日志。',
title: '审计日志不可用',
},
details: {
@@ -35,12 +35,12 @@ const resources = {
description: '无法从服务端加载审计请求日志。',
title: '请求失败',
},
- eyebrow: 'Playground 遥测',
+ eyebrow: '工作台请求记录',
filters: {
all: '所有日志',
apiTypePlaceholder: 'API 类型',
error: '错误日志',
- requestIdPlaceholder: '精确 Request ID',
+ requestIdPlaceholder: '精确请求 ID',
statusCodePlaceholder: '状态码',
},
loading: '正在加载请求日志...',
@@ -60,25 +60,26 @@ const resources = {
reset: '重置',
searchPlaceholder: '筛选方法、路径或状态码',
scope: {
- currentIdentity: '当前范围:当前 API key 身份',
- currentIdentityWithName: '当前范围:当前 API key 身份({{identity}})',
+ currentIdentity: '当前范围:当前 API 密钥对应的身份',
+ currentIdentityWithName:
+ '当前范围:当前 API 密钥对应的身份({{identity}})',
},
status: {
- error: 'ERR',
- pending: 'PENDING',
- success: 'OK',
+ error: '错误',
+ pending: '等待中',
+ success: '成功',
},
table: {
- accountId: 'Account ID',
+ accountId: '账号 ID',
apiType: 'API 类型',
duration: '耗时',
method: '方法',
path: '路径',
- requestId: 'Request ID',
+ requestId: '请求 ID',
status: '状态',
time: '时间',
title: '捕获的请求',
- userId: 'User ID',
+ userId: '用户 ID',
},
title: '请求日志',
},
@@ -143,7 +144,7 @@ const resources = {
feishu: '飞书 / Lark',
feishuHint: '支持文档、知识库、电子表格和多维表格链接。',
git: 'Git 仓库',
- gitHint: '支持公开或私有 Git 仓库,并可指定分支或 Commit。',
+ gitHint: '支持公开或私有 Git 仓库,并可指定分支或提交。',
remoteFile: '远程文件',
remoteFileHint: '将下载并解析该远程文件。',
tos: 'TOS',
@@ -160,7 +161,7 @@ const resources = {
feishuHint: '文档、知识库、电子表格和多维表格',
feishuExample: 'https://example.feishu.cn/docx/...',
git: 'Git 仓库',
- gitHint: '公开或私有仓库,可指定分支或 Commit',
+ gitHint: '公开或私有仓库,可指定分支或提交',
gitExample: 'https://github.com/org/repo',
webPage: '网页 / 站点',
webPageHint: '单页、递归抓取、Sitemap、RSS 和 Atom',
@@ -183,15 +184,15 @@ const resources = {
app: '服务端应用凭证',
appHint: '使用服务端配置的 FEISHU_APP_ID 和 FEISHU_APP_SECRET。',
user: '用户授权',
- userHint: '使用当前用户的飞书 Access Token 访问私有文档。',
+ userHint: '使用当前用户的飞书访问令牌访问私有文档。',
},
- accessToken: 'Access Token',
+ accessToken: '访问令牌',
'accessToken.placeholder': 'u-...',
- 'accessToken.hint': 'Token 仅用于本次导入,不会保存。',
- refreshToken: 'Refresh Token',
+ 'accessToken.hint': '访问令牌仅用于本次导入,不会保存。',
+ refreshToken: '刷新令牌',
'refreshToken.placeholder': 'r-...',
'refreshToken.hint':
- '定时同步需要 Refresh Token;服务端还需配置签发该 Token 的同一个飞书应用。',
+ '定时同步需要刷新令牌;服务端还需配置签发该令牌的同一个飞书应用。',
configuration: {
credentials: '在飞书开放平台获取应用的 App ID 和 App Secret。',
server:
@@ -203,22 +204,22 @@ const resources = {
refType: '版本定位',
branch: '分支',
'branch.placeholder': 'main',
- commit: 'Commit',
- 'commit.placeholder': '完整或短 Commit SHA',
+ commit: '提交',
+ 'commit.placeholder': '完整或短格式的提交 SHA',
auth: {
title: '仓库访问方式',
public: '公开仓库',
publicHint: '无需凭证,直接访问仓库。',
- token: 'HTTPS Token',
+ token: 'HTTPS 令牌',
tokenHint: '通过 HTTPS Basic Auth 访问私有仓库。',
- httpsOnly: 'Token 认证仅支持 HTTPS Git 地址。',
+ httpsOnly: '令牌认证仅支持 HTTPS Git 地址。',
},
username: '用户名',
'username.placeholder': 'oauth2',
- token: '访问 Token',
- 'token.placeholder': 'Personal Access Token',
+ token: '访问令牌',
+ 'token.placeholder': '个人访问令牌',
'token.hint':
- '凭证通过请求体发送;开启定时同步后会保存到 Watch 私有鉴权状态。',
+ '凭证会随请求发送;开启定时同步后,还会保存在私有凭证存储中。',
},
web: {
mode: {
@@ -311,6 +312,11 @@ const resources = {
title: '文件处理任务',
empty: '暂无处理任务',
toggleError: '展开或收起错误详情',
+ errors: {
+ tempUploadMissingId: '临时上传未返回文件 ID。',
+ cancelled: '处理已取消',
+ failed: '处理失败',
+ },
columns: {
fileName: '文件名',
status: '状态',
@@ -412,6 +418,7 @@ const resources = {
noArguments: '无参数',
rawMode: 'JSONL',
recordCount: '{{count}} 条记录',
+ recordCount_other: '{{count}} 条记录',
toolcall: '工具调用',
},
},
@@ -454,7 +461,7 @@ const resources = {
label: '自定义 URI',
},
},
- sessionId: 'Session ID',
+ sessionId: '会话 ID',
sessionPlaceholder: 'session_id(可选)',
},
advanced: {
@@ -486,7 +493,7 @@ const resources = {
detail: {
score: '相关度',
level: '层级',
- openPlayground: '在 Playground 打开',
+ openPlayground: '在工作台中打开',
uri: 'URI',
summary: '摘要',
noSummary: '暂无可展示的摘要',
@@ -503,9 +510,9 @@ const resources = {
provenance: '检索过程({{count}})',
},
types: {
- resource: 'Resources',
- memory: 'Memories',
- skill: 'Skills',
+ resource: '资源',
+ memory: '记忆',
+ skill: '技能',
},
queryPlan: {
title: '查询计划 {{count}} 条',
@@ -532,7 +539,7 @@ const resources = {
'请求未能到达 OpenViking 服务,请检查连接地址、服务状态或跨域配置。',
code: '错误码',
status: 'HTTP 状态',
- requestId: 'Request ID',
+ requestId: '请求 ID',
},
noResults: {
title: '没有找到匹配的内容',
diff --git a/web-studio/src/i18n/locales/zh-CN/workspace.ts b/web-studio/src/i18n/locales/zh-CN/workspace.ts
index f2cd77288..b8a327694 100644
--- a/web-studio/src/i18n/locales/zh-CN/workspace.ts
+++ b/web-studio/src/i18n/locales/zh-CN/workspace.ts
@@ -10,12 +10,12 @@ const workspace = {
},
header: {
currentUser: {
- account: 'Account',
- accountSummary: 'Account · {{account}}',
+ account: '账号',
+ accountSummary: '账号 · {{account}}',
openMenu: '查看当前用户 {{user}}',
signedInAs: '当前数据访问身份',
unset: '未设置',
- user: 'User',
+ user: '用户',
},
defaultTitle: 'OpenViking Studio',
},
@@ -51,7 +51,7 @@ const workspace = {
title: '会话',
},
playground: {
- title: '实验场',
+ title: '工作台',
},
},
sidebar: {
@@ -83,11 +83,30 @@ const workspace = {
unhealthy: '部分组件需要关注',
components: '{{healthy}} / {{total}} 个组件正常',
},
+ queue: {
+ title: '任务队列',
+ noData: '暂无队列数据',
+ queueName: '队列',
+ processing: '处理中',
+ pending: '等待中',
+ completed: '已完成',
+ processed: '已处理',
+ requeued: '重新入队',
+ errors: '错误',
+ totalRow: '合计',
+ embedding: 'Embedding',
+ semanticNodes: '语义节点',
+ semantic: '语义处理',
+ externalParse: '外部解析',
+ addResource: '添加资源',
+ sessionCommit: '会话提交',
+ userDeletion: '删除用户',
+ },
tabs: {
label: '监控类型',
overview: '总览',
queue: '任务队列',
- vikingdb: 'VectorDB',
+ vikingdb: '向量数据库',
models: '模型',
filesystem: '文件系统',
lock: '锁',
@@ -95,6 +114,28 @@ const workspace = {
},
detail: {
noData: '暂无监控数据',
+ columns: {
+ averageMs: '平均耗时(毫秒)',
+ calls: '调用次数',
+ collection: '集合',
+ completion: '输出 Token',
+ contextType: '上下文类型',
+ count: '次数',
+ indexCount: '索引数',
+ lastUpdated: '最后更新时间',
+ maximumMs: '最长耗时(毫秒)',
+ metric: '指标',
+ minimumMs: '最短耗时(毫秒)',
+ model: '模型',
+ operation: '操作',
+ prompt: '输入 Token',
+ provider: '供应商',
+ queries: '查询次数',
+ status: '状态',
+ total: '合计',
+ value: '数值',
+ vectorCount: '向量数',
+ },
descriptions: {
queue: '资源处理、语义生成和会话提交队列。',
vikingdb: '向量数据存储与索引服务。',
@@ -103,6 +144,48 @@ const workspace = {
lock: '事务锁与并发控制服务。',
retrieval: '上下文检索服务。',
},
+ metrics: {
+ averageLatency: '平均延迟(毫秒)',
+ averageResults: '平均每次查询结果数',
+ averageScore: '平均相关度',
+ maximumLatency: '最长延迟(毫秒)',
+ overallAverage: '总体平均耗时(毫秒)',
+ rerankFallback: 'Rerank 回退次数',
+ rerankUsed: 'Rerank 使用次数',
+ scoreRange: '相关度范围',
+ totalOperations: '操作总数',
+ totalQueries: '查询总数',
+ totalResults: '结果总数',
+ totalTime: '总耗时(秒)',
+ zeroResultQueries: '无结果查询次数',
+ zeroResultRate: '无结果查询占比',
+ },
+ statusText: {
+ activeLocks: '活动锁:{{count}}',
+ conflicts: '冲突:{{count}}',
+ embeddingModels: 'Embedding 模型:',
+ filesystemError: '获取文件系统统计数据失败:{{error}}',
+ filesystemUnavailable: '暂无文件系统统计数据。',
+ modelUsageUnavailable: '暂无模型用量数据。',
+ mount: '挂载点:{{path}}(插件:{{plugin}})',
+ noCollections: '未找到集合。',
+ noFilesystemOperations: '尚未记录文件系统操作。',
+ notInitialized: '尚未初始化。',
+ queueUnavailable: '暂无队列状态数据。',
+ rerankModels: 'Rerank 模型:',
+ retrievalUnavailable: '尚未记录检索请求。',
+ staleLocksRemoved: '已清理的过期锁:{{count}}',
+ vikingdbUnavailable: 'VikingDB 管理器尚未初始化。',
+ vlmModels: 'VLM 模型:',
+ waitingLocks: '等待中的锁:{{count}}',
+ },
+ values: {
+ configured: '已配置',
+ error: '错误',
+ ok: '正常',
+ total: '合计',
+ unknown: '未知',
+ },
},
offline: {
title: '尚未连接 OpenViking 服务',
@@ -123,7 +206,7 @@ const workspace = {
networkError: '无法连接 OpenViking 服务,请检查服务地址和连接状态。',
connectionSettings: '打开连接设置',
detail: '详情',
- openPlayground: '在 Playground 打开',
+ openPlayground: '在工作台中打开',
viewDetail: '查看 {{name}} 详情',
detailLoading: '正在加载技能详情...',
detailLoadFailed: '技能详情加载失败',
@@ -138,7 +221,7 @@ const workspace = {
content: 'SKILL.md',
description: '简介',
files: '文件',
- overview: 'Overview',
+ overview: '概览',
tags: '标签',
},
scopes: {
@@ -153,7 +236,7 @@ const workspace = {
},
tasksPage: {
title: '任务中心',
- description: '集中查看资源处理、会话提交和 Reindex 等后台任务。',
+ description: '集中查看资源处理、会话提交和重建索引等后台任务。',
refresh: '刷新',
loading: '正在加载任务...',
empty: '暂无后台任务',
@@ -219,7 +302,7 @@ const workspace = {
add_resource: '资源处理',
add_skill: '技能导入',
connector_import: '连接器导入',
- admin_reindex: 'Reindex',
+ admin_reindex: '重建索引',
snapshot_restore_reindex: '快照恢复索引',
legacy_migration: '旧数据迁移',
legacy_cleanup: '旧数据清理',
@@ -227,7 +310,7 @@ const workspace = {
},
watchesPage: {
title: '定时同步',
- description: '通过 Watch 任务定期检查远程资源更新,并集中管理同步计划。',
+ description: '通过定时同步任务检查远程资源更新,并集中管理同步计划。',
refresh: '刷新',
add: '添加',
adding: '添加中...',
@@ -310,46 +393,46 @@ const workspace = {
},
},
accountSwitcher: {
- create: '新建 Account',
+ create: '新建账号',
dialog: {
- accountLabel: 'Account',
+ accountLabel: '账号',
accountPlaceholder: 'team-account',
- adminLabel: '初始 Admin user',
+ adminLabel: '初始管理员用户',
cancel: '取消',
description:
'创建一个新的空间和首个管理员。创建完成后将自动切换到该空间。',
submit: '创建并切换',
- title: '新建 Account',
+ title: '新建账号',
},
- empty: '没有匹配的 Account',
+ empty: '没有匹配的账号',
errors: {
- loadAccounts: '加载 Account 失败',
- noCreatedKey: 'Account 已创建,但服务端没有返回可用于切换的数据凭证。',
- noUsableKey: '该 Account 没有可用于数据访问的明文 User API Key。',
- noUsers: '该 Account 下没有可用用户。',
+ loadAccounts: '账号加载失败',
+ noCreatedKey: '账号已创建,但服务端没有返回可用于切换的数据凭证。',
+ noUsableKey: '该账号没有可用于数据访问的明文用户 API 密钥。',
+ noUsers: '该账号下没有可用用户。',
},
- loading: '正在加载 Accounts...',
+ loading: '正在加载账号...',
manualSwitch: {
description:
- '服务端没有返回 {{account}} 下的明文凭证。请输入该 Account 中任意用户的 User API Key。',
- hint: 'API Key 只用于校验并切换当前数据身份,不会修改或重新生成服务端凭证。',
- keyLabel: 'User API Key',
- keyPlaceholder: '粘贴目标 Account 的 User API Key',
- manageOnly: '仅管理该 Account',
+ '服务端没有返回 {{account}} 下的明文凭证。请输入该账号中任意用户的用户 API 密钥。',
+ hint: 'API 密钥只用于校验并切换当前数据身份,不会修改或重新生成服务端凭证。',
+ keyLabel: '用户 API 密钥',
+ keyPlaceholder: '粘贴目标账号的用户 API 密钥',
+ manageOnly: '仅管理该账号',
submit: '验证并切换',
- title: '输入 User API Key',
+ title: '输入用户 API 密钥',
},
memberCount: '{{count}} 个用户',
- searchPlaceholder: '搜索 Account',
+ searchPlaceholder: '搜索账号',
toast: {
created: '已创建并切换到 {{account}}',
createdSwitchFailed:
- '{{account}} 已创建,但数据身份切换失败:{{error}}。仍可进入该 Account 管理用户。',
+ '{{account}} 已创建,但数据身份切换失败:{{error}}。仍可进入该账号管理用户。',
managementSwitched:
- '管理空间已切换到 {{account}}。访问租户数据前,请先选择或创建 User Key。',
+ '管理空间已切换到 {{account}}。访问租户数据前,请先选择或创建用户密钥。',
switched: '已切换到 {{account}}',
},
- unset: '未选择 Account',
+ unset: '未选择账号',
},
common: {
action: {
@@ -375,11 +458,11 @@ const workspace = {
connection: {
devMode: {
description:
- '当前服务会自动提供身份,通常不需要填写 account、user 和 API key。',
+ '当前服务会自动提供身份,通常不需要填写账号、用户和 API 密钥。',
title: '服务端托管身份',
},
dialog: {
- title: '连接与身份',
+ title: '连接设置',
},
identitySummary: {
dev: '服务端隐式身份',
@@ -388,16 +471,16 @@ const workspace = {
},
fields: {
accountId: {
- label: 'Account',
+ label: '账号',
placeholder: 'default',
},
apiKey: {
- label: 'API Key',
- placeholder: '输入 X-API-Key 或 Bearer token',
+ label: 'API 密钥',
+ placeholder: '输入 X-API-Key 或 Bearer 令牌',
},
adminApiKey: {
- label: 'Admin API key',
- placeholder: 'Root 或 account-admin key',
+ label: '管理员 API 密钥',
+ placeholder: 'Root 或账号管理员 API 密钥',
},
baseUrl: {
label: '服务地址',
@@ -407,26 +490,31 @@ const workspace = {
title: '身份与凭证',
},
dataApiKey: {
- label: 'User API key',
+ label: '用户 API 密钥',
},
userId: {
- label: 'User',
+ label: '用户',
placeholder: 'default',
},
},
+ errors: {
+ identitySwitchUnsupported: '当前服务器模式不支持切换身份。',
+ credentialMismatch: '所选凭证与目标账号和用户不匹配。',
+ rootRequired: '只有通过校验的 Root 凭证才能切换管理账号。',
+ },
},
settings: {
actions: {
- addAccount: '新增 account',
- addUser: '新增 user',
+ addAccount: '新增账号',
+ addUser: '新增用户',
cancel: '取消',
changeRole: '修改 {{user}} 的角色',
- confirmDeleteAccount: '永久删除 Account',
+ confirmDeleteAccount: '永久删除账号',
confirmRemoveUser: '删除用户',
confirmRoleChange: '确认修改',
copy: '复制',
currentIdentity: '当前身份',
- deleteAccount: '删除 Account',
+ deleteAccount: '删除账号',
refresh: '刷新',
regenerate: '重新生成',
removeUser: '删除 {{user}}',
@@ -436,42 +524,42 @@ const workspace = {
},
connection: {
accountListLimited:
- '当前 key 不能列出所有 account;如果它有 account-admin 权限,仍可管理选中的 account。',
- adminError: '校验 Root API Key 失败:{{message}}',
+ '当前密钥不能列出所有账号;如果它有账号管理员权限,仍可管理选中的账号。',
+ adminError: 'Root API 密钥校验失败:{{message}}',
description:
- '租户数据 API 使用 User API Key;控制 API 可单独使用 Root 或 account-admin key。',
- devMode: '当前为开发模式 — 身份自动确定,无需 API key。',
+ '租户数据 API 使用用户 API 密钥;控制 API 可另行使用 Root 或账号管理员 API 密钥。',
+ devMode: '当前为开发模式,身份会自动确定,无需 API 密钥。',
keyGuide: {
control: {
primary:
- '当前 User API Key 已可用于 Playground 和数据访问,普通用户无需配置控制凭证。',
+ '当前用户 API 密钥已可用于工作台和数据访问,普通用户无需配置控制凭证。',
secondary:
- '如需切换 Account 或管理用户,请向部署管理员索取 Root Key,或向当前 Account 管理员索取 Admin Key。Root Key 位于服务端 ov.conf 的 server.root_api_key。',
- title: '需要管理 Account 或用户?',
+ '如需切换账号或管理用户,请向部署管理员索取 Root API 密钥,或向当前账号管理员索取管理员 API 密钥。Root API 密钥位于服务端 ov.conf 的 server.root_api_key。',
+ title: '需要管理账号或用户?',
},
data: {
primary:
- 'Root/Admin API Key 主要用于管理操作,Playground 和租户数据访问需要绑定用户身份的 User API Key。',
+ 'Root 或管理员 API 密钥主要用于管理操作;工作台和租户数据 API 需要绑定用户身份的用户 API 密钥。',
secondary:
- '请在「用户管理」中选择、创建用户或重新生成 User Key,然后将它用作 User API Key。',
- title: '还缺少 User API Key',
+ '请在“用户管理”中选择或创建用户,或者重新生成用户密钥,然后将其用作用户 API 密钥。',
+ title: '还缺少用户 API 密钥',
},
empty: {
- primary: '普通用户:请向当前 Account 管理员索取 User API Key。',
+ primary: '普通用户:请向当前账号管理员索取用户 API 密钥。',
secondary:
- '部署管理员:Root API Key 位于服务端 ov.conf 的 server.root_api_key;填入后可在「用户管理」中创建或重新生成 User Key。',
- title: '还没有 OpenViking API Key?',
+ '部署管理员:Root API 密钥位于服务端 ov.conf 的 server.root_api_key;填入后可在“用户管理”中创建或重新生成用户密钥。',
+ title: '还没有 OpenViking API 密钥?',
},
- learnMore: '查看 API Key 获取方式',
+ learnMore: '查看 API 密钥获取方式',
trusted: {
primary:
- '当前 Trusted 服务启用了 Root Key 校验,浏览器需要配置同一 Root API Key 才能访问管理和租户数据接口。',
+ '当前 Trusted 服务启用了 Root API 密钥校验。浏览器需要配置相同的密钥,才能访问管理接口和租户数据接口。',
secondary:
- '请向部署管理员索取 Root Key;它位于服务端 ov.conf 的 server.root_api_key。Trusted 模式的数据身份由 Account/User 断言确定,不需要 User API Key。',
- title: 'Trusted 服务需要 Root API Key',
+ '请向部署管理员索取 Root API 密钥;它位于服务端 ov.conf 的 server.root_api_key。Trusted 模式的数据身份由账号和用户断言确定,不需要用户 API 密钥。',
+ title: 'Trusted 服务需要 Root API 密钥',
},
},
- rootHint: '用于列出 account / user,以及生成或轮换 key。',
+ rootHint: '用于列出账号和用户,以及生成或轮换密钥。',
title: '连接设置',
unsupportedAuthMode: {
description:
@@ -479,7 +567,7 @@ const workspace = {
primary: '该服务器配置了 {{mode}} 认证。',
title: '不支持的认证模式',
},
- userHint: '供 Playground 和租户数据 API 使用。',
+ userHint: '供工作台和租户数据 API 使用。',
},
connectionPage: {
description: '配置 OpenViking 服务连接、控制面凭证和当前数据访问凭证。',
@@ -488,15 +576,14 @@ const workspace = {
dialogs: {
addAccount: {
description:
- '创建一个工作区 account 和第一个 admin user。新 key 只会在创建后展示一次。',
- title: '新增 account',
+ '创建一个工作区账号和首位管理员用户。新密钥只会在创建后展示一次。',
+ title: '新增账号',
},
addUser: {
currentAccountDescription:
- '在 {{accountId}} 空间下创建用户。生成的 key 只会在创建后展示一次。',
- description:
- '在已有 account 下注册 user。生成的 key 只会在创建后展示一次。',
- title: '新增 user',
+ '在 {{accountId}} 空间下创建用户。生成的密钥只会在创建后展示一次。',
+ description: '在已有账号下注册用户。生成的密钥只会在创建后展示一次。',
+ title: '新增用户',
},
changeRole: {
description:
@@ -504,45 +591,54 @@ const workspace = {
title: '修改用户角色?',
},
deleteAccount: {
- confirmHint: 'Account 名称必须完全一致。',
+ confirmHint: '账号名称必须完全一致。',
confirmLabel: '请输入 {{account}} 以确认',
description:
- '此操作将永久删除 {{account}},之后将无法再访问该 Account,且无法撤销。',
- title: '删除这个 Account?',
+ '此操作将永久删除 {{account}},之后将无法再访问该账号,且无法撤销。',
+ title: '删除这个账号?',
},
regenerate: {
description:
- '要重新生成 {{account}} / {{user}} 的 API key 吗?当前 key 会立即失效。',
- title: '重新生成 API key?',
+ '要重新生成 {{account}} / {{user}} 的 API 密钥吗?当前密钥会立即失效。',
+ title: '重新生成 API 密钥?',
},
removeUser: {
description:
- '确定从 {{account}} 空间移除 {{user}} 吗?该用户的 API Key 会立即失效,此操作不可撤销。',
+ '确定从 {{account}} 空间移除 {{user}} 吗?该用户的 API 密钥会立即失效,此操作不可撤销。',
title: '删除用户?',
},
},
empty: {
adminDescription:
- '使用 root 或 account admin API key 后,可以列出用户、复制 key、新增身份或轮换凭证。',
- adminTitle: '需要 admin 权限',
- usersDescription: '创建一个 user 来生成第一个 API key。',
- usersTitle: '选中的 accounts 下没有 user',
+ '使用 Root 或账号管理员 API 密钥后,可以列出用户、复制密钥、新增身份或轮换凭证。',
+ adminTitle: '需要管理员权限',
+ usersDescription: '创建一个用户以生成第一个 API 密钥。',
+ usersTitle: '选中的账号下没有用户',
},
fields: {
- account: 'Account',
- adminUser: 'Admin user',
- adminApiKey: 'Admin API key',
- apiKey: 'API key',
+ account: '账号',
+ adminUser: '管理员用户',
+ adminApiKey: '管理员 API 密钥',
+ apiKey: 'API 密钥',
baseUrl: '服务地址',
- dataApiKey: 'User API key',
- rootApiKey: 'Root or Admin API Key',
- userApiKey: 'User API Key',
+ dataApiKey: '用户 API 密钥',
+ rootApiKey: 'Root 或管理员 API 密钥',
+ userApiKey: '用户 API 密钥',
role: '角色',
- user: 'User',
+ user: '用户',
},
health: {
admin: '控制面权限',
data: '数据访问',
+ detail: {
+ accountAdminAvailable: '账号管理员权限可用',
+ adminModeRequired: '管理 API 需要使用 API 密钥模式或 Trusted 模式',
+ controlKeyRequired: '需要 Root 或账号管理员 API 密钥',
+ dataKeyRequired: '需要用户或账号管理员 API 密钥',
+ rootAvailable: 'Root 管理权限可用',
+ tenantDataAvailable: '租户数据访问可用',
+ trustedIdentityRequired: 'Trusted 模式的数据访问需要账号和用户信息',
+ },
state: {
checking: '检查中',
error: '异常',
@@ -554,51 +650,50 @@ const workspace = {
description:
'请现在复制保存。离开当前状态后,OpenViking 可能只展示前缀。',
dismiss: '收起',
- title: '新的 API key',
+ title: '新的 API 密钥',
},
loading: '正在加载身份...',
management: {
- accountFilter: 'Accounts',
+ accountFilter: '账号',
accessDeniedDescription:
- '只有配置并通过校验的 Root 或 Account Admin API Key 才能管理用户。',
+ '只有配置并通过校验的 Root 或账号管理员 API 密钥才能管理用户。',
accessDeniedTitle: '无用户管理权限',
currentAccountDescription: '管理 {{account}} 空间下的用户和访问凭证。',
- description:
- '查看选中 accounts 下的 users 和凭证,并在网页端新增 user 或轮换 key。',
+ description: '查看选中账号下的用户和凭证,并在网页端新增用户或轮换密钥。',
memberListDescription:
- '“切换身份”会将该用户设为 Playground、检索等数据页面的访问身份,不会改变当前 Root/Admin 管理凭证。',
+ '“切换身份”会将该用户设为工作台、检索等数据页面的访问身份,不会改变当前 Root 或管理员凭证。',
memberListDescriptionRoot:
- '可直接修改成员角色;“切换身份”只会改变 Playground、检索等数据页面的访问身份,不会改变当前 Root 管理凭证。',
+ '可直接修改成员角色。“切换身份”只会改变工作台、检索等数据页面的访问身份,不会改变当前 Root 管理凭证。',
memberListTitle: '空间成员',
cannotRemoveCurrentIdentity: '不能删除当前正在使用的身份。',
cannotRemoveLastManager: '不能删除空间内最后一个管理员。',
- noUsableKey: '该用户没有可用于数据访问的明文 API Key。',
+ noUsableKey: '该用户没有可用于数据访问的明文 API 密钥。',
openConnection: '打开连接设置',
title: '用户管理',
},
page: {
adminDescription:
- '配置当前 OpenViking Studio 身份,并管理账号、用户和 API key。',
+ '配置当前 OpenViking Studio 身份,并管理账号、用户和 API 密钥。',
description:
- '配置当前 OpenViking Studio 的服务地址和 API key,查看当前身份下的数据。',
- title: '连接与身份',
+ '配置当前 OpenViking Studio 的服务地址和 API 密钥,查看当前身份下的数据。',
+ title: '连接设置',
},
placeholders: {
account: 'team-account',
- adminApiKey: 'Root 或 account-admin key',
- apiKey: '输入 X-API-Key 或 Bearer token',
+ adminApiKey: 'Root 或账号管理员 API 密钥',
+ apiKey: '输入 X-API-Key 或 Bearer 令牌',
baseUrl: 'http://127.0.0.1:1933',
- devModeApiKey: '[dev mode,无需 API key]',
- userApiKey: 'User API key',
+ devModeApiKey: '[开发模式,无需 API 密钥]',
+ userApiKey: '用户 API 密钥',
user: 'default',
},
roles: {
- admin: 'Admin',
+ admin: '管理员',
root: 'Root',
- user: 'User',
+ user: '用户',
},
serverMode: {
- api_key: 'API key 模式',
+ api_key: 'API 密钥模式',
checking: '检查中...',
dev: '开发模式',
ldap: 'LDAP 模式',
@@ -607,29 +702,29 @@ const workspace = {
trusted: 'Trusted 模式',
},
stats: {
- accounts: 'Accounts 总数',
- apiKeys: '可见 API keys',
- users: 'Users',
+ accounts: '账号总数',
+ apiKeys: '可见 API 密钥',
+ users: '用户数',
},
table: {
- account: 'Account',
+ account: '账号',
actions: '操作',
- apiKey: 'API key',
+ apiKey: 'API 密钥',
role: '角色',
- user: 'User',
+ user: '用户',
},
toast: {
- accountCreated: 'Account 已创建',
+ accountCreated: '账号已创建',
accountDeleted: '{{account}} 已删除',
accountDeletedRecoveryFailed:
- 'Account 已删除,但无法加载剩余 Account 列表:{{error}}',
+ '账号已删除,但无法加载剩余账号列表:{{error}}',
connectionSaved: '连接已保存',
copyFailed: '复制失败',
copied: '已复制',
dataKeySelected: '已切换数据访问身份',
- keyRegenerated: 'API key 已重新生成',
+ keyRegenerated: 'API 密钥已重新生成',
roleUpdated: '{{user}} 的角色已修改为 {{role}}',
- userCreated: 'User 已创建',
+ userCreated: '用户已创建',
userRemoved: '{{user}} 已删除',
},
},
@@ -675,35 +770,35 @@ const workspace = {
},
page: {
description:
- '按产品需求对齐首页内容:菜单入口、上下文数据量、今日 tokens、今日检索、Agent 访问、tokens 趋势和上下文提交统计。',
+ '汇总上下文数据、今日检索、Token 用量和上下文提交等运行数据。',
eyebrow: 'OpenViking Studio',
settings: '连接与设置',
- title: 'Overview',
+ title: '概览',
},
requestFailed: '请求失败',
todayRetrievals: {
description:
- '展示用户或 Agent 今日使用语义检索 find() 和 search() 的成功调用次数,每天零点刷新。',
- find: 'find',
- search: 'search',
+ '展示今日基础检索(find())和增强检索(search())的成功调用次数,每天零点刷新。',
+ find: '基础检索',
+ search: '增强检索',
title: '今日检索次数',
},
todayTokens: {
- description: '展示今日实时 token 消耗,每天零点刷新。',
- embeddingInput: 'Embedding input tokens',
- title: '今日 Tokens 消耗',
- vlmInput: 'VLM input tokens',
- vlmOutput: 'VLM output tokens',
+ description: '展示今日实时 Token 用量,每天零点刷新。',
+ embeddingInput: 'Embedding 输入 Token',
+ title: '今日 Token 用量',
+ vlmInput: 'VLM 输入 Token',
+ vlmOutput: 'VLM 输出 Token',
},
tokenTrend: {
description:
- '展示最近 14 天每日 token 消耗,包含 VLM 输入、VLM 输出和 Embedding 输入。',
- empty: '最近 14 天暂无 token 消耗',
- title: 'tokens 总消耗统计',
+ '展示最近 14 天的每日 Token 用量,包括 VLM 输入、VLM 输出和 Embedding 输入。',
+ empty: '最近 14 天暂无 Token 用量',
+ title: 'Token 总用量统计',
},
- usageDisabled: 'Usage/Audit 未初始化,暂无实时统计。',
+ usageDisabled: '用量和审计功能尚未初始化,暂无实时统计。',
usageAccessRequired:
- '当前连接未获取到 admin/root 权限,无法显示 Usage/Audit 数据。请在连接与身份中配置具备 Console Usage/Audit 权限的 API Key。',
+ '当前连接没有管理员或 Root 权限,无法显示用量和审计数据。请在“连接设置”中配置具备控制台用量和审计权限的 API 密钥。',
},
} as const
diff --git a/web-studio/src/lib/admin.ts b/web-studio/src/lib/admin.ts
index 6385ddc00..ca34ad487 100644
--- a/web-studio/src/lib/admin.ts
+++ b/web-studio/src/lib/admin.ts
@@ -61,8 +61,18 @@ export type UpdateUserRoleInput = {
export type ProbeState = 'ok' | 'error' | 'skipped'
+export type CapabilityDetailCode =
+ | 'accountAdminAvailable'
+ | 'adminModeRequired'
+ | 'controlKeyRequired'
+ | 'dataKeyRequired'
+ | 'rootAvailable'
+ | 'tenantDataAvailable'
+ | 'trustedIdentityRequired'
+
export type CapabilityProbeResult = {
detail?: string
+ detailCode?: CapabilityDetailCode
state: ProbeState
}
@@ -163,7 +173,7 @@ async function probeAdminAccess(
}
if (input.serverMode === 'dev') {
return {
- detail: 'Admin API requires API-key or trusted mode',
+ detailCode: 'adminModeRequired',
state: 'skipped',
}
}
@@ -174,7 +184,7 @@ async function probeAdminAccess(
const controlKey = input.adminApiKey.trim()
if (input.serverMode === 'api_key' && !controlKey) {
return {
- detail: 'A root or account-admin API key is required',
+ detailCode: 'controlKeyRequired',
state: 'skipped',
}
}
@@ -186,7 +196,7 @@ async function probeAdminAccess(
try {
await client.get('/api/v1/admin/accounts', { headers })
return {
- detail: 'Root admin control available',
+ detailCode: 'rootAvailable',
state: 'ok',
}
} catch (accountsError) {
@@ -210,7 +220,7 @@ async function probeAdminAccess(
},
})
return {
- detail: 'Account admin control available',
+ detailCode: 'accountAdminAvailable',
state: 'ok',
}
} catch (usersError) {
@@ -230,7 +240,7 @@ async function probeDataAccess(
}
if (input.serverMode === 'api_key' && !input.apiKey) {
return {
- detail: 'A user or account-admin API key is required',
+ detailCode: 'dataKeyRequired',
state: 'skipped',
}
}
@@ -239,7 +249,7 @@ async function probeDataAccess(
(!input.accountId.trim() || !input.userId.trim())
) {
return {
- detail: 'Trusted mode data access requires account and user',
+ detailCode: 'trustedIdentityRequired',
state: 'skipped',
}
}
@@ -263,7 +273,7 @@ async function probeDataAccess(
},
})
return {
- detail: 'Tenant data access available',
+ detailCode: 'tenantDataAvailable',
state: 'ok',
}
} catch (error) {
diff --git a/web-studio/src/routes/monitoring/-components/observer-status-content.test.tsx b/web-studio/src/routes/monitoring/-components/observer-status-content.test.tsx
new file mode 100644
index 000000000..4b8bdeb50
--- /dev/null
+++ b/web-studio/src/routes/monitoring/-components/observer-status-content.test.tsx
@@ -0,0 +1,60 @@
+// @vitest-environment jsdom
+
+import { cleanup, render, screen } from '@testing-library/react'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+import { ObserverStatusContent } from './observer-status-content'
+
+const translations: Record<string, string> = {
+ 'detail.columns.contextType': '上下文类型',
+ 'detail.columns.count': '次数',
+ 'detail.columns.metric': '指标',
+ 'detail.columns.operation': '操作',
+ 'detail.columns.queries': '查询次数',
+ 'detail.columns.value': '数值',
+ 'detail.metrics.totalOperations': '操作总数',
+ 'detail.values.unknown': '未知',
+}
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (key: string) => translations[key] ?? key,
+ }),
+}))
+
+afterEach(cleanup)
+
+describe('ObserverStatusContent', () => {
+ it('renders localized labels from adjacent observer tables', () => {
+ render(
+ <ObserverStatusContent
+ status={`
++-----------+-------+
+| Operation | Count |
++-----------+-------+
+| read | 12 |
++-----------+-------+
++------------------+-------+
+| Metric | Value |
++------------------+-------+
+| Total Operations | 12 |
++------------------+-------+
++--------------+---------+
+| Context Type | Queries |
++--------------+---------+
+| unknown | 8 |
++--------------+---------+
+`}
+ />,
+ )
+
+ expect(screen.getByRole('columnheader', { name: '指标' })).toBeTruthy()
+ expect(screen.getByText('操作总数')).toBeTruthy()
+ expect(
+ screen.getByRole('columnheader', { name: '上下文类型' }),
+ ).toBeTruthy()
+ expect(screen.getByText('未知')).toBeTruthy()
+ expect(screen.queryByText('Metric')).toBeNull()
+ expect(screen.queryByText('unknown')).toBeNull()
+ })
+})
diff --git a/web-studio/src/routes/monitoring/-components/observer-status-content.tsx b/web-studio/src/routes/monitoring/-components/observer-status-content.tsx
new file mode 100644
index 000000000..bb9ca8dac
--- /dev/null
+++ b/web-studio/src/routes/monitoring/-components/observer-status-content.tsx
@@ -0,0 +1,74 @@
+import * as React from 'react'
+import { useTranslation } from 'react-i18next'
+
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '#/components/ui/table'
+import { localizeObserverStatusBlocks } from '../-lib/localize-observer-status'
+import { parseObserverStatus } from '../-lib/parse-status'
+
+export function ObserverStatusContent({ status }: { status: string }) {
+ const { t } = useTranslation('monitoringPage')
+ const blocks = React.useMemo(
+ () => localizeObserverStatusBlocks(parseObserverStatus(status), t),
+ [status, t],
+ )
+
+ if (blocks.length === 0) {
+ return <p className="text-sm text-muted-foreground">{t('detail.noData')}</p>
+ }
+
+ return (
+ <div className="grid gap-4">
+ {blocks.map((block, blockIndex) =>
+ block.kind === 'text' ? (
+ <p
+ key={`${block.value}-${blockIndex}`}
+ className="rounded-lg border bg-muted/20 px-3 py-2 text-sm text-muted-foreground"
+ >
+ {block.value}
+ </p>
+ ) : (
+ <div
+ key={`table-${blockIndex}`}
+ className="overflow-x-auto rounded-lg border"
+ >
+ <Table>
+ <TableHeader>
+ <TableRow className="bg-muted/20 hover:bg-muted/20">
+ {block.headers.map((header, headerIndex) => (
+ <TableHead
+ key={`${header}-${headerIndex}`}
+ className="whitespace-nowrap"
+ >
+ {header}
+ </TableHead>
+ ))}
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {block.rows.map((row, rowIndex) => (
+ <TableRow key={`row-${rowIndex}`}>
+ {row.map((cell, cellIndex) => (
+ <TableCell
+ key={`${cell}-${cellIndex}`}
+ className="whitespace-nowrap font-mono text-xs"
+ >
+ {cell}
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </div>
+ ),
+ )}
+ </div>
+ )
+}
diff --git a/web-studio/src/routes/monitoring/-lib/localize-observer-status.test.ts b/web-studio/src/routes/monitoring/-lib/localize-observer-status.test.ts
new file mode 100644
index 000000000..d9eeb8157
--- /dev/null
+++ b/web-studio/src/routes/monitoring/-lib/localize-observer-status.test.ts
@@ -0,0 +1,88 @@
+import type { TFunction } from 'i18next'
+import { describe, expect, it } from 'vitest'
+
+import { localizeObserverStatusBlocks } from './localize-observer-status'
+
+const translations: Record<string, string> = {
+ 'detail.columns.contextType': '上下文类型',
+ 'detail.columns.metric': '指标',
+ 'detail.columns.queries': '查询次数',
+ 'detail.columns.value': '数值',
+ 'detail.metrics.totalOperations': '操作总数',
+ 'detail.statusText.mount': '挂载点:{{path}}(插件:{{plugin}})',
+ 'detail.values.total': '合计',
+ 'detail.values.unknown': '未知',
+ 'queue.totalRow': '合计',
+}
+
+const t = ((key: string, options?: Record<string, unknown>) => {
+ let value = translations[key] ?? key
+ for (const [name, replacement] of Object.entries(options ?? {})) {
+ value = value.replace(`{{${name}}}`, String(replacement))
+ }
+ return value
+}) as TFunction<'monitoringPage'>
+
+describe('localizeObserverStatusBlocks', () => {
+ it('localizes registered observer labels and preserves technical values', () => {
+ expect(
+ localizeObserverStatusBlocks(
+ [
+ {
+ headers: ['Metric', 'Value'],
+ kind: 'table',
+ rows: [['Total Operations', '12']],
+ },
+ {
+ headers: ['Context Type', 'Queries'],
+ kind: 'table',
+ rows: [
+ ['unknown', '8'],
+ ['resource', '4'],
+ ],
+ },
+ {
+ kind: 'text',
+ value: 'Mount: /local (plugin: localfs)',
+ },
+ ],
+ t,
+ ),
+ ).toEqual([
+ {
+ headers: ['指标', '数值'],
+ kind: 'table',
+ rows: [['操作总数', '12']],
+ },
+ {
+ headers: ['上下文类型', '查询次数'],
+ kind: 'table',
+ rows: [
+ ['未知', '8'],
+ ['resource', '4'],
+ ],
+ },
+ {
+ kind: 'text',
+ value: '挂载点:/local(插件:localfs)',
+ },
+ ])
+ })
+
+ it('localizes total rows only in summary columns', () => {
+ const [block] = localizeObserverStatusBlocks(
+ [
+ {
+ headers: ['Queue', 'Collection', 'Provider', 'Model', 'Operation'],
+ kind: 'table',
+ rows: [['TOTAL', 'TOTAL', 'TOTAL', 'TOTAL', 'TOTAL']],
+ },
+ ],
+ t,
+ )
+
+ expect(block).toMatchObject({
+ rows: [['合计', '合计', 'TOTAL', 'TOTAL', 'TOTAL']],
+ })
+ })
+})
diff --git a/web-studio/src/routes/monitoring/-lib/localize-observer-status.ts b/web-studio/src/routes/monitoring/-lib/localize-observer-status.ts
new file mode 100644
index 000000000..54f5da199
--- /dev/null
+++ b/web-studio/src/routes/monitoring/-lib/localize-observer-status.ts
@@ -0,0 +1,179 @@
+import type { TFunction } from 'i18next'
+
+import type { ObserverStatusBlock } from './parse-status'
+
+type MonitoringTranslator = TFunction<'monitoringPage'>
+
+const headerKeys = {
+ 'Avg (ms)': 'detail.columns.averageMs',
+ Calls: 'detail.columns.calls',
+ Collection: 'detail.columns.collection',
+ Completion: 'detail.columns.completion',
+ 'Context Type': 'detail.columns.contextType',
+ Count: 'detail.columns.count',
+ Errors: 'queue.errors',
+ 'In Progress': 'queue.processing',
+ 'Index Count': 'detail.columns.indexCount',
+ 'Last Updated': 'detail.columns.lastUpdated',
+ 'Max (ms)': 'detail.columns.maximumMs',
+ Metric: 'detail.columns.metric',
+ 'Min (ms)': 'detail.columns.minimumMs',
+ Model: 'detail.columns.model',
+ Operation: 'detail.columns.operation',
+ Pending: 'queue.pending',
+ Processed: 'queue.processed',
+ Prompt: 'detail.columns.prompt',
+ Provider: 'detail.columns.provider',
+ Queries: 'detail.columns.queries',
+ Queue: 'queue.queueName',
+ Requeued: 'queue.requeued',
+ Status: 'detail.columns.status',
+ Total: 'detail.columns.total',
+ Value: 'detail.columns.value',
+ 'Vector Count': 'detail.columns.vectorCount',
+} as const
+
+const metricKeys = {
+ 'Avg Latency (ms)': 'detail.metrics.averageLatency',
+ 'Avg Results/Query': 'detail.metrics.averageResults',
+ 'Avg Score': 'detail.metrics.averageScore',
+ 'Max Latency (ms)': 'detail.metrics.maximumLatency',
+ 'Overall Avg (ms)': 'detail.metrics.overallAverage',
+ 'Rerank Fallback': 'detail.metrics.rerankFallback',
+ 'Rerank Used': 'detail.metrics.rerankUsed',
+ 'Score Range': 'detail.metrics.scoreRange',
+ 'Total Operations': 'detail.metrics.totalOperations',
+ 'Total Queries': 'detail.metrics.totalQueries',
+ 'Total Results': 'detail.metrics.totalResults',
+ 'Total Time (s)': 'detail.metrics.totalTime',
+ 'Zero-Result Queries': 'detail.metrics.zeroResultQueries',
+ 'Zero-Result Rate': 'detail.metrics.zeroResultRate',
+} as const
+
+const queueKeys = {
+ add_resource: 'queue.addResource',
+ addresource: 'queue.addResource',
+ embedding: 'queue.embedding',
+ external_parse: 'queue.externalParse',
+ externalparse: 'queue.externalParse',
+ semantic: 'queue.semantic',
+ 'semantic-nodes': 'queue.semanticNodes',
+ semantic_nodes: 'queue.semanticNodes',
+ session_commit: 'queue.sessionCommit',
+ sessioncommit: 'queue.sessionCommit',
+ total: 'queue.totalRow',
+ user_deletion: 'queue.userDeletion',
+ userdeletion: 'queue.userDeletion',
+} as const
+
+const statusTextKeys = {
+ 'Embedding Models:': 'detail.statusText.embeddingModels',
+ 'No collections found.': 'detail.statusText.noCollections',
+ 'No filesystem statistics available.':
+ 'detail.statusText.filesystemUnavailable',
+ 'No model usage data available.': 'detail.statusText.modelUsageUnavailable',
+ 'No operation statistics recorded yet.':
+ 'detail.statusText.noFilesystemOperations',
+ 'No queue status data available.': 'detail.statusText.queueUnavailable',
+ 'No retrieval queries recorded.': 'detail.statusText.retrievalUnavailable',
+ 'Not initialized': 'detail.statusText.notInitialized',
+ 'Rerank Models:': 'detail.statusText.rerankModels',
+ 'VikingDB manager not initialized.': 'detail.statusText.vikingdbUnavailable',
+ 'VLM Models:': 'detail.statusText.vlmModels',
+} as const
+
+function translateMappedValue(
+ value: string,
+ mapping: Record<string, string>,
+ t: MonitoringTranslator,
+): string {
+ const key = mapping[value]
+ return key ? t(key) : value
+}
+
+function localizeCell(
+ cell: string,
+ header: string | undefined,
+ t: MonitoringTranslator,
+): string {
+ if (header === 'Queue') {
+ return translateMappedValue(cell.toLowerCase(), queueKeys, t)
+ }
+ if (header === 'Metric') return translateMappedValue(cell, metricKeys, t)
+ if (header === 'Collection' && cell === 'TOTAL') {
+ return t('detail.values.total')
+ }
+
+ if (header === 'Status') {
+ if (cell === 'OK') return t('detail.values.ok')
+ if (cell === 'ERROR') return t('detail.values.error')
+ if (cell === 'configured') return t('detail.values.configured')
+ }
+
+ if (
+ cell === 'unknown' &&
+ (header === 'Provider' || header === 'Context Type')
+ ) {
+ return t('detail.values.unknown')
+ }
+
+ return cell
+}
+
+function localizeText(value: string, t: MonitoringTranslator): string {
+ const mapped = translateMappedValue(value, statusTextKeys, t)
+ if (mapped !== value) return mapped
+
+ const mount = value.match(/^Mount: (.+) \(plugin: (.+)\)$/)
+ if (mount) {
+ return t('detail.statusText.mount', {
+ path: mount[1],
+ plugin: mount[2],
+ })
+ }
+
+ const filesystemError = value.match(
+ /^Error retrieving filesystem statistics: (.+)$/,
+ )
+ if (filesystemError) {
+ return t('detail.statusText.filesystemError', {
+ error: filesystemError[1],
+ })
+ }
+
+ const lockStatus = [
+ [/^Active locks: (.+)$/, 'activeLocks'],
+ [/^Waiting locks: (.+)$/, 'waitingLocks'],
+ [/^Stale locks removed: (.+)$/, 'staleLocksRemoved'],
+ [/^Conflicts: (.+)$/, 'conflicts'],
+ ] as const
+ for (const [pattern, key] of lockStatus) {
+ const match = value.match(pattern)
+ if (match) {
+ return t(`detail.statusText.${key}`, { count: match[1] })
+ }
+ }
+
+ return value
+}
+
+export function localizeObserverStatusBlocks(
+ blocks: ObserverStatusBlock[],
+ t: MonitoringTranslator,
+): ObserverStatusBlock[] {
+ return blocks.map((block) => {
+ if (block.kind === 'text') {
+ return { kind: 'text', value: localizeText(block.value, t) }
+ }
+
+ return {
+ headers: block.headers.map((header) =>
+ translateMappedValue(header, headerKeys, t),
+ ),
+ kind: 'table',
+ rows: block.rows.map((row) =>
+ row.map((cell, index) => localizeCell(cell, block.headers[index], t)),
+ ),
+ }
+ })
+}
diff --git a/web-studio/src/routes/monitoring/-lib/parse-status.test.ts b/web-studio/src/routes/monitoring/-lib/parse-status.test.ts
index 02d284c2c..75da7ed1e 100644
--- a/web-studio/src/routes/monitoring/-lib/parse-status.test.ts
+++ b/web-studio/src/routes/monitoring/-lib/parse-status.test.ts
@@ -29,4 +29,32 @@ describe('parseObserverStatus', () => {
},
])
})
+
+ it('keeps adjacent ASCII tables as separate blocks', () => {
+ expect(
+ parseObserverStatus(`
++-----------+-------+
+| Operation | Count |
++-----------+-------+
+| read | 12 |
++-----------+-------+
++------------------+-------+
+| Metric | Value |
++------------------+-------+
+| Total Operations | 12 |
++------------------+-------+
+`),
+ ).toEqual([
+ {
+ headers: ['Operation', 'Count'],
+ kind: 'table',
+ rows: [['read', '12']],
+ },
+ {
+ headers: ['Metric', 'Value'],
+ kind: 'table',
+ rows: [['Total Operations', '12']],
+ },
+ ])
+ })
})
diff --git a/web-studio/src/routes/monitoring/-lib/parse-status.ts b/web-studio/src/routes/monitoring/-lib/parse-status.ts
index 4ab37d596..10140a9cd 100644
--- a/web-studio/src/routes/monitoring/-lib/parse-status.ts
+++ b/web-studio/src/routes/monitoring/-lib/parse-status.ts
@@ -25,31 +25,34 @@ export function parseObserverStatus(status: string): ObserverStatusBlock[] {
for (let index = 0; index < lines.length; ) {
if (lines[index].startsWith('+') && lines[index + 1]?.startsWith('|')) {
+ const headers = parseRow(lines[index + 1])
const rows: string[][] = []
- index += 1
+ index += 2
+
+ if (lines[index]?.startsWith('+')) index += 1
while (index < lines.length) {
const line = lines[index]
if (line.startsWith('|')) {
rows.push(parseRow(line))
+ index += 1
+ continue
}
- index += 1
- if (
- line.startsWith('+') &&
- !lines[index]?.startsWith('|') &&
- !lines[index]?.startsWith('+')
- ) {
+
+ if (line.startsWith('+')) {
+ index += 1
+ if (lines[index]?.startsWith('|')) continue
break
}
- }
- if (rows.length > 0) {
- blocks.push({
- headers: rows[0],
- kind: 'table',
- rows: rows.slice(1),
- })
+ break
}
+
+ blocks.push({
+ headers,
+ kind: 'table',
+ rows,
+ })
continue
}
diff --git a/web-studio/src/routes/monitoring/route.tsx b/web-studio/src/routes/monitoring/route.tsx
index 6120d16a6..5a0c2a860 100644
--- a/web-studio/src/routes/monitoring/route.tsx
+++ b/web-studio/src/routes/monitoring/route.tsx
@@ -20,18 +20,10 @@ import { Alert, AlertDescription, AlertTitle } from '#/components/ui/alert'
import { Badge } from '#/components/ui/badge'
import { Button } from '#/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '#/components/ui/card'
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from '#/components/ui/table'
import { useAppConnection } from '#/hooks/use-app-connection'
import { getHealth, getObserverSystem, getOvResult } from '#/lib/ov-client'
import { cn } from '#/lib/utils'
-import { parseObserverStatus } from './-lib/parse-status'
+import { ObserverStatusContent } from './-components/observer-status-content'
import { stripVersionPrefix } from './-lib/version'
export const Route = createFileRoute('/monitoring')({
@@ -87,9 +79,7 @@ async function fetchMonitoringOverview(): Promise<MonitoringOverview> {
getOvResult<Record<string, unknown>>(getHealth()),
getOvResult<Record<string, unknown>>(getObserverSystem()),
])
- const rawComponents = isRecord(observer.components)
- ? observer.components
- : {}
+ const rawComponents = isRecord(observer.components) ? observer.components : {}
const components: Record<string, ObserverComponent> = {}
for (const [name] of MONITOR_TYPES) {
@@ -110,13 +100,7 @@ async function fetchMonitoringOverview(): Promise<MonitoringOverview> {
}
}
-function HealthBadge({
- healthy,
- label,
-}: {
- healthy: boolean
- label: string
-}) {
+function HealthBadge({ healthy, label }: { healthy: boolean; label: string }) {
return (
<Badge
variant="outline"
@@ -138,66 +122,6 @@ function HealthBadge({
)
}
-function ObserverStatusContent({ status }: { status: string }) {
- const { t } = useTranslation('monitoringPage')
- const blocks = React.useMemo(() => parseObserverStatus(status), [status])
-
- if (blocks.length === 0) {
- return (
- <p className="text-sm text-muted-foreground">{t('detail.noData')}</p>
- )
- }
-
- return (
- <div className="grid gap-4">
- {blocks.map((block, blockIndex) =>
- block.kind === 'text' ? (
- <p
- key={`${block.value}-${blockIndex}`}
- className="rounded-lg border bg-muted/20 px-3 py-2 text-sm text-muted-foreground"
- >
- {block.value}
- </p>
- ) : (
- <div
- key={`table-${blockIndex}`}
- className="overflow-x-auto rounded-lg border"
- >
- <Table>
- <TableHeader>
- <TableRow className="bg-muted/20 hover:bg-muted/20">
- {block.headers.map((header, headerIndex) => (
- <TableHead
- key={`${header}-${headerIndex}`}
- className="whitespace-nowrap"
- >
- {header}
- </TableHead>
- ))}
- </TableRow>
- </TableHeader>
- <TableBody>
- {block.rows.map((row, rowIndex) => (
- <TableRow key={`row-${rowIndex}`}>
- {row.map((cell, cellIndex) => (
- <TableCell
- key={`${cell}-${cellIndex}`}
- className="whitespace-nowrap font-mono text-xs"
- >
- {cell}
- </TableCell>
- ))}
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </div>
- ),
- )}
- </div>
- )
-}
-
function MonitoringRoute() {
const { i18n, t } = useTranslation('monitoringPage')
const { identityScopeKey, serverMode } = useAppConnection()
diff --git a/web-studio/src/routes/resources/-components/upload-task-dialog.tsx b/web-studio/src/routes/resources/-components/upload-task-dialog.tsx
index e5ffb1b62..cb8593f27 100644
--- a/web-studio/src/routes/resources/-components/upload-task-dialog.tsx
+++ b/web-studio/src/routes/resources/-components/upload-task-dialog.tsx
@@ -26,7 +26,7 @@ function TaskStatusBadge({ status }: { status: ResourceUploadTask['status'] }) {
if (status === 'failed') {
return (
- <Badge variant="secondary" className="bg-rose-500/12 text-black">
+ <Badge variant="secondary" className="bg-rose-500/12 text-destructive">
{t('processingTasks.status.failed')}
</Badge>
)
@@ -105,7 +105,8 @@ export function UploadTaskDialog({
const isFailed = task.status === 'failed'
const isExpanded = expandedTaskIds.has(task.id)
const hasDetail =
- isFailed && (task.errorCode || task.errorMessage)
+ isFailed &&
+ (task.errorCode || task.errorMessage || task.errorDetail)
return (
<div
@@ -155,15 +156,21 @@ export function UploadTaskDialog({
{hasDetail && isExpanded ? (
<div className="space-y-1 border-t border-border/40 bg-rose-500/6 px-10 py-3 text-sm">
{task.errorCode ? (
- <div className="font-mono text-black">
+ <div className="font-mono text-foreground">
{task.errorCode}
</div>
) : null}
{task.errorMessage ? (
- <div className="text-black">
+ <div className="text-foreground">
{task.errorMessage}
</div>
) : null}
+ {task.errorDetail &&
+ task.errorDetail !== task.errorMessage ? (
+ <div className="font-mono text-xs text-foreground">
+ {task.errorDetail}
+ </div>
+ ) : null}
</div>
) : null}
</div>
diff --git a/web-studio/src/routes/resources/-hooks/use-resource-upload.test.tsx b/web-studio/src/routes/resources/-hooks/use-resource-upload.test.tsx
index 6efaa52a2..28428f65f 100644
--- a/web-studio/src/routes/resources/-hooks/use-resource-upload.test.tsx
+++ b/web-studio/src/routes/resources/-hooks/use-resource-upload.test.tsx
@@ -9,6 +9,7 @@ import {
} from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
+import i18n from '#/i18n'
import {
ResourceUploadProvider,
useResourceUpload,
@@ -48,7 +49,7 @@ function UploadHarness({
onCompleted: () => void
onFailed?: () => void
}) {
- const { refreshTasks, startRemote } = useResourceUpload()
+ const { refreshTasks, startRemote, tasks } = useResourceUpload()
return (
<>
@@ -70,6 +71,7 @@ function UploadHarness({
data-testid="refresh"
onClick={() => void refreshTasks()}
/>
+ <output data-testid="task-error">{tasks[0]?.errorMessage}</output>
</>
)
}
@@ -150,4 +152,40 @@ describe('ResourceUploadProvider remote completion', () => {
await waitFor(() => expect(onFailed).toHaveBeenCalledOnce())
})
+
+ it('updates an empty server error fallback when the language changes', async () => {
+ const previousLanguage = i18n.language
+ try {
+ await i18n.changeLanguage('en')
+ apiMocks.getTasks.mockResolvedValue([
+ {
+ created_at: 1,
+ status: 'failed',
+ task_id: 'resource-task',
+ task_type: 'add_resource',
+ updated_at: 2,
+ },
+ ])
+
+ render(
+ <ResourceUploadProvider>
+ <UploadHarness onAccepted={vi.fn()} onCompleted={vi.fn()} />
+ </ResourceUploadProvider>,
+ )
+
+ await waitFor(() =>
+ expect(screen.getByTestId('task-error').textContent).toBe(
+ 'Processing failed',
+ ),
+ )
+
+ await i18n.changeLanguage('zh-CN')
+
+ await waitFor(() =>
+ expect(screen.getByTestId('task-error').textContent).toBe('处理失败'),
+ )
+ } finally {
+ await i18n.changeLanguage(previousLanguage)
+ }
+ })
})
diff --git a/web-studio/src/routes/resources/-hooks/use-resource-upload.tsx b/web-studio/src/routes/resources/-hooks/use-resource-upload.tsx
index ba89bbcb0..ba7fec916 100644
--- a/web-studio/src/routes/resources/-hooks/use-resource-upload.tsx
+++ b/web-studio/src/routes/resources/-hooks/use-resource-upload.tsx
@@ -1,6 +1,8 @@
import * as React from 'react'
+import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
+import i18n from '#/i18n'
import {
getTasks,
getOvResult,
@@ -45,7 +47,9 @@ export type ResourceUploadTask = {
createdAt: number
finishedAt: number | null
errorCode: string | null
+ errorDetail?: string | null
errorMessage: string | null
+ errorMessageOrigin?: 'fallback' | 'server' | undefined
rootUri: string | null
}
@@ -175,6 +179,7 @@ export function ResourceUploadProvider({
}: {
children: React.ReactNode
}) {
+ const { t } = useTranslation('resources', { i18n })
const [tasks, setTasks] = React.useState<ResourceUploadTask[]>([])
const [remoteState, setRemoteState] =
React.useState<RemoteUploadState>(INITIAL_REMOTE_STATE)
@@ -220,7 +225,13 @@ export function ResourceUploadProvider({
}),
)
const serverTasks = normalizeTaskList(result)
- setTasks((prev) => mergeServerTasks(prev, serverTasks))
+ const fallbackMessages = {
+ failed: i18n.t('resources:processingTasks.errors.failed'),
+ cancelled: i18n.t('resources:processingTasks.errors.cancelled'),
+ }
+ setTasks((prev) =>
+ mergeServerTasks(prev, serverTasks, fallbackMessages),
+ )
} catch (error) {
if (options.notifyOnError !== false) {
toast.error(getErrorMessage(error), { duration: 5000 })
@@ -270,7 +281,9 @@ export function ResourceUploadProvider({
? uploadResult.temp_file_id
: undefined
if (typeof tempFileId !== 'string' || !tempFileId.trim()) {
- throw new Error('Temp upload did not return temp_file_id.')
+ throw new Error(
+ i18n.t('resources:processingTasks.errors.tempUploadMissingId'),
+ )
}
updateTask(taskId, (task) => ({
@@ -291,7 +304,10 @@ export function ResourceUploadProvider({
if (addResult.status === 'error') {
const errors = Array.isArray(addResult.errors) ? addResult.errors : []
- throw new Error(errors.join('; ') || 'Processing failed')
+ throw new Error(
+ errors.join('; ') ||
+ i18n.t('resources:processingTasks.errors.failed'),
+ )
}
const rootUri =
@@ -418,7 +434,10 @@ export function ResourceUploadProvider({
if (result.status === 'error') {
const errors = Array.isArray(result.errors) ? result.errors : []
- throw new Error(errors.join('; ') || 'Processing failed')
+ throw new Error(
+ errors.join('; ') ||
+ i18n.t('resources:processingTasks.errors.failed'),
+ )
}
const warnings = Array.isArray(result.warnings) ? result.warnings : []
@@ -484,7 +503,9 @@ export function ResourceUploadProvider({
progress: null,
finishedAt: Date.now(),
errorCode: 'CANCELED',
- errorMessage: 'Canceled',
+ errorMessage: i18n.t(
+ 'resources:processingTasks.errors.cancelled',
+ ),
}))
return
}
@@ -527,7 +548,7 @@ export function ResourceUploadProvider({
React.useEffect(() => {
void refreshTasks({ notifyOnError: false, silent: true })
- }, [refreshTasks])
+ }, [refreshTasks, t])
const hasActiveServerTasks = React.useMemo(
() =>
@@ -576,7 +597,8 @@ export function ResourceUploadProvider({
? {
...prev,
phase: 'idle',
- error: remoteTask.errorMessage || 'Processing failed',
+ error:
+ remoteTask.errorMessage || t('processingTasks.errors.failed'),
}
: prev,
)
@@ -589,12 +611,14 @@ export function ResourceUploadProvider({
? {
...prev,
phase: 'idle',
- error: remoteTask.errorMessage || 'Processing cancelled',
+ error:
+ remoteTask.errorMessage ||
+ t('processingTasks.errors.cancelled'),
}
: prev,
)
}
- }, [remoteState.phase, remoteState.taskId, tasks])
+ }, [remoteState.phase, remoteState.taskId, t, tasks])
React.useEffect(() => {
for (const task of tasks) {
diff --git a/web-studio/src/routes/resources/-lib/resource-upload-tasks.test.ts b/web-studio/src/routes/resources/-lib/resource-upload-tasks.test.ts
new file mode 100644
index 000000000..559c9b878
--- /dev/null
+++ b/web-studio/src/routes/resources/-lib/resource-upload-tasks.test.ts
@@ -0,0 +1,98 @@
+import { describe, expect, it } from 'vitest'
+
+import { mergeServerTasks } from './resource-upload-tasks'
+import type { ResourceUploadTask } from '../-hooks/use-resource-upload'
+import type { TaskRecord } from '@ov-server/api/v1/tasks'
+
+function serverRecord(error?: string): TaskRecord {
+ return {
+ error,
+ status: 'failed',
+ task_id: 'task-1',
+ task_type: 'add_resource',
+ } as TaskRecord
+}
+
+function previousTask(
+ errorMessage: string,
+ errorMessageOrigin?: ResourceUploadTask['errorMessageOrigin'],
+ errorDetail?: string,
+): ResourceUploadTask {
+ return {
+ createdAt: 1,
+ errorCode: 'SERVER_TASK_FAILED',
+ errorDetail,
+ errorMessage,
+ errorMessageOrigin,
+ fileName: 'document.pdf',
+ fileSize: null,
+ fileType: null,
+ finishedAt: 2,
+ id: 'server-task-1',
+ progress: null,
+ rootUri: null,
+ serverTaskId: 'task-1',
+ source: 'server',
+ status: 'failed',
+ }
+}
+
+describe('mergeServerTasks', () => {
+ it('preserves an existing server error when a later record omits it', () => {
+ const [task] = mergeServerTasks(
+ [previousTask('provider overloaded', 'server', 'provider overloaded')],
+ [serverRecord()],
+ { cancelled: 'Cancelled', failed: 'Processing failed' },
+ )
+
+ expect(task.errorMessage).toBe('provider overloaded')
+ expect(task.errorMessageOrigin).toBe('server')
+ expect(task.errorDetail).toBe('provider overloaded')
+ })
+
+ it('refreshes a generated fallback when the locale changes', () => {
+ const [task] = mergeServerTasks(
+ [previousTask('Processing failed', 'fallback')],
+ [serverRecord()],
+ { cancelled: '已取消', failed: '处理失败' },
+ )
+
+ expect(task.errorMessage).toBe('处理失败')
+ expect(task.errorMessageOrigin).toBe('fallback')
+ expect(task.errorDetail).toBeNull()
+ })
+
+ it('localizes the generic server processing error', () => {
+ const [task] = mergeServerTasks(
+ [],
+ [serverRecord('resource processing failed')],
+ { cancelled: '已取消', failed: '处理失败' },
+ )
+
+ expect(task.errorMessage).toBe('处理失败')
+ expect(task.errorMessageOrigin).toBe('fallback')
+ expect(task.errorDetail).toBe('resource processing failed')
+ })
+
+ it('preserves a detailed server error', () => {
+ const [task] = mergeServerTasks([], [serverRecord('provider overloaded')], {
+ cancelled: '已取消',
+ failed: '处理失败',
+ })
+
+ expect(task.errorMessage).toBe('provider overloaded')
+ expect(task.errorMessageOrigin).toBe('server')
+ expect(task.errorDetail).toBe('provider overloaded')
+ })
+
+ it('keeps a detailed raw error when a later record is generic', () => {
+ const [task] = mergeServerTasks(
+ [previousTask('provider overloaded', 'server', 'provider overloaded')],
+ [serverRecord('resource processing failed')],
+ { cancelled: '已取消', failed: '处理失败' },
+ )
+
+ expect(task.errorMessage).toBe('provider overloaded')
+ expect(task.errorDetail).toBe('provider overloaded')
+ })
+})
diff --git a/web-studio/src/routes/resources/-lib/resource-upload-tasks.ts b/web-studio/src/routes/resources/-lib/resource-upload-tasks.ts
index 7626659a1..07d0140b5 100644
--- a/web-studio/src/routes/resources/-lib/resource-upload-tasks.ts
+++ b/web-studio/src/routes/resources/-lib/resource-upload-tasks.ts
@@ -83,8 +83,13 @@ function toUploadStatus(
return 'processing'
}
+function isGenericServerTaskError(error: string): boolean {
+ return error.trim().toLowerCase() === 'resource processing failed'
+}
+
function mergeServerTask(
record: TaskRecord,
+ fallbackMessages: { failed: string; cancelled: string },
existing?: ResourceUploadTask,
): ResourceUploadTask {
const status = toUploadStatus(record.status)
@@ -98,6 +103,38 @@ function mergeServerTask(
: getServerTaskName(record)
const isFinished =
status === 'success' || status === 'failed' || status === 'cancelled'
+ const hasErrorStatus = status === 'failed' || status === 'cancelled'
+ const recordErrorDetail =
+ hasErrorStatus && typeof record.error === 'string' && record.error.trim()
+ ? record.error.trim()
+ : null
+ const recordError =
+ recordErrorDetail && !isGenericServerTaskError(recordErrorDetail)
+ ? recordErrorDetail
+ : null
+ const existingError =
+ hasErrorStatus &&
+ existing?.errorMessage &&
+ existing.errorMessageOrigin !== 'fallback'
+ ? existing.errorMessage
+ : null
+ const fallbackError =
+ status === 'failed'
+ ? fallbackMessages.failed
+ : status === 'cancelled'
+ ? fallbackMessages.cancelled
+ : null
+ const errorMessage = recordError || existingError || fallbackError
+ const errorMessageOrigin = recordError
+ ? 'server'
+ : existingError
+ ? existing?.errorMessageOrigin
+ : fallbackError
+ ? 'fallback'
+ : undefined
+ const errorDetail = hasErrorStatus
+ ? (recordError ?? existing?.errorDetail ?? recordErrorDetail)
+ : null
return {
id: existing?.id ?? `server-${record.task_id}`,
@@ -114,12 +151,9 @@ function mergeServerTask(
status === 'failed'
? (existing?.errorCode ?? 'SERVER_TASK_FAILED')
: null,
- errorMessage:
- status === 'failed'
- ? record.error || existing?.errorMessage || 'Processing failed'
- : status === 'cancelled'
- ? record.error || 'Processing cancelled'
- : null,
+ errorDetail,
+ errorMessage,
+ errorMessageOrigin,
rootUri,
}
}
@@ -127,6 +161,7 @@ function mergeServerTask(
export function mergeServerTasks(
previous: ResourceUploadTask[],
serverTasks: TaskRecord[],
+ fallbackMessages: { failed: string; cancelled: string },
): ResourceUploadTask[] {
const previousByServerId = new Map<string, ResourceUploadTask>()
for (const task of previous) {
@@ -142,7 +177,7 @@ export function mergeServerTasks(
if (existing) {
consumedLocalIds.add(existing.id)
}
- return mergeServerTask(record, existing)
+ return mergeServerTask(record, fallbackMessages, existing)
})
for (const task of previous) {
diff --git a/web-studio/src/routes/settings/-lib/localize-capability-probe.test.ts b/web-studio/src/routes/settings/-lib/localize-capability-probe.test.ts
new file mode 100644
index 000000000..f3be37913
--- /dev/null
+++ b/web-studio/src/routes/settings/-lib/localize-capability-probe.test.ts
@@ -0,0 +1,37 @@
+import type { TFunction } from 'i18next'
+import { describe, expect, it } from 'vitest'
+
+import { localizeCapabilityDetail } from './localize-capability-probe'
+import type { CapabilityDetailCode } from '#/lib/admin'
+
+const translations: Record<string, string> = {
+ 'health.detail.accountAdminAvailable': '账号管理员权限可用',
+ 'health.detail.adminModeRequired': '管理 API 需要受支持的服务模式',
+ 'health.detail.controlKeyRequired': '需要管理密钥',
+ 'health.detail.dataKeyRequired': '需要用户密钥',
+ 'health.detail.rootAvailable': 'Root 管理权限可用',
+ 'health.detail.tenantDataAvailable': '租户数据访问可用',
+ 'health.detail.trustedIdentityRequired': '需要账号和用户信息',
+}
+
+const t = ((key: string) => translations[key] ?? key) as TFunction<'settings'>
+
+describe('localizeCapabilityDetail', () => {
+ it('maps every structured capability detail code', () => {
+ const codes = Object.keys(translations).map((key) =>
+ key.replace('health.detail.', ''),
+ ) as CapabilityDetailCode[]
+
+ for (const code of codes) {
+ expect(
+ localizeCapabilityDetail({ detailCode: code, state: 'ok' }, t),
+ ).toBe(translations[`health.detail.${code}`])
+ }
+ })
+
+ it('preserves an unstructured server error', () => {
+ expect(
+ localizeCapabilityDetail({ detail: 'HTTP 503', state: 'error' }, t),
+ ).toBe('HTTP 503')
+ })
+})
diff --git a/web-studio/src/routes/settings/-lib/localize-capability-probe.ts b/web-studio/src/routes/settings/-lib/localize-capability-probe.ts
new file mode 100644
index 000000000..90f59de5e
--- /dev/null
+++ b/web-studio/src/routes/settings/-lib/localize-capability-probe.ts
@@ -0,0 +1,25 @@
+import type { TFunction } from 'i18next'
+
+import type { CapabilityDetailCode, CapabilityProbeResult } from '#/lib/admin'
+
+type SettingsTranslator = TFunction<'settings'>
+
+const detailKeys = {
+ accountAdminAvailable: 'health.detail.accountAdminAvailable',
+ adminModeRequired: 'health.detail.adminModeRequired',
+ controlKeyRequired: 'health.detail.controlKeyRequired',
+ dataKeyRequired: 'health.detail.dataKeyRequired',
+ rootAvailable: 'health.detail.rootAvailable',
+ tenantDataAvailable: 'health.detail.tenantDataAvailable',
+ trustedIdentityRequired: 'health.detail.trustedIdentityRequired',
+} as const satisfies Record<CapabilityDetailCode, string>
+
+export function localizeCapabilityDetail(
+ result: CapabilityProbeResult | undefined,
+ t: SettingsTranslator,
+): string | undefined {
+ if (result?.detailCode) {
+ return t(detailKeys[result.detailCode])
+ }
+ return result?.detail
+}
diff --git a/web-studio/src/routes/settings/route.tsx b/web-studio/src/routes/settings/route.tsx
index 8c695b5f8..91d06cd1e 100644
--- a/web-studio/src/routes/settings/route.tsx
+++ b/web-studio/src/routes/settings/route.tsx
@@ -28,6 +28,7 @@ import type { CapabilityProbeResult } from '#/lib/admin'
import { DEFAULT_ACCOUNT_ID, DEFAULT_USER_ID } from '#/lib/admin-options'
import { PLAIN_INPUT_PROPS } from '#/lib/form-input'
import { cn } from '#/lib/utils'
+import { localizeCapabilityDetail } from './-lib/localize-capability-probe'
import type { ConnectionDraft } from '#/hooks/use-app-connection'
export const Route = createFileRoute('/settings')({
@@ -58,6 +59,7 @@ function CapabilityStatus({
}) {
const { t } = useTranslation('settings')
const state = isLoading ? 'checking' : result?.state || 'skipped'
+ const detail = localizeCapabilityDetail(result, t)
return (
<div
@@ -77,9 +79,9 @@ function CapabilityStatus({
{t(`health.state.${state}`)}
</span>
</div>
- {result?.detail ? (
+ {detail ? (
<p className="mt-1 truncate text-xs text-muted-foreground">
- {result.detail}
+ {detail}
</p>
) : null}
</div>
@@ -288,7 +290,9 @@ function ConnectionSettingsRoute() {
) : isUnsupportedAuthMode ? (
<Alert variant="destructive" className="border-destructive/50">
<TriangleAlertIcon className="size-5" />
- <AlertTitle>{t('connection.unsupportedAuthMode.title')}</AlertTitle>
+ <AlertTitle>
+ {t('connection.unsupportedAuthMode.title')}
+ </AlertTitle>
<AlertDescription className="grid gap-2">
<p>
{t('connection.unsupportedAuthMode.primary', {