fix:修复创建渠道,分类选择不显示label的问题、API地址增加“完整URL”支持 - #4756
Conversation
- 修复选择渠道类型后输入框显示数字编号而非名称的问题 - 修复选中后再次打开下拉框只显示已选项、不显示全部选项的问题 - 修复选中选项后输入框未自动失去焦点的问题 - 引入 isEditing/editValue 双状态机制,非编辑态显示 label,编辑态显示用户输入
WalkthroughThis PR adds a new ChangesFull Request URL Toggle Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (6)
web/default/src/components/ui/combobox-input.tsx (1)
45-46: ⚡ Quick winConsider using i18n for default prop values.
The default values for
placeholderandemptyTextare English strings. While parent components can override these with translated text, applyingt()to the defaults would ensure they're translated even when not explicitly overridden by the parent.♻️ Proposed refactor to add i18n to defaults
export function ComboboxInput({ options, value = '', onValueChange, - placeholder = 'Select or type...', - emptyText = 'No option found.', + placeholder, + emptyText, className, id, }: ComboboxInputProps) { const { t } = useTranslation() + const defaultPlaceholder = placeholder ?? t('Select or type...') + const defaultEmptyText = emptyText ?? t('No option found.') const [open, setOpen] = React.useState(false)Then use
defaultPlaceholderanddefaultEmptyTextthroughout the component where these values are referenced.As per coding guidelines: "All user-facing text content must support i18n using the
t()function fromuseTranslation()in React components".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/default/src/components/ui/combobox-input.tsx` around lines 45 - 46, The default English strings for the props placeholder and emptyText should be wrapped with the i18n t() function; import and call useTranslation() in the component to get t, create defaultPlaceholder and defaultEmptyText (e.g. const defaultPlaceholder = t('combobox.placeholder', 'Select or type...') and const defaultEmptyText = t('combobox.empty', 'No option found.')), then use those defaults wherever placeholder and emptyText are referenced (or assign them as default values for the component props) so the ComboboxInput component uses translated defaults when parents don’t override them.web/default/src/i18n/locales/zh.json (1)
1463-1464: ⚖️ Poor tradeoffTranslations look good; consider hierarchical keys for future work.
The Chinese translations for the new "Full URL" feature are accurate and appropriate. The entries correctly follow the existing pattern used throughout this file.
However, the coding guideline recommends using hierarchical and semantically clear translation key names (e.g.,
dashboard.overview.title) rather than English phrases as keys. While the current approach is consistent with the majority of entries in this file, consider migrating to hierarchical keys in future work for better maintainability and alignment with the guideline. For example:
"Full Request URL"→"channel.api.fullRequestUrl""Use a complete request URL..."→"channel.api.fullRequestUrl.hint"This would be a project-wide refactoring effort and shouldn't block this PR. As per coding guidelines, i18n files should use hierarchical and semantically clear translation key names such as
dashboard.overview.titleand maintain naming consistency.Also applies to: 1798-1799, 4162-4162
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/default/src/i18n/locales/zh.json` around lines 1463 - 1464, The i18n entries currently use English-phrase keys ("Enter the complete API request URL. The system will use this URL directly without appending any path." and "Enter the complete request URL. The system will use this URL directly without appending any path.") — convert these to hierarchical semantic keys (e.g., channel.api.fullRequestUrl and channel.api.fullRequestUrl.hint), update the JSON keys accordingly, and then update all places in the codebase that reference the original English keys to use the new hierarchical keys; also apply the same renaming pattern to the other occurrences noted in the review so all translations remain consistent.web/default/src/i18n/locales/en.json (1)
1463-1464: ⚡ Quick winUnify duplicated “complete URL” helper copy
These two entries are near-duplicates with only “API” differing, which will drift over time and create inconsistent UX wording. Prefer one canonical string (or one key with interpolation) and reuse it.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/default/src/i18n/locales/en.json` around lines 1463 - 1464, Unify the near-duplicate localization entries by keeping one canonical key/value and removing the duplicate: replace the two strings "Enter the complete API request URL. The system will use this URL directly without appending any path." and "Enter the complete request URL. The system will use this URL directly without appending any path." with a single shared key (or a key with an interpolated token like "Enter the complete {type} request URL...") and update callers to use that single key (or pass type="API" where needed) so the wording is consistent and not duplicated.web/default/src/i18n/locales/vi.json (1)
1463-1464: 🏗️ Heavy liftUse hierarchical i18n keys for new full-URL strings
The new keys are source-text keys (for example at Line 1798 and Line 4167) instead of semantic hierarchical keys. Please migrate these additions to structured keys (e.g.,
channels.form.fullUrl.label,channels.form.fullUrl.placeholder) and update call sites accordingly.As per coding guidelines,
web/default/src/i18n/**/*.{ts,tsx,json}must "Use hierarchical and semantically clear translation key names such asdashboard.overview.titleand maintain naming consistency".Also applies to: 1798-1799, 4162-4167
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/default/src/i18n/locales/vi.json` around lines 1463 - 1464, The new Vietnamese translations use source-text keys instead of hierarchical keys; replace the two string keys "Enter the complete API request URL. The system will use this URL directly without appending any path." and "Enter the complete request URL. The system will use this URL directly without appending any path." with semantically hierarchical keys (for example channels.form.fullUrl.label and channels.form.fullUrl.placeholder) in vi.json, move the empty values under those keys, and then update all call sites that reference the original source-text keys to use the new keys (e.g., channels.form.fullUrl.label / channels.form.fullUrl.placeholder) — do the same migration for the other occurrences of these source-text keys elsewhere in i18n files so naming is consistent across web/default/src/i18n.web/default/src/features/channels/lib/channel-form.ts (1)
394-395: ⚡ Quick winConsider optimizing settings JSON size by omitting false values.
The current implementation always sets
use_full_urlin the settings object, even when it'sfalse. This could bloat the JSON payload. Consider following the pattern used for other optional settings:// Use full URL setting — applies to all channel types -settingsObj.use_full_url = formData.use_full_url === true +if (formData.use_full_url === true) { + settingsObj.use_full_url = true +} else if ('use_full_url' in settingsObj) { + delete settingsObj.use_full_url +}This ensures the field is only present when explicitly enabled, making the stored JSON more compact and readable. The backend already uses
omitempty(dto/channel_settings.go:44), so omittingfalsevalues aligns with the backend's intent.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/default/src/features/channels/lib/channel-form.ts` around lines 394 - 395, The settings object always assigns settingsObj.use_full_url = formData.use_full_url === true which writes false into the JSON; change this to only set the property when the form value is true (mirror other optional settings) so the key is omitted when false—update the logic in channel-form.ts where settingsObj is built (referencing settingsObj, formData.use_full_url) to conditionally add settingsObj.use_full_url only if formData.use_full_url === true.relay/channel/api_request.go (1)
291-300: ⚡ Quick winConsider validating
ChannelBaseUrlwhenUseFullURLis enabled to provide clearer error messages.When
UseFullURLis true,ChannelBaseUrlis used directly without validation. SinceGetBaseURL()can return an empty string, an invalid URL could reachhttp.NewRequest(line 304) and produce a generic parse error. Add a check for non-empty and valid URL format before using it, or enhance the error message fromhttp.NewRequestto clarify the root cause when it fails on an empty or malformed URL.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@relay/channel/api_request.go` around lines 291 - 300, When info.ChannelMeta.ChannelOtherSettings.UseFullURL is true the code uses info.ChannelBaseUrl directly which can be empty or malformed and later causes a generic error in http.NewRequest; validate the value first by checking it's non-empty and parseable (e.g., call url.Parse on info.ChannelBaseUrl) and return a clear error like "invalid ChannelBaseUrl: empty or malformed" if parsing fails, or alternatively call GetRequestURL when parsing fails to produce a better message; update the branch handling UseFullURL and ensure any error returned references ChannelBaseUrl and UseFullURL so callers understand the root cause instead of the generic http.NewRequest parse error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx`:
- Around line 1805-1860: The toggle between Input and Select (useFullURL) can
lose/override user input because Select uses a hard fallback value and the
components unmount/mount; update the rendering so both controls bind directly to
the same field without a fallback (use value={field.value} and
onChange={field.onChange} for both Input and Select) and remove the "||
'https://ark.cn-beijing.volces.com'" default; if you need to preserve distinct
"custom" vs "preset" values, persist the custom URL in a separate local state
(e.g., customUrl) and sync it with the form field when toggling (read/write via
field.onChange) and ensure both Input and Select share a stable key/name so
validation (errors) and form state remain intact and no console errors occur
during the swap.
In `@web/default/src/i18n/locales/en.json`:
- Around line 1798-1799: The new phrase-based i18n keys ("Use Full URL", "Full
Request URL", "Full Request URL *") must be replaced with hierarchical semantic
keys to match project conventions: add keys like
channels.form.api.useFullUrl.label, channels.form.api.fullRequestUrl.label, and
channels.form.api.fullRequestUrl.requiredLabel in
web/default/src/i18n/locales/en.json (and mirror them in other locale files),
move the existing English strings under these keys, and update any code
references that use the old phrase keys to the new hierarchical keys (also check
the other occurrence noted around line 4167 and adjust similarly).
In `@web/default/src/i18n/locales/fr.json`:
- Around line 1287-1295: The FR locale JSON has multiple empty translations for
new "full URL" UI strings (keys like "e.g.,
https://api.example.com/suno/submit", "e.g.,
https://api.example.com/v1/chat/completions", "e.g.,
https://ark.cn-beijing.volces.com/api/v3/chat/completions", "e.g.,
https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
"e.g., https://fastgpt.run/api/openapi/v1/chat/completions" and the other
repeated keys at lines noted) — fill each empty value with an appropriate French
example string (e.g., "p. ex., https://...") to avoid blank UI labels/help text;
update the values in fr.json for the exact keys mentioned so they mirror the
existing translated patterns like "par ex., https://..." or "p. ex.,
https://..." and run a quick search for any remaining "" values for similar keys
to ensure none are left untranslated.
- Around line 1287-1295: The current fr.json entries use raw example
sentences/URLs as translation keys (e.g., "e.g.,
https://api.example.com/suno/submit", "e.g.,
https://api.openai.com/v1/chat/completions") which violates the i18n naming
convention; replace each raw-string key with a hierarchical semantic key (for
example channel.examples.suno, channel.examples.openai,
channel.examples.azure.docs, etc.), move the English example URL into the value
for fr.json (translated form only if needed), and ensure the new keys follow the
project's dot-separated pattern (e.g., channel.fullUrl.label,
channel.fullUrl.help, channel.fullUrl.examples.openai); update the corresponding
keys in other locale files and any components using the old keys so lookups use
the new semantic keys (also fix the other occurrences noted in the review).
In `@web/default/src/i18n/locales/ja.json`:
- Around line 1287-1295: Fill the empty Japanese translations for the newly
added full-URL keys in the ja.json locale by replacing each "" value with a
concise Japanese example string matching the pattern used elsewhere (e.g., "例:
https://..."); specifically update the keys "e.g.,
https://api.example.com/suno/submit", "e.g.,
https://api.example.com/v1/chat/completions", "e.g.,
https://ark.cn-beijing.volces.com/api/v3/chat/completions", "e.g.,
https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
and "e.g., https://fastgpt.run/api/openapi/v1/chat/completions" with appropriate
Japanese example text (e.g., "例: https://api.example.com/v1/chat/completions");
apply the same pattern to the other occurrences noted (around lines 1463-1464,
1798-1799, 4162, 4167) so no keys remain empty.
In `@web/default/src/i18n/locales/ru.json`:
- Around line 1287-1295: The new Russian locale entries for several Full URL
helper strings (for example the keys "e.g.,
https://api.example.com/suno/submit", "e.g.,
https://api.example.com/v1/chat/completions", "e.g.,
https://ark.cn-beijing.volces.com/api/v3/chat/completions", "e.g.,
https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
and "e.g., https://fastgpt.run/api/openapi/v1/chat/completions") are empty and
will render blank UI; fill each empty value with the appropriate Russian
translation (or a sensible fallback like the English example string) matching
the other nearby translated entries (e.g., use "например, <url>") so
placeholders/help text are visible in the ru.json file and consistent across the
Full URL fields.
In `@web/default/src/i18n/locales/vi.json`:
- Around line 1287-1295: Populate the empty Vietnamese translation values in
vi.json for the newly added keys so the UI placeholders don't render blank;
specifically provide appropriate Vietnamese strings for "e.g.,
https://api.example.com/suno/submit", "e.g.,
https://api.example.com/v1/chat/completions", "e.g.,
https://ark.cn-beijing.volces.com/api/v3/chat/completions", "e.g.,
https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
and "e.g., https://fastgpt.run/api/openapi/v1/chat/completions" (and the other
empty entries noted in the review), matching the existing style used for entries
like "e.g., https://api.openai.com/v1/chat/completions" and "ví dụ:
https://fastgpt.run/api/openapi" and keeping punctuation/format consistent.
---
Nitpick comments:
In `@relay/channel/api_request.go`:
- Around line 291-300: When info.ChannelMeta.ChannelOtherSettings.UseFullURL is
true the code uses info.ChannelBaseUrl directly which can be empty or malformed
and later causes a generic error in http.NewRequest; validate the value first by
checking it's non-empty and parseable (e.g., call url.Parse on
info.ChannelBaseUrl) and return a clear error like "invalid ChannelBaseUrl:
empty or malformed" if parsing fails, or alternatively call GetRequestURL when
parsing fails to produce a better message; update the branch handling UseFullURL
and ensure any error returned references ChannelBaseUrl and UseFullURL so
callers understand the root cause instead of the generic http.NewRequest parse
error.
In `@web/default/src/components/ui/combobox-input.tsx`:
- Around line 45-46: The default English strings for the props placeholder and
emptyText should be wrapped with the i18n t() function; import and call
useTranslation() in the component to get t, create defaultPlaceholder and
defaultEmptyText (e.g. const defaultPlaceholder = t('combobox.placeholder',
'Select or type...') and const defaultEmptyText = t('combobox.empty', 'No option
found.')), then use those defaults wherever placeholder and emptyText are
referenced (or assign them as default values for the component props) so the
ComboboxInput component uses translated defaults when parents don’t override
them.
In `@web/default/src/features/channels/lib/channel-form.ts`:
- Around line 394-395: The settings object always assigns
settingsObj.use_full_url = formData.use_full_url === true which writes false
into the JSON; change this to only set the property when the form value is true
(mirror other optional settings) so the key is omitted when false—update the
logic in channel-form.ts where settingsObj is built (referencing settingsObj,
formData.use_full_url) to conditionally add settingsObj.use_full_url only if
formData.use_full_url === true.
In `@web/default/src/i18n/locales/en.json`:
- Around line 1463-1464: Unify the near-duplicate localization entries by
keeping one canonical key/value and removing the duplicate: replace the two
strings "Enter the complete API request URL. The system will use this URL
directly without appending any path." and "Enter the complete request URL. The
system will use this URL directly without appending any path." with a single
shared key (or a key with an interpolated token like "Enter the complete {type}
request URL...") and update callers to use that single key (or pass type="API"
where needed) so the wording is consistent and not duplicated.
In `@web/default/src/i18n/locales/vi.json`:
- Around line 1463-1464: The new Vietnamese translations use source-text keys
instead of hierarchical keys; replace the two string keys "Enter the complete
API request URL. The system will use this URL directly without appending any
path." and "Enter the complete request URL. The system will use this URL
directly without appending any path." with semantically hierarchical keys (for
example channels.form.fullUrl.label and channels.form.fullUrl.placeholder) in
vi.json, move the empty values under those keys, and then update all call sites
that reference the original source-text keys to use the new keys (e.g.,
channels.form.fullUrl.label / channels.form.fullUrl.placeholder) — do the same
migration for the other occurrences of these source-text keys elsewhere in i18n
files so naming is consistent across web/default/src/i18n.
In `@web/default/src/i18n/locales/zh.json`:
- Around line 1463-1464: The i18n entries currently use English-phrase keys
("Enter the complete API request URL. The system will use this URL directly
without appending any path." and "Enter the complete request URL. The system
will use this URL directly without appending any path.") — convert these to
hierarchical semantic keys (e.g., channel.api.fullRequestUrl and
channel.api.fullRequestUrl.hint), update the JSON keys accordingly, and then
update all places in the codebase that reference the original English keys to
use the new hierarchical keys; also apply the same renaming pattern to the other
occurrences noted in the review so all translations remain consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3964f486-b3aa-4e85-8907-e048dd132ebf
📒 Files selected for processing (14)
dto/channel_settings.gorelay/channel/api_request.goweb/default/src/components/ui/combobox-input.tsxweb/default/src/features/channels/components/drawers/channel-mutate-drawer.tsxweb/default/src/features/channels/lib/channel-form.tsweb/default/src/features/channels/types.tsweb/default/src/i18n/locales/_reports/_sync-report.jsonweb/default/src/i18n/locales/_reports/zh.untranslated.jsonweb/default/src/i18n/locales/en.jsonweb/default/src/i18n/locales/fr.jsonweb/default/src/i18n/locales/ja.jsonweb/default/src/i18n/locales/ru.jsonweb/default/src/i18n/locales/vi.jsonweb/default/src/i18n/locales/zh.json
| {useFullURL ? ( | ||
| <FormControl> | ||
| <SelectTrigger> | ||
| <SelectValue /> | ||
| </SelectTrigger> | ||
| <Input | ||
| placeholder={t( | ||
| 'e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions' | ||
| )} | ||
| {...field} | ||
| /> | ||
| </FormControl> | ||
| <SelectContent alignItemWithTrigger={false}> | ||
| <SelectGroup> | ||
| <SelectItem value='https://ark.cn-beijing.volces.com'> | ||
| {t('https://ark.cn-beijing.volces.com')} | ||
| </SelectItem> | ||
| <SelectItem value='https://ark.ap-southeast.bytepluses.com'> | ||
| {t('https://ark.ap-southeast.bytepluses.com')} | ||
| </SelectItem> | ||
| <SelectItem value='doubao-coding-plan'> | ||
| {t('Doubao Coding Plan')} | ||
| </SelectItem> | ||
| </SelectGroup> | ||
| </SelectContent> | ||
| </Select> | ||
| ) : ( | ||
| <Select | ||
| items={[ | ||
| { | ||
| value: 'https://ark.cn-beijing.volces.com', | ||
| label: t('https://ark.cn-beijing.volces.com'), | ||
| }, | ||
| { | ||
| value: | ||
| 'https://ark.ap-southeast.bytepluses.com', | ||
| label: t( | ||
| 'https://ark.ap-southeast.bytepluses.com' | ||
| ), | ||
| }, | ||
| { | ||
| value: 'doubao-coding-plan', | ||
| label: t('Doubao Coding Plan'), | ||
| }, | ||
| ]} | ||
| onValueChange={field.onChange} | ||
| value={ | ||
| field.value || | ||
| 'https://ark.cn-beijing.volces.com' | ||
| } | ||
| > | ||
| <FormControl> | ||
| <SelectTrigger> | ||
| <SelectValue /> | ||
| </SelectTrigger> | ||
| </FormControl> | ||
| <SelectContent alignItemWithTrigger={false}> | ||
| <SelectGroup> | ||
| <SelectItem value='https://ark.cn-beijing.volces.com'> | ||
| {t('https://ark.cn-beijing.volces.com')} | ||
| </SelectItem> | ||
| <SelectItem value='https://ark.ap-southeast.bytepluses.com'> | ||
| {t( | ||
| 'https://ark.ap-southeast.bytepluses.com' | ||
| )} | ||
| </SelectItem> | ||
| <SelectItem value='doubao-coding-plan'> | ||
| {t('Doubao Coding Plan')} | ||
| </SelectItem> | ||
| </SelectGroup> | ||
| </SelectContent> | ||
| </Select> | ||
| )} |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check if similar component-switching patterns exist elsewhere in the codebase
# Search for other instances where form fields conditionally render different component types
rg -n -A5 -B5 'FormControl.*\?' --type=tsx --glob 'web/default/**/*.tsx' | rg -C3 'Select.*Input|Input.*Select'Repository: QuantumNous/new-api
Length of output: 91
🏁 Script executed:
#!/bin/bash
# Fixed search for conditional component rendering in form fields
# Use ts type which includes tsx files, or search more broadly
# Search for ternary operators that switch component types in form contexts
rg -n 'useFullURL\s*\?' --type ts web/default/src/features/channels/components/drawers/
# Also check for FormField usage around the area in question
echo "=== Checking FormField setup ==="
grep -n "base_url\|useFullURL" web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx | head -20Repository: QuantumNous/new-api
Length of output: 1203
🏁 Script executed:
#!/bin/bash
# Search for other conditional component rendering patterns in tsx files using fd and cat
echo "=== Looking for similar Select/Input switching patterns ==="
fd -e tsx web/default/src/features/channels/components/drawers/ --exec grep -l "Select\|Input" {} \; | head -5
# Check the specific file for the FormField structure
echo "=== Checking FormField controller for base_url ==="
sed -n '1790,1870p' web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsxRepository: QuantumNous/new-api
Length of output: 4648
🏁 Script executed:
#!/bin/bash
# Check for other conditional component rendering patterns in FormField controllers
# Search for similar ternary patterns inside FormField render functions
echo "=== Searching for other FormField with conditional component rendering ==="
rg -n 'render=\(\{.*field' web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx | wc -l
echo "Total FormField controls in this file"
# Look for any other Select/Input switching patterns
echo ""
echo "=== Checking if other form fields use conditional components ==="
rg -B20 'Select\|Input' web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx | rg -B5 'name=' | grep -E 'name=|Select|Input' | head -30Repository: QuantumNous/new-api
Length of output: 244
🏁 Script executed:
#!/bin/bash
# Check the actual structure of other base_url fields in different channel types
# to compare with VolcEngine
echo "=== Azure (type 3) base_url structure ==="
sed -n '1249,1295p' web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx | head -20
echo ""
echo "=== FastGPT (type 22) base_url structure ==="
sed -n '1489,1535p' web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx | head -20Repository: QuantumNous/new-api
Length of output: 2338
🏁 Script executed:
#!/bin/bash
# Verify the actual field binding completeness for VolcEngine
# Check lines around the VolcEngine conditional to see full context
echo "=== VolcEngine FormField controller full structure ==="
sed -n '1776,1810p' web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
echo ""
echo "=== Check if Input is missing any required field bindings ==="
sed -n '1805,1820p' web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
echo ""
echo "=== Check if there are any other component-type switches in the entire file ==="
rg -c 'useFullURL\s*\?\s*\(' web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsxRepository: QuantumNous/new-api
Length of output: 2701
Test the toggle interaction to ensure acceptable UX when switching between Input and Select modes.
The form binding is correct—both Input and Select components properly bind to the field controller, and form state should be preserved when switching modes. However, this pattern is unique in the file; other channel types (Azure, FastGPT, SunoAPI) keep the same Input component and only change label/placeholder text.
When toggling between modes, ensure:
- Custom URLs entered in Input mode can be manually re-entered or cleared if switching to Select
- Values selected in Select mode persist appropriately when switching to Input mode
- No console errors occur during the component swap
- Form validation state is maintained across mode switches
The Select component's fallback value (|| 'https://ark.cn-beijing.volces.com') prevents breakage, but the user experience should be validated to confirm switching modes feels intuitive.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx`
around lines 1805 - 1860, The toggle between Input and Select (useFullURL) can
lose/override user input because Select uses a hard fallback value and the
components unmount/mount; update the rendering so both controls bind directly to
the same field without a fallback (use value={field.value} and
onChange={field.onChange} for both Input and Select) and remove the "||
'https://ark.cn-beijing.volces.com'" default; if you need to preserve distinct
"custom" vs "preset" values, persist the custom URL in a separate local state
(e.g., customUrl) and sync it with the form field when toggling (read/write via
field.onChange) and ensure both Input and Select share a stable key/name so
validation (errors) and form state remain intact and no console errors occur
during the swap.
| "Full Request URL": "Full Request URL", | ||
| "Full Request URL *": "Full Request URL *", |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift
Use hierarchical i18n keys for new Full URL labels
The new keys are phrase-based ("Use Full URL", "Full Request URL", "Full Request URL *"). Please migrate these new additions to semantic hierarchical keys (for example: channels.form.api.useFullUrl.label, channels.form.api.fullRequestUrl.label, channels.form.api.fullRequestUrl.requiredLabel) to keep key naming consistent and maintainable.
As per coding guidelines, web/default/src/i18n/**/*.{ts,tsx,json} should “Use hierarchical and semantically clear translation key names such as dashboard.overview.title and maintain naming consistency”.
Also applies to: 4167-4167
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/default/src/i18n/locales/en.json` around lines 1798 - 1799, The new
phrase-based i18n keys ("Use Full URL", "Full Request URL", "Full Request URL
*") must be replaced with hierarchical semantic keys to match project
conventions: add keys like channels.form.api.useFullUrl.label,
channels.form.api.fullRequestUrl.label, and
channels.form.api.fullRequestUrl.requiredLabel in
web/default/src/i18n/locales/en.json (and mirror them in other locale files),
move the existing English strings under these keys, and update any code
references that use the old phrase keys to the new hierarchical keys (also check
the other occurrence noted around line 4167 and adjust similarly).
| "e.g., https://api.example.com/suno/submit": "", | ||
| "e.g., https://api.example.com/v1/chat/completions": "", | ||
| "e.g., https://api.openai.com/v1/chat/completions": "par ex., https://api.openai.com/v1/chat/completions", | ||
| "e.g., https://ark.cn-beijing.volces.com": "p. ex., https://ark.cn-beijing.volces.com", | ||
| "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "", | ||
| "e.g., https://docs-test-001.openai.azure.com": "par ex., https://docs-test-001.openai.azure.com", | ||
| "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "", | ||
| "e.g., https://fastgpt.run/api/openapi": "par ex., https://fastgpt.run/api/openapi", | ||
| "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "", |
There was a problem hiding this comment.
French locale entries are empty for newly added “full URL” UI strings.
Line 1287, Line 1288, Line 1291, Line 1293, Line 1295, Line 1463, Line 1464, Line 1798, Line 1799, Line 4162, and Line 4167 currently resolve to "". In FR locale this can render blank labels/help text or fallback behavior in critical form fields.
💡 Proposed fix (fill FR translations now, refine wording later if needed)
- "e.g., https://api.example.com/suno/submit": "",
- "e.g., https://api.example.com/v1/chat/completions": "",
+ "e.g., https://api.example.com/suno/submit": "par ex., https://api.example.com/suno/submit",
+ "e.g., https://api.example.com/v1/chat/completions": "par ex., https://api.example.com/v1/chat/completions",
@@
- "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "",
+ "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "par ex., https://ark.cn-beijing.volces.com/api/v3/chat/completions",
@@
- "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "",
+ "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "par ex., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
@@
- "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "",
+ "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "par ex., https://fastgpt.run/api/openapi/v1/chat/completions",
@@
- "Enter the complete API request URL. The system will use this URL directly without appending any path.": "",
- "Enter the complete request URL. The system will use this URL directly without appending any path.": "",
+ "Enter the complete API request URL. The system will use this URL directly without appending any path.": "Saisissez l’URL complète de requête API. Le système utilisera directement cette URL sans ajouter de chemin.",
+ "Enter the complete request URL. The system will use this URL directly without appending any path.": "Saisissez l’URL complète de requête. Le système utilisera directement cette URL sans ajouter de chemin.",
@@
- "Full Request URL": "",
- "Full Request URL *": "",
+ "Full Request URL": "URL complète de requête",
+ "Full Request URL *": "URL complète de requête *",
@@
- "Use a complete request URL without path concatenation, e.g. https://api.example.com/v1/chat/completions": "",
+ "Use a complete request URL without path concatenation, e.g. https://api.example.com/v1/chat/completions": "Utiliser une URL complète de requête sans concaténation de chemin, par ex. https://api.example.com/v1/chat/completions",
@@
- "Use Full URL": "",
+ "Use Full URL": "Utiliser l’URL complète",Also applies to: 1463-1464, 1798-1799, 4162-4167
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/default/src/i18n/locales/fr.json` around lines 1287 - 1295, The FR locale
JSON has multiple empty translations for new "full URL" UI strings (keys like
"e.g., https://api.example.com/suno/submit", "e.g.,
https://api.example.com/v1/chat/completions", "e.g.,
https://ark.cn-beijing.volces.com/api/v3/chat/completions", "e.g.,
https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
"e.g., https://fastgpt.run/api/openapi/v1/chat/completions" and the other
repeated keys at lines noted) — fill each empty value with an appropriate French
example string (e.g., "p. ex., https://...") to avoid blank UI labels/help text;
update the values in fr.json for the exact keys mentioned so they mirror the
existing translated patterns like "par ex., https://..." or "p. ex.,
https://..." and run a quick search for any remaining "" values for similar keys
to ensure none are left untranslated.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
New i18n keys are not hierarchical/semantic as required by project rules.
The new additions use full English sentences and raw example URLs as keys, which conflicts with the i18n key convention and makes reuse/maintenance harder. Prefer semantic keys (e.g. channel.fullUrl.label, channel.fullUrl.help, channel.fullUrl.examples.openai), with localized strings as values.
As per coding guidelines, "Use hierarchical and semantically clear translation key names such as dashboard.overview.title and maintain naming consistency".
Also applies to: 1463-1464, 1798-1799, 4162-4167
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/default/src/i18n/locales/fr.json` around lines 1287 - 1295, The current
fr.json entries use raw example sentences/URLs as translation keys (e.g., "e.g.,
https://api.example.com/suno/submit", "e.g.,
https://api.openai.com/v1/chat/completions") which violates the i18n naming
convention; replace each raw-string key with a hierarchical semantic key (for
example channel.examples.suno, channel.examples.openai,
channel.examples.azure.docs, etc.), move the English example URL into the value
for fr.json (translated form only if needed), and ensure the new keys follow the
project's dot-separated pattern (e.g., channel.fullUrl.label,
channel.fullUrl.help, channel.fullUrl.examples.openai); update the corresponding
keys in other locale files and any components using the old keys so lookups use
the new semantic keys (also fix the other occurrences noted in the review).
| "e.g., https://api.example.com/suno/submit": "", | ||
| "e.g., https://api.example.com/v1/chat/completions": "", | ||
| "e.g., https://api.openai.com/v1/chat/completions": "例: https://api.openai.com/v1/chat/completions", | ||
| "e.g., https://ark.cn-beijing.volces.com": "例: https://ark.cn-beijing.volces.com", | ||
| "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "", | ||
| "e.g., https://docs-test-001.openai.azure.com": "例: https://docs-test-001.openai.azure.com", | ||
| "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "", | ||
| "e.g., https://fastgpt.run/api/openapi": "例: https://fastgpt.run/api/openapi", | ||
| "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "", |
There was a problem hiding this comment.
Fill newly added Japanese translations (currently blank)
Several new keys for the full-URL flow are empty (""), which will render blank labels/help text in JA and degrade the channel-create UX.
💡 Suggested patch
- "e.g., https://api.example.com/suno/submit": "",
- "e.g., https://api.example.com/v1/chat/completions": "",
+ "e.g., https://api.example.com/suno/submit": "例: https://api.example.com/suno/submit",
+ "e.g., https://api.example.com/v1/chat/completions": "例: https://api.example.com/v1/chat/completions",
- "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "",
+ "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "例: https://ark.cn-beijing.volces.com/api/v3/chat/completions",
- "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "",
+ "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "例: https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
- "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "",
+ "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "例: https://fastgpt.run/api/openapi/v1/chat/completions",
- "Enter the complete API request URL. The system will use this URL directly without appending any path.": "",
- "Enter the complete request URL. The system will use this URL directly without appending any path.": "",
+ "Enter the complete API request URL. The system will use this URL directly without appending any path.": "完全な API リクエスト URL を入力してください。システムはこの URL をそのまま使用し、パスを追加しません。",
+ "Enter the complete request URL. The system will use this URL directly without appending any path.": "完全なリクエスト URL を入力してください。システムはこの URL をそのまま使用し、パスを追加しません。",
- "Full Request URL": "",
- "Full Request URL *": "",
+ "Full Request URL": "完全なリクエスト URL",
+ "Full Request URL *": "完全なリクエスト URL *",
- "Use a complete request URL without path concatenation, e.g. https://api.example.com/v1/chat/completions": "",
+ "Use a complete request URL without path concatenation, e.g. https://api.example.com/v1/chat/completions": "パス結合を行わず、完全なリクエスト URL を使用します(例: https://api.example.com/v1/chat/completions)",
- "Use Full URL": "",
+ "Use Full URL": "完全な URL を使用"Also applies to: 1463-1464, 1798-1799, 4162-4162, 4167-4167
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/default/src/i18n/locales/ja.json` around lines 1287 - 1295, Fill the
empty Japanese translations for the newly added full-URL keys in the ja.json
locale by replacing each "" value with a concise Japanese example string
matching the pattern used elsewhere (e.g., "例: https://..."); specifically
update the keys "e.g., https://api.example.com/suno/submit", "e.g.,
https://api.example.com/v1/chat/completions", "e.g.,
https://ark.cn-beijing.volces.com/api/v3/chat/completions", "e.g.,
https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
and "e.g., https://fastgpt.run/api/openapi/v1/chat/completions" with appropriate
Japanese example text (e.g., "例: https://api.example.com/v1/chat/completions");
apply the same pattern to the other occurrences noted (around lines 1463-1464,
1798-1799, 4162, 4167) so no keys remain empty.
| "e.g., https://api.example.com/suno/submit": "", | ||
| "e.g., https://api.example.com/v1/chat/completions": "", | ||
| "e.g., https://api.openai.com/v1/chat/completions": "например, https://api.openai.com/v1/chat/completions", | ||
| "e.g., https://ark.cn-beijing.volces.com": "например, https://ark.cn-beijing.volces.com", | ||
| "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "", | ||
| "e.g., https://docs-test-001.openai.azure.com": "например, https://docs-test-001.openai.azure.com", | ||
| "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "", | ||
| "e.g., https://fastgpt.run/api/openapi": "например, https://fastgpt.run/api/openapi", | ||
| "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "", |
There was a problem hiding this comment.
New RU i18n keys are empty and will render blank UI text
Several newly added strings for the Full URL feature are set to "" (e.g., Line 1798, Line 1799, Line 4167). In RU locale this will show blank labels/placeholders/help text instead of fallback content, making the new form options hard to use.
Suggested fix
- "e.g., https://api.example.com/suno/submit": "",
- "e.g., https://api.example.com/v1/chat/completions": "",
+ "e.g., https://api.example.com/suno/submit": "например, https://api.example.com/suno/submit",
+ "e.g., https://api.example.com/v1/chat/completions": "например, https://api.example.com/v1/chat/completions",
...
- "Enter the complete API request URL. The system will use this URL directly without appending any path.": "",
- "Enter the complete request URL. The system will use this URL directly without appending any path.": "",
+ "Enter the complete API request URL. The system will use this URL directly without appending any path.": "Введите полный URL запроса API. Система будет использовать этот URL напрямую без добавления пути.",
+ "Enter the complete request URL. The system will use this URL directly without appending any path.": "Введите полный URL запроса. Система будет использовать этот URL напрямую без добавления пути.",
...
- "Full Request URL": "",
- "Full Request URL *": "",
+ "Full Request URL": "Полный URL запроса",
+ "Full Request URL *": "Полный URL запроса *",
...
- "Use a complete request URL without path concatenation, e.g. https://api.example.com/v1/chat/completions": "",
- "Use Full URL": "",
+ "Use a complete request URL without path concatenation, e.g. https://api.example.com/v1/chat/completions": "Используйте полный URL запроса без конкатенации пути, например: https://api.example.com/v1/chat/completions",
+ "Use Full URL": "Использовать полный URL",Also applies to: 1463-1464, 1798-1799, 4162-4167
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/default/src/i18n/locales/ru.json` around lines 1287 - 1295, The new
Russian locale entries for several Full URL helper strings (for example the keys
"e.g., https://api.example.com/suno/submit", "e.g.,
https://api.example.com/v1/chat/completions", "e.g.,
https://ark.cn-beijing.volces.com/api/v3/chat/completions", "e.g.,
https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
and "e.g., https://fastgpt.run/api/openapi/v1/chat/completions") are empty and
will render blank UI; fill each empty value with the appropriate Russian
translation (or a sensible fallback like the English example string) matching
the other nearby translated entries (e.g., use "например, <url>") so
placeholders/help text are visible in the ru.json file and consistent across the
Full URL fields.
| "e.g., https://api.example.com/suno/submit": "", | ||
| "e.g., https://api.example.com/v1/chat/completions": "", | ||
| "e.g., https://api.openai.com/v1/chat/completions": "ví dụ: https://api.openai.com/v1/chat/completions", | ||
| "e.g., https://ark.cn-beijing.volces.com": "ví dụ, https://ark.cn-beijing.volces.com", | ||
| "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "", | ||
| "e.g., https://docs-test-001.openai.azure.com": "ví dụ: https://docs-test-001.openai.azure.com", | ||
| "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "", | ||
| "e.g., https://fastgpt.run/api/openapi": "ví dụ: https://fastgpt.run/api/openapi", | ||
| "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "", |
There was a problem hiding this comment.
Empty translation values will render blank UI text
Several newly added Vietnamese entries are empty ("") (e.g., Line 1287, Line 1463, Line 1798, Line 4167). This can make placeholders/labels/switch text disappear in the channel form for vi users.
💡 Proposed fix
- "e.g., https://api.example.com/suno/submit": "",
- "e.g., https://api.example.com/v1/chat/completions": "",
+ "e.g., https://api.example.com/suno/submit": "ví dụ: https://api.example.com/suno/submit",
+ "e.g., https://api.example.com/v1/chat/completions": "ví dụ: https://api.example.com/v1/chat/completions",
@@
- "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "",
+ "e.g., https://ark.cn-beijing.volces.com/api/v3/chat/completions": "ví dụ: https://ark.cn-beijing.volces.com/api/v3/chat/completions",
@@
- "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "",
+ "e.g., https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview": "ví dụ: https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
@@
- "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "",
+ "e.g., https://fastgpt.run/api/openapi/v1/chat/completions": "ví dụ: https://fastgpt.run/api/openapi/v1/chat/completions",
@@
- "Enter the complete API request URL. The system will use this URL directly without appending any path.": "",
- "Enter the complete request URL. The system will use this URL directly without appending any path.": "",
+ "Enter the complete API request URL. The system will use this URL directly without appending any path.": "Nhập URL yêu cầu API đầy đủ. Hệ thống sẽ dùng trực tiếp URL này mà không nối thêm đường dẫn.",
+ "Enter the complete request URL. The system will use this URL directly without appending any path.": "Nhập URL yêu cầu đầy đủ. Hệ thống sẽ dùng trực tiếp URL này mà không nối thêm đường dẫn.",
@@
- "Full Request URL": "",
- "Full Request URL *": "",
+ "Full Request URL": "URL yêu cầu đầy đủ",
+ "Full Request URL *": "URL yêu cầu đầy đủ *",
@@
- "Use a complete request URL without path concatenation, e.g. https://api.example.com/v1/chat/completions": "",
+ "Use a complete request URL without path concatenation, e.g. https://api.example.com/v1/chat/completions": "Sử dụng URL yêu cầu đầy đủ không nối đường dẫn, ví dụ: https://api.example.com/v1/chat/completions",
@@
- "Use Full URL": "",
+ "Use Full URL": "Sử dụng URL đầy đủ",Also applies to: 1463-1464, 1798-1799, 4162-4167
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/default/src/i18n/locales/vi.json` around lines 1287 - 1295, Populate the
empty Vietnamese translation values in vi.json for the newly added keys so the
UI placeholders don't render blank; specifically provide appropriate Vietnamese
strings for "e.g., https://api.example.com/suno/submit", "e.g.,
https://api.example.com/v1/chat/completions", "e.g.,
https://ark.cn-beijing.volces.com/api/v3/chat/completions", "e.g.,
https://docs-test-001.openai.azure.com/openai/deployments/model/chat/completions?api-version=2025-04-01-preview",
and "e.g., https://fastgpt.run/api/openapi/v1/chat/completions" (and the other
empty entries noted in the review), matching the existing style used for entries
like "e.g., https://api.openai.com/v1/chat/completions" and "ví dụ:
https://fastgpt.run/api/openapi" and keeping punctuation/format consistent.
Important
修复创建渠道,分类选择不显示label的问题、API地址增加“完整URL”支持
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
修复创建渠道,分类选择不显示label的问题、API地址增加“完整URL”支持
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
Summary by CodeRabbit
New Features
Localization