From f7cdf588ae2563707d2983b89fa80f9de4a3bf92 Mon Sep 17 00:00:00 2001
From: Sycun <165354365+Sycun@users.noreply.github.com>
Date: Thu, 19 Nov 2026 10:39:49 +0800
Subject: [PATCH] fix(frontend): use custom names for model channels
---
web/frontend/src/lib/model-channel.js | 20 ++++++++++++
web/frontend/src/pages/chat/ChatSettings.jsx | 13 ++++----
.../pages/deep-assessments/CreateModal.jsx | 7 ++--
.../pages/settings/sections/BasicSection.jsx | 9 ++++--
.../pages/settings/sections/ProbePanel.jsx | 21 ++++++------
web/frontend/tests/model-channels.spec.mjs | 32 ++++++++++++++++---
web/frontend/tests/regressions.spec.mjs | 8 ++---
...A9As2.js => agents-management-DeKV9N2s.js} | 2 +-
...-docs-BkYb87w5.js => api-docs-JRmx1ZOg.js} | 2 +-
...-0crVxUx1.js => asset-library-xwk2jyLe.js} | 2 +-
...D_5zrfsx.js => asset-overview-ggBJA5RD.js} | 2 +-
...ents-CXr9SP6Q.js => c2-events-B28xE-G6.js} | 2 +-
...s-CLUvM2f0.js => c2-listeners-DNn_Czfr.js} | 2 +-
...ds-DFGF_lf2.js => c2-payloads-COwyFjLx.js} | 2 +-
...es-DajwXdtE.js => c2-profiles-CeyDVUtN.js} | 2 +-
...ns-Db6vS1No.js => c2-sessions-CPcN5V6q.js} | 2 +-
...ared-CoFq4vPx.js => c2-shared-xHvwOKBR.js} | 2 +-
...ared-Ij_8wvn-.js => c2-shared-ySfm4uFc.js} | 2 +-
...tasks-D0Jie5Ef.js => c2-tasks-CWgXjyNM.js} | 2 +-
web/static/app/assets/chat-BKpYwUrf.js | 4 ---
web/static/app/assets/chat-BbmyA2fo.js | 4 +++
...les-D2bhKzt6.js => chat-files-ezhftRzK.js} | 2 +-
...oard-6C1Mg3-7.js => dashboard-DKQ5q-fI.js} | 2 +-
...v8eetM.js => deep-assessments-DO8ovIjZ.js} | 4 +--
.../{hitl-DnLbaZrC.js => hitl-DAIit5o8.js} | 2 +-
.../{index-Bp0yS_jU.js => index-BauQ8w_n.js} | 4 +--
...t-CGxj3C6O.js => info-collect-C8VDSF2I.js} | 2 +-
...NQ.js => knowledge-management-_9X_x2e-.js} | 2 +-
...s => knowledge-retrieval-logs-CFwYWGFk.js} | 2 +-
...DmaZ__CE.js => mcp-management-vjX0UYCW.js} | 2 +-
...or-BPUUL2zv.js => mcp-monitor-BHEWpU93.js} | 2 +-
.../app/assets/model-channel-mQ6lfvSO.js | 1 +
...-B-os6Zqw.js => platform-rbac-CTiSOibu.js} | 2 +-
...jects-C3G-Yxxk.js => projects-BlPGQDoJ.js} | 2 +-
...Ov-x8K.js => roles-management-BrTwBnQp.js} | 2 +-
web/static/app/assets/settings-CyXnBfik.js | 20 ------------
web/static/app/assets/settings-D9yGP7xS.js | 20 ++++++++++++
...DpUN9.js => skills-management-DH-Ny3xd.js} | 2 +-
...Chaw8bc9.js => skills-monitor-CiLqs1eK.js} | 2 +-
.../{tasks-Bv16BMQ9.js => tasks-DGrY1h_r.js} | 2 +-
...ard-CMTlxo63.js => tool-guard-CwFn66j1.js} | 2 +-
...dA7kBSP.js => vulnerabilities-CvTS3Frp.js} | 2 +-
...shell-BVrx1ecQ.js => webshell-DShOEjLQ.js} | 2 +-
...lows-sDAbfFl4.js => workflows-CkSj01fp.js} | 2 +-
web/static/app/index.html | 2 +-
web/static/i18n/en-US.json | 1 -
web/static/i18n/zh-CN.json | 1 -
47 files changed, 137 insertions(+), 94 deletions(-)
create mode 100644 web/frontend/src/lib/model-channel.js
rename web/static/app/assets/{agents-management-2lvA9As2.js => agents-management-DeKV9N2s.js} (97%)
rename web/static/app/assets/{api-docs-BkYb87w5.js => api-docs-JRmx1ZOg.js} (98%)
rename web/static/app/assets/{asset-library-0crVxUx1.js => asset-library-xwk2jyLe.js} (99%)
rename web/static/app/assets/{asset-overview-D_5zrfsx.js => asset-overview-ggBJA5RD.js} (98%)
rename web/static/app/assets/{c2-events-CXr9SP6Q.js => c2-events-B28xE-G6.js} (96%)
rename web/static/app/assets/{c2-listeners-CLUvM2f0.js => c2-listeners-DNn_Czfr.js} (97%)
rename web/static/app/assets/{c2-payloads-DFGF_lf2.js => c2-payloads-COwyFjLx.js} (97%)
rename web/static/app/assets/{c2-profiles-DajwXdtE.js => c2-profiles-CeyDVUtN.js} (97%)
rename web/static/app/assets/{c2-sessions-Db6vS1No.js => c2-sessions-CPcN5V6q.js} (98%)
rename web/static/app/assets/{c2-shared-CoFq4vPx.js => c2-shared-xHvwOKBR.js} (96%)
rename web/static/app/assets/{c2-shared-Ij_8wvn-.js => c2-shared-ySfm4uFc.js} (94%)
rename web/static/app/assets/{c2-tasks-D0Jie5Ef.js => c2-tasks-CWgXjyNM.js} (98%)
delete mode 100644 web/static/app/assets/chat-BKpYwUrf.js
create mode 100644 web/static/app/assets/chat-BbmyA2fo.js
rename web/static/app/assets/{chat-files-D2bhKzt6.js => chat-files-ezhftRzK.js} (99%)
rename web/static/app/assets/{dashboard-6C1Mg3-7.js => dashboard-DKQ5q-fI.js} (99%)
rename web/static/app/assets/{deep-assessments-rXv8eetM.js => deep-assessments-DO8ovIjZ.js} (52%)
rename web/static/app/assets/{hitl-DnLbaZrC.js => hitl-DAIit5o8.js} (99%)
rename web/static/app/assets/{index-Bp0yS_jU.js => index-BauQ8w_n.js} (93%)
rename web/static/app/assets/{info-collect-CGxj3C6O.js => info-collect-C8VDSF2I.js} (99%)
rename web/static/app/assets/{knowledge-management-Dk2mzYNQ.js => knowledge-management-_9X_x2e-.js} (98%)
rename web/static/app/assets/{knowledge-retrieval-logs-BMMTFIny.js => knowledge-retrieval-logs-CFwYWGFk.js} (96%)
rename web/static/app/assets/{mcp-management-DmaZ__CE.js => mcp-management-vjX0UYCW.js} (99%)
rename web/static/app/assets/{mcp-monitor-BPUUL2zv.js => mcp-monitor-BHEWpU93.js} (99%)
create mode 100644 web/static/app/assets/model-channel-mQ6lfvSO.js
rename web/static/app/assets/{platform-rbac-B-os6Zqw.js => platform-rbac-CTiSOibu.js} (99%)
rename web/static/app/assets/{projects-C3G-Yxxk.js => projects-BlPGQDoJ.js} (99%)
rename web/static/app/assets/{roles-management-D_Ov-x8K.js => roles-management-BrTwBnQp.js} (96%)
delete mode 100644 web/static/app/assets/settings-CyXnBfik.js
create mode 100644 web/static/app/assets/settings-D9yGP7xS.js
rename web/static/app/assets/{skills-management-Dq6DpUN9.js => skills-management-DH-Ny3xd.js} (98%)
rename web/static/app/assets/{skills-monitor-Chaw8bc9.js => skills-monitor-CiLqs1eK.js} (95%)
rename web/static/app/assets/{tasks-Bv16BMQ9.js => tasks-DGrY1h_r.js} (99%)
rename web/static/app/assets/{tool-guard-CMTlxo63.js => tool-guard-CwFn66j1.js} (99%)
rename web/static/app/assets/{vulnerabilities-DdA7kBSP.js => vulnerabilities-CvTS3Frp.js} (99%)
rename web/static/app/assets/{webshell-BVrx1ecQ.js => webshell-DShOEjLQ.js} (99%)
rename web/static/app/assets/{workflows-sDAbfFl4.js => workflows-CkSj01fp.js} (99%)
diff --git a/web/frontend/src/lib/model-channel.js b/web/frontend/src/lib/model-channel.js
new file mode 100644
index 00000000..68fbabd8
--- /dev/null
+++ b/web/frontend/src/lib/model-channel.js
@@ -0,0 +1,20 @@
+export function modelChannelName(id, channel) {
+ return channel?.name?.trim() || id;
+}
+
+export function modelChannelOptions(channels) {
+ const options = channels.map(([value, channel]) => ({ value, name: modelChannelName(value, channel) }));
+ const counts = new Map();
+ for (const { name } of options) {
+ counts.set(name, (counts.get(name) || 0) + 1);
+ }
+ return options.map(({ value, name }) => ({
+ value,
+ name,
+ label: counts.get(name) > 1 ? `${name} · ID ${value}` : name
+ }));
+}
+
+export function selectedModelChannelName(option) {
+ return option.name || option.label;
+}
diff --git a/web/frontend/src/pages/chat/ChatSettings.jsx b/web/frontend/src/pages/chat/ChatSettings.jsx
index 5dd41db7..6fc0db5f 100644
--- a/web/frontend/src/pages/chat/ChatSettings.jsx
+++ b/web/frontend/src/pages/chat/ChatSettings.jsx
@@ -4,6 +4,7 @@ import { useResource } from '../../components/hooks';
import { ErrorBanner, toastError } from '../../components/ui';
import { api } from '../../lib/http';
import { useT } from '../../lib/i18n';
+import { modelChannelName, modelChannelOptions, selectedModelChannelName } from '../../lib/model-channel';
import { REASONING_EFFORTS, REASONING_MODES } from './useModelPreferences';
const { Text } = Typography;
@@ -49,15 +50,12 @@ export default function ChatSettings({
: approvalActive
? t('chat.hitlUseHumanFirstMessage', null, '首条消息改用人工审批')
: t('chat.hitlEnableFirstMessage', null, '为首条消息开启人工审批');
- const defaultChannel = model.config.data?.default_channel;
- const defaultModel = model.channels.find(([id]) => id === defaultChannel)?.[1]?.model;
+ const defaultId = model.config.data?.default_channel;
+ const defaultName = defaultId ? modelChannelName(defaultId, model.config.data?.channels?.[defaultId]) : '';
const defaultLabel = t('chat.aiChannelDefault', null, '跟随默认通道');
const channelOptions = [
- { value: '', label: defaultModel ? `${defaultLabel} · ${defaultModel}` : defaultLabel },
- ...model.channels.map(([id, config]) => ({
- value: id,
- label: [config?.name || id, config?.model].filter(Boolean).join(' · ')
- }))
+ { value: '', label: defaultName ? `${defaultLabel} · ${defaultName}` : defaultLabel },
+ ...modelChannelOptions(model.channels)
];
const reasoningLabels = {
default: t('chat.reasoningModeDefault', null, '跟随系统'),
@@ -105,6 +103,7 @@ export default function ChatSettings({
label={t('chat.aiChannelLabel', null, 'AI 通道')}
value={model.channel}
optionList={channelOptions}
+ renderSelectedItem={selectedModelChannelName}
onSelect={model.setChannel}
loading={model.config.loading}
disabled={busy || model.config.loading || Boolean(model.config.error)}
diff --git a/web/frontend/src/pages/deep-assessments/CreateModal.jsx b/web/frontend/src/pages/deep-assessments/CreateModal.jsx
index 441b27a9..7c838307 100644
--- a/web/frontend/src/pages/deep-assessments/CreateModal.jsx
+++ b/web/frontend/src/pages/deep-assessments/CreateModal.jsx
@@ -3,6 +3,7 @@ import { useCallback, useEffect, useState } from 'react';
import { Banner, Button, Form, Modal, Spin } from '@douyinfe/semi-ui';
import { api } from '../../lib/http';
import { useT } from '../../lib/i18n';
+import { modelChannelOptions, selectedModelChannelName } from '../../lib/model-channel';
import { ErrorBanner, toastError, toastSuccess } from '../../components/ui';
const HITL_OPTIONS = [
@@ -57,10 +58,7 @@ export default function CreateAssessmentModal({ visible, onCancel, onCreated })
}
};
- const models = (options?.models || []).map(item => ({
- value: item.id,
- label: [item.name || item.id, item.model].filter(Boolean).join(' · ')
- }));
+ const models = modelChannelOptions((options?.models || []).map(item => [item.id, item]));
const roles = (options?.roles || []).map(role => ({ value: role, label: role }));
const projects = (options?.projects || []).map(project => ({ value: project.id, label: project.name || project.id }));
@@ -121,6 +119,7 @@ export default function CreateAssessmentModal({ visible, onCancel, onCreated })
field="model"
label={t('deepAssessments.model', null, '模型渠道')}
optionList={[{ value: '', label: '系统默认' }, ...models]}
+ renderSelectedItem={selectedModelChannelName}
style={{ width: '100%' }}
/>
{
const data = config.data;
if (!data) return [];
- const channels = data.ai?.channels ? Object.keys(data.ai.channels) : [];
+ const channels = data.ai?.channels || {};
+ const channelNames = Object.entries(channels).map(([id, channel]) => modelChannelName(id, channel));
+ const defaultId = data.ai?.default_channel;
const tools = Array.isArray(data.tools) ? data.tools : [];
const enabledTools = tools.filter(tool => tool.enabled).length;
return [
- { label: t('settings.defaultChannel', null, '默认 AI 通道'), value: data.ai?.default_channel || '—' },
+ { label: t('settings.defaultChannel', null, '默认 AI 通道'), value: defaultId ? modelChannelName(defaultId, channels[defaultId]) : '—' },
{
label: t('settingsBasic.aiChannelSavedList', null, '已保存通道'),
- value: `${formatNumber(channels.length)}${channels.length ? `(${channels.slice(0, 4).join('、')})` : ''}`
+ value: `${formatNumber(channelNames.length)}${channelNames.length ? `(${channelNames.slice(0, 4).join('、')})` : ''}`
},
{
label: t('settings.toolsEnabled', null, '已启用工具'),
diff --git a/web/frontend/src/pages/settings/sections/ProbePanel.jsx b/web/frontend/src/pages/settings/sections/ProbePanel.jsx
index 0248b1b9..7c02baa5 100644
--- a/web/frontend/src/pages/settings/sections/ProbePanel.jsx
+++ b/web/frontend/src/pages/settings/sections/ProbePanel.jsx
@@ -5,6 +5,7 @@ import { useId, useState } from 'react';
import { Banner, Button, Input, Select, Space, Tag, Typography } from '@douyinfe/semi-ui';
import { api } from '../../../lib/http';
import { useT } from '../../../lib/i18n';
+import { modelChannelOptions, selectedModelChannelName } from '../../../lib/model-channel';
import { ErrorBanner, KeyValueList, SectionCard, toastSuccess } from '../../../components/ui';
import { Hint } from './common';
@@ -194,15 +195,9 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
const [saveError, setSaveError] = useState(null);
const [applyPending, setApplyPending] = useState(false);
const locked = !canWrite || saving;
- const channelNames = channelIds.map(id => channels[id].name?.trim() || id);
const channelOptions = legacy
? [{ value: MAIN_CHANNEL, label: t('settingsProbe.mainChannel', null, '主模型通道') }]
- : channelIds.map((id, index) => {
- const name = channelNames[index];
- const displayName = channelNames.indexOf(name) !== channelNames.lastIndexOf(name) ? `${name} · ${id}` : name;
- const suffix = id === defaultId ? t('settingsProbe.defaultChannelSuffix', null, '(默认)') : '';
- return { value: id, label: displayName + suffix };
- });
+ : modelChannelOptions(Object.entries(channels));
const providerOptions = PROVIDERS.map(({ value, key, fallback }) => ({ value, label: t(key, null, fallback) }));
if (!providerOptions.some(option => option.value === form.provider)) {
providerOptions.push({ value: form.provider, label: form.provider });
@@ -390,17 +385,23 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
)}
>
-