Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions web/src/components/table/channels/modals/EditChannelModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const PARAM_OVERRIDE_OPERATIONS_TEMPLATE = {
],
};

const DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL = 'doubao-coding-plan';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Potential mismatch with backend deprecated base URL breaks “keep existing” behavior

The guard compares/stores doubao-coding-plan, but backend special-base config for OpenAI uses https://ark.cn-beijing.volces.com/api/coding/v3 (constant/channel.go:205-208). If loaded channels carry the resolved URL, existing deprecated channels won’t be recognized as keepable.

🔧 Suggested fix
-const DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL = 'doubao-coding-plan';
+const DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL =
+  'https://ark.cn-beijing.volces.com/api/coding/v3';
+const DEPRECATED_DOUBAO_CODING_PLAN_LEGACY_KEY = 'doubao-coding-plan';
...
-const canKeepDeprecatedDoubaoCodingPlan =
-  initialBaseUrlRef.current === DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL;
+const canKeepDeprecatedDoubaoCodingPlan = [
+  DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL,
+  DEPRECATED_DOUBAO_CODING_PLAN_LEGACY_KEY,
+].includes((initialBaseUrlRef.current || '').trim());

Also applies to: 425-425, 963-963, 3081-3083

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/table/channels/modals/EditChannelModal.jsx` at line 127,
The code uses DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL set to
'doubao-coding-plan', but the backend deprecated special-base is the full
resolved URL, so existing channels with the resolved URL aren't recognized as
deprecated; update the check logic that references
DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL (and all occurrences) to accept both
forms: preserve the existing short token for legacy records and also treat the
backend-resolved URL 'https://ark.cn-beijing.volces.com/api/coding/v3' as
equivalent (either by replacing DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL with the
full URL or by adding a secondary constant and updating comparisons in
EditChannelModal.jsx and the other referenced usages to normalize/compare
against both values before deciding to “keep existing”).


// 支持并且已适配通过接口获取模型列表的渠道类型
const MODEL_FETCHABLE_TYPES = new Set([
1, 4, 14, 34, 17, 26, 27, 24, 47, 25, 20, 23, 31, 40, 42, 48, 43,
Expand Down Expand Up @@ -413,9 +415,21 @@ const EditChannelModal = (props) => {
];
const formContainerRef = useRef(null);
const doubaoApiClickCountRef = useRef(0);
const initialBaseUrlRef = useRef('');
const initialModelsRef = useRef([]);
const initialModelMappingRef = useRef('');
const initialStatusCodeMappingRef = useRef('');
const doubaoCodingPlanDeprecationMessage =
'Doubao Coding Plan 不再允许新增。根据火山方舟文档,Coding 套餐额度仅适用于 AI Coding 产品内调用,不适用于单独 API 调用;在非 AI Coding 产品中使用对应的 Base URL 和 API Key 可能被视为违规,并可能导致订阅停用或账号封禁。';
const canKeepDeprecatedDoubaoCodingPlan =
initialBaseUrlRef.current === DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL;
const doubaoCodingPlanOptionLabel = (
<Tooltip content={doubaoCodingPlanDeprecationMessage} position='left'>
<span className='inline-flex items-center gap-2'>
<span>Doubao Coding Plan</span>
</span>
</Tooltip>
);
Comment on lines +422 to +432

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

New tooltip/label text bypasses i18n pipeline

Line 422-432 introduces user-facing strings outside t(...). This won’t be localized and violates frontend i18n conventions for this path.

🌐 Suggested fix
-  const doubaoCodingPlanDeprecationMessage =
-    'Doubao Coding Plan 不再允许新增。根据火山方舟文档,Coding 套餐额度仅适用于 AI Coding 产品内调用,不适用于单独 API 调用;在非 AI Coding 产品中使用对应的 Base URL 和 API Key 可能被视为违规,并可能导致订阅停用或账号封禁。';
+  const doubaoCodingPlanDeprecationMessage = t(
+    'Doubao Coding Plan 不再允许新增。根据火山方舟文档,Coding 套餐额度仅适用于 AI Coding 产品内调用,不适用于单独 API 调用;在非 AI Coding 产品中使用对应的 Base URL 和 API Key 可能被视为违规,并可能导致订阅停用或账号封禁。',
+  );
...
-        <span>Doubao Coding Plan</span>
+        <span>{t('Doubao Coding Plan')}</span>

As per coding guidelines: “Frontend i18n: Use useTranslation() hook and call t('中文key') in components.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const doubaoCodingPlanDeprecationMessage =
'Doubao Coding Plan 不再允许新增。根据火山方舟文档,Coding 套餐额度仅适用于 AI Coding 产品内调用,不适用于单独 API 调用;在非 AI Coding 产品中使用对应的 Base URL 和 API Key 可能被视为违规,并可能导致订阅停用或账号封禁。';
const canKeepDeprecatedDoubaoCodingPlan =
initialBaseUrlRef.current === DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL;
const doubaoCodingPlanOptionLabel = (
<Tooltip content={doubaoCodingPlanDeprecationMessage} position='left'>
<span className='inline-flex items-center gap-2'>
<span>Doubao Coding Plan</span>
</span>
</Tooltip>
);
const doubaoCodingPlanDeprecationMessage = t(
'Doubao Coding Plan 不再允许新增。根据火山方舟文档,Coding 套餐额度仅适用于 AI Coding 产品内调用,不适用于单独 API 调用;在非 AI Coding 产品中使用对应的 Base URL 和 API Key 可能被视为违规,并可能导致订阅停用或账号封禁。',
);
const canKeepDeprecatedDoubaoCodingPlan =
initialBaseUrlRef.current === DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL;
const doubaoCodingPlanOptionLabel = (
<Tooltip content={doubaoCodingPlanDeprecationMessage} position='left'>
<span className='inline-flex items-center gap-2'>
<span>{t('Doubao Coding Plan')}</span>
</span>
</Tooltip>
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/table/channels/modals/EditChannelModal.jsx` around lines
422 - 432, The new user-facing strings (doubaoCodingPlanDeprecationMessage and
the label in doubaoCodingPlanOptionLabel) are hard-coded and bypass i18n; update
the component to use the useTranslation() hook and replace those literals with
t('...') calls (e.g., t('doubaoCodingPlan.deprecationMessage') and
t('doubaoCodingPlan.label')), keeping canKeepDeprecatedDoubaoCodingPlan logic
unchanged; ensure translation keys are added to the locale resource files and
import/use the hook at the top of EditChannelModal.jsx.


// 2FA状态更新辅助函数
const updateTwoFAState = (updates) => {
Expand Down Expand Up @@ -946,6 +960,7 @@ const EditChannelModal = (props) => {
data.base_url = 'https://ark.cn-beijing.volces.com';
}

initialBaseUrlRef.current = data.base_url || '';
setInputs(data);
if (formApiRef.current) {
formApiRef.current.setValues(data);
Expand Down Expand Up @@ -1260,6 +1275,7 @@ const EditChannelModal = (props) => {
fetchModels().then();
fetchGroups().then();
if (!isEdit) {
initialBaseUrlRef.current = '';
setInputs(originInputs);
if (formApiRef.current) {
formApiRef.current.setValues(originInputs);
Expand Down Expand Up @@ -3062,8 +3078,9 @@ const EditChannelModal = (props) => {
'https://ark.ap-southeast.bytepluses.com',
},
{
value: 'doubao-coding-plan',
label: 'Doubao Coding Plan',
value: DEPRECATED_DOUBAO_CODING_PLAN_BASE_URL,
label: doubaoCodingPlanOptionLabel,
disabled: !canKeepDeprecatedDoubaoCodingPlan,
},
]}
defaultValue='https://ark.cn-beijing.volces.com'
Expand Down