diff --git a/web/frontend/src/pages/settings/page.css b/web/frontend/src/pages/settings/page.css index 320dcc66..96a885a5 100644 --- a/web/frontend/src/pages/settings/page.css +++ b/web/frontend/src/pages/settings/page.css @@ -121,3 +121,10 @@ .settings-field-wide { grid-column: span 1; } .settings-yaml-input .semi-input-textarea { min-height: 300px; } } + +.settings-update-source-form { + display: flex; + flex-direction: column; + gap: 8px; + max-width: 760px; +} diff --git a/web/frontend/src/pages/settings/sections/AuditSection.jsx b/web/frontend/src/pages/settings/sections/AuditSection.jsx index 590ec11c..ab24bce7 100644 --- a/web/frontend/src/pages/settings/sections/AuditSection.jsx +++ b/web/frontend/src/pages/settings/sections/AuditSection.jsx @@ -372,24 +372,24 @@ function AuditDetail({ id, categoryLabel, actionLabel, resultLabel }) { { label: t('settingsAudit.detailResult', null, '结果'), value: }, { label: t('settingsAudit.detailCategory', null, '类别'), value: categoryLabel(log.category) }, { label: t('settingsAudit.colAction', null, '操作'), value: actionLabel(log.action) }, - { label: 'actor', value: log.actor || '—' }, + { label: t('settingsDisplay.actor', null, '操作者'), value: log.actor || '—' }, { label: t('settingsAudit.colIp', null, 'IP'), value: {log.clientIp || '—'} }, - { label: 'level', value: log.level || '—' }, - { label: 'resource_type', value: log.resourceType || '—' }, + { label: t('settingsDisplay.level', null, '日志级别'), value: log.level || '—' }, + { label: t('settingsDisplay.resourceType', null, '资源类型'), value: log.resourceType || '—' }, { label: t('settingsAudit.resourceIdLabel', null, '资源 ID'), value: {log.resourceId || '—'} }, { - label: 'resource_available', - value: log.resourceAvailable === undefined ? '—' : String(log.resourceAvailable) + label: t('settingsDisplay.resourceAvailable', null, '资源是否可访问'), + value: log.resourceAvailable == null ? '—' : log.resourceAvailable ? t('common.yes', null, '是') : t('common.no', null, '否') }, - { label: 'session', value: {log.sessionHint || '—'} }, - { label: 'userAgent', value: truncate(log.userAgent || '—', 80) } + { label: t('settingsDisplay.session', null, '会话标识'), value: {log.sessionHint || '—'} }, + { label: t('settingsDisplay.userAgent', null, '客户端标识'), value: truncate(log.userAgent || '—', 80) } ]} />
{t('settingsAudit.detailMessage', null, '说明')} {log.message || '—'}
- {log.detail && } + {log.detail && } ); } diff --git a/web/frontend/src/pages/settings/sections/BasicSection.jsx b/web/frontend/src/pages/settings/sections/BasicSection.jsx index 42996442..ce1437bb 100644 --- a/web/frontend/src/pages/settings/sections/BasicSection.jsx +++ b/web/frontend/src/pages/settings/sections/BasicSection.jsx @@ -211,7 +211,7 @@ export default function BasicSection() { diff --git a/web/frontend/src/pages/settings/sections/ProbePanel.jsx b/web/frontend/src/pages/settings/sections/ProbePanel.jsx index 029188af..b76d06d2 100644 --- a/web/frontend/src/pages/settings/sections/ProbePanel.jsx +++ b/web/frontend/src/pages/settings/sections/ProbePanel.jsx @@ -15,15 +15,27 @@ const { Text } = Typography; const MAIN_CHANNEL = '__main__'; const NO_CHANNELS = {}; const PROVIDERS = [ - { value: 'openai_compatible', label: 'OpenAI 兼容' }, - { value: 'claude', label: 'Claude(Anthropic Messages)' } -]; -const CONTEXT_PROFILES = [ - { value: '', label: '默认(未知窗口)' }, - { value: 'auto', label: 'auto(自动)' }, - { value: 'local_auto', label: 'local_auto(本地服务)' }, - { value: 'custom', label: 'custom(手动运行时参数)' } + { value: 'openai_compatible', key: 'settingsProbe.compatible', fallback: '兼容 OpenAI 的接口' }, + { value: 'claude', key: 'settingsBasic.providerClaude', fallback: 'Claude(Anthropic Messages)' } ]; +const CONTEXT_PROFILES = ['', 'auto', 'local_auto', 'custom']; +const CONTEXT_WARNING_KEYS = { + context_window_unknown: 'contextWarnUnknown', + context_runtime_unknown: 'contextWarnRuntimeUnknown', + local_context_window_unknown: 'contextWarnWindowUnknown', + local_context_window_small: 'contextWarnWindowSmall', + max_total_tokens_clamped: 'contextWarnBudgetClamped', + max_completion_tokens_clamped: 'contextWarnCompletionClamped', + configured_budget_exceeds_context_window: 'contextWarnBudgetExceedsWindow', + ollama_v1_ignores_num_ctx: 'contextWarnOllamaV1', + ollama_runtime_context_unknown: 'contextWarnOllamaRuntime', + llamacpp_parallel_slots: 'contextWarnLlamaCppSlots' +}; +const BACKEND_NAMES = { ollama: 'Ollama', llamacpp: 'llama.cpp', lmstudio: 'LM Studio', omlx: 'oMLX', vllm: 'vLLM' }; + +function profileLabel(t, value) { + return t('settingsProbe.profiles.' + (value || 'default'), null, value || '使用默认设置'); +} function numberValue(raw) { const value = parseInt(raw, 10); @@ -57,18 +69,36 @@ function channelValues(config, id) { }; } -function summarizeContext(payload) { - const rows = [ - { label: 'success', value: String(Boolean(payload.success)) }, - { label: 'model', value: payload.model || '—' }, - { label: 'latency_ms', value: payload.latency_ms != null ? `${payload.latency_ms} ms` : '—' }, - { label: 'context_window', value: payload.context_window ?? '—' }, - { label: 'context_backend', value: payload.context_backend || '—' }, - { label: 'context_source', value: payload.context_source || '—' }, - { label: 'context_profile', value: payload.context_profile || '(空)' }, - { label: 'effective_max_total_tokens', value: payload.effective_max_total_tokens ?? '—' } +function summarizeTest(t, payload) { + return [ + { label: t('settingsProbe.result', null, '测试结果'), value: {t('settingsBasic.testSuccess', null, '连接成功')} }, + { label: t('settingsBasic.model', null, '模型'), value: payload.model || '—' }, + { + label: t('settingsProbe.latency', null, '响应耗时'), + value: payload.latency_ms != null + ? t('settingsProbe.milliseconds', { value: payload.latency_ms }, `${payload.latency_ms} 毫秒`) + : '—' + } + ]; +} + +function summarizeContext(t, payload) { + const source = payload.context_source; + const sourceKey = source?.replace(/^omlx_models_(?=max_model_len|context_length|max_context_length)/, 'openai_models_'); + const backend = payload.context_backend; + return [ + ...summarizeTest(t, payload), + { label: t('settingsProbe.window', null, '上下文窗口'), value: payload.context_window ?? '—' }, + { + label: t('settingsProbe.backend', null, '模型接口类型'), + value: backend === 'openai_compatible' + ? t('settingsProbe.compatible', null, '兼容 OpenAI 的接口') + : BACKEND_NAMES[backend] || backend || '—' + }, + { label: t('settingsProbe.source', null, '窗口信息来源'), value: source ? t('settingsProbe.sources.' + sourceKey, null, source) : '—' }, + { label: t('settingsProbe.profile', null, '上下文配置'), value: profileLabel(t, payload.context_profile) }, + { label: t('settingsProbe.effectiveBudget', null, '实际可用上下文令牌数'), value: payload.effective_max_total_tokens ?? '—' } ]; - return rows; } function ProbeOutput({ state }) { @@ -84,7 +114,7 @@ function ProbeOutput({ state }) { type={payload.supported === false ? 'info' : 'danger'} bordered closeIcon={null} - description={payload.error || t('settingsBasic.modelsListFailed', '获取模型列表失败')} + description={payload.error || t('settingsBasic.modelsListFailed', null, '获取模型列表失败')} /> ); } @@ -92,7 +122,6 @@ function ProbeOutput({ state }) { return (
- success {t('settingsBasic.modelsListSuccess', { count: payload.count ?? models.length }, `已获取 ${payload.count ?? models.length} 个模型`)}
@@ -109,32 +138,41 @@ function ProbeOutput({ state }) { {payload.success ? ( true }, - { label: 'model', value: payload.model || '—' }, - { label: 'latency_ms', value: payload.latency_ms != null ? `${payload.latency_ms} ms` : '—' } - ]} + items={summarizeTest(t, payload)} /> ) : ( - + )}
); } if (!payload.success) { - return ; + return ; } const warnings = Array.isArray(payload.context_warnings) ? payload.context_warnings : []; return (
- + {warnings.length > 0 && ( + {t('settingsProbe.warnings', null, '上下文提示')} +
    + {[...new Set(warnings)].map(code => ( +
  • + {Object.hasOwn(CONTEXT_WARNING_KEYS, code) + ? t('settingsBasic.' + CONTEXT_WARNING_KEYS[code], null, code) + : t('settingsProbe.unknownWarning', { code }, `收到未识别的上下文提示(${code})`)} +
  • + ))} +
+
+ )} /> )}
@@ -154,10 +192,10 @@ export default function ProbePanel({ config, canWrite }) { }, [channelId, config]); const channelOptions = useMemo(() => [ - { value: MAIN_CHANNEL, label: t('settings.mainChannel', null, '主模型(openai 段)') }, + { value: MAIN_CHANNEL, label: t('settingsProbe.mainChannel', null, '主模型通道') }, ...Object.keys(channels).map(id => ({ value: id, - label: `${id}${id === config.ai?.default_channel ? '(默认)' : ''}` + label: `${id}${id === config.ai?.default_channel ? t('settingsProbe.defaultChannelSuffix', null, '(默认)') : ''}` })) ], [channels, config.ai?.default_channel, t]); @@ -259,37 +297,39 @@ export default function ProbePanel({ config, canWrite }) { />
+ )} + {!checkResult && !checkError && ( - 尚未检查远端版本(GET /system/update 不联网)。 + {t('updateUi.versionUnchecked', null, '尚未检查远端版本。')} )} {checkResult && ( <> @@ -158,19 +231,19 @@ export default function UpdateSection() { type="warning" bordered closeIcon={null} - description={`${t('update.checkFailed', null, '检查更新失败')}:${checkResult.checkError}`} + description={t('update.checkFailed', { reason: checkResult.checkError }, `检查失败:${checkResult.checkError}`)} /> ) : ( {checkResult.updateAvailable - ? t('update.behindCount', { count: checkResult.behind }, `落后 ${checkResult.behind} 个提交`) - : t('update.upToDate', null, '已是最新')} + ? t('update.behindCount', { n: checkResult.behind }, `落后 ${checkResult.behind} 个提交`) + : t('update.upToDate', { commit: shortCommit(checkResult.commit) }, '已是最新')} {checkResult.ahead > 0 && ( - {t('update.aheadCount', { count: checkResult.ahead }, `领先 ${checkResult.ahead} 个提交`)} + {t('update.aheadCount', { n: checkResult.ahead }, `领先 ${checkResult.ahead} 个提交`)} )} - {checkResult.diverged && diverged} + {checkResult.diverged && {t('updateUi.diverged', null, '本机与远端提交历史已分叉')}} {t('update.remoteHead', null, '远端 HEAD')}:{shortCommit(checkResult.remoteCommit)} {checkResult.targetBranch ? `(${checkResult.targetBranch})` : ''} @@ -188,7 +261,7 @@ export default function UpdateSection() { ))} {checkResult.incomingTotal > incoming.length && ( - {t('update.incomingTruncated', { count: checkResult.incomingTotal }, `共 ${checkResult.incomingTotal} 个提交,仅显示前 ${incoming.length} 个`)} + {t('update.incomingTruncated', { total: checkResult.incomingTotal, shown: Math.min(10, incoming.length) }, `共 ${checkResult.incomingTotal} 个提交,仅显示前 ${incoming.length} 个`)} )} )} @@ -198,7 +271,7 @@ export default function UpdateSection() { {job.state} : null} + extra={job ? {jobStateLabel(t, job.state)} : null} > {!job && {t('update.noJob', null, '暂无更新任务记录。')}} {job && ( @@ -206,19 +279,19 @@ export default function UpdateSection() { {shortCommit(job.id)} }, - { label: 'kind', value: job.kind || '—' }, - { label: 'started', value: job.started ? formatDateTime(job.started) : '—' }, - { label: 'finished', value: job.finished ? formatDateTime(job.finished) : '—' }, - { label: 'restartRequested', value: yesNo(t, job.restartRequested) }, - { label: 'restartError', value: job.restartError || '—' } + { label: t('updateUi.taskId', null, '任务编号'), value: {shortCommit(job.id)} }, + { label: t('updateUi.kind', null, '任务类型'), value: job.kind ? t('updateUi.kinds.' + job.kind, null, job.kind) : '—' }, + { label: t('updateUi.started', null, '开始时间'), value: job.started ? formatDateTime(job.started) : '—' }, + { label: t('updateUi.finished', null, '结束时间'), value: job.finished ? formatDateTime(job.finished) : '—' }, + { label: t('updateUi.restartRequested', null, '已请求重启'), value: yesNo(t, job.restartRequested) }, + { label: t('updateUi.restartError', null, '重启错误'), value: job.restartError || '—' } ]} /> {Array.isArray(job.steps) && job.steps.length > 0 && ( {job.steps.map((step, index) => ( - {step.phase} + {t('updateUi.phases.' + step.phase, null, step.phase)}
{truncate(step.message || '', 160)}
{step.at ? formatDateTime(step.at) : ''}
@@ -229,12 +302,12 @@ export default function UpdateSection() { {shortCommit(job.result.fromCommit)} }, - { label: 'toCommit', value: {shortCommit(job.result.toCommit)} }, - { label: 'commits', value: formatNumber(job.result.commits) }, - { label: 'filesTouched', value: formatNumber(job.result.filesTouched) }, - { label: 'keptContent', value: formatNumber((job.result.keptContent || []).length) }, - { label: 'overwritten', value: formatNumber((job.result.overwritten || []).length) } + { label: t('updateUi.fromCommit', null, '更新前提交'), value: {shortCommit(job.result.fromCommit)} }, + { label: t('updateUi.toCommit', null, '更新后提交'), value: {shortCommit(job.result.toCommit)} }, + { label: t('update.resultCommits', null, '并入提交数'), value: formatNumber(job.result.commits) }, + { label: t('update.resultFiles', null, '改动文件数'), value: formatNumber(job.result.filesTouched) }, + { label: t('updateUi.keptContent', null, '保留的本机文件数'), value: formatNumber((job.result.keptContent || []).length) }, + { label: t('updateUi.overwritten', null, '覆盖的文件数'), value: formatNumber((job.result.overwritten || []).length) } ]} /> )} diff --git a/web/frontend/src/pages/vulnerabilities/FilterBar.jsx b/web/frontend/src/pages/vulnerabilities/FilterBar.jsx index 3ee4860a..fa1a44fd 100644 --- a/web/frontend/src/pages/vulnerabilities/FilterBar.jsx +++ b/web/frontend/src/pages/vulnerabilities/FilterBar.jsx @@ -9,7 +9,7 @@ function withEmpty(label, options) { return [{ value: '', label }, ...options]; } -export default function FilterBar({ t, filters, options, projectOptions, onChange, onReset }) { +export default function FilterBar({ t, filters, options, projectOptions, hasGroupFilters, onChange, onReset }) { const [keyword, setKeyword] = useState(filters.q); const debounced = useDebounced(keyword, 380); const lastEmitted = useRef(filters.q); @@ -102,7 +102,7 @@ export default function FilterBar({ t, filters, options, projectOptions, onChang )} - {canDelete && hasActiveFilters(filters) && ( + {canDelete && !groupSelection && !groupSearch && hasActiveFilters(filters) && ( @@ -408,7 +442,7 @@ export default function VulnerabilitiesPage() { {t('common.refresh', null, '刷新')} {canWrite && (