feat(provider-form): custom User-Agent presets dropdown in advanced settings

Polish the provider-level User-Agent override UI on the Claude and Codex forms.

- Add a shared CustomUserAgentField (label + input + preset dropdown + live
  validation) so both forms stay in sync.
- Provide curated UA presets (Claude Code / Kilo Code families that pass
  coding-plan UA whitelists per #3671); the first is Claude Code's real
  `claude-cli/x (external, cli)` format. Whitelists gate on the name prefix,
  not the version, so static values stay valid across upgrades.
- Expose presets via a dropdown to the right of the input (z-[200] so it
  renders above the dialog layers) instead of inline chips.
- Move the field into the existing advanced/reasoning collapsibles.
- userAgent.ts mirrors the backend byte rule (reject only control chars;
  non-ASCII is allowed) for a non-blocking inline hint.
- i18n for all four locales (zh/en/ja/zh-TW).
This commit is contained in:
Jason
2026-06-10 16:39:26 +08:00
parent 8b925c2f2f
commit 596019505f
11 changed files with 212 additions and 56 deletions
+4
View File
@@ -1043,6 +1043,10 @@
"anthropicSmallFastModel": "Fast Model",
"apiFormat": "API Format",
"apiFormatHint": "Select the input format for the provider's API",
"customUserAgent": "Custom User-Agent",
"customUserAgentHint": "Only takes effect when local routing/proxy takeover is enabled; replaces the User-Agent in requests forwarded to the provider API.",
"customUserAgentInvalid": "User-Agent must not contain control characters (e.g. line breaks); otherwise it will be ignored.",
"customUserAgentPresets": "Presets",
"fullUrlLabel": "Full URL",
"fullUrlEnabled": "Full URL Mode",
"fullUrlDisabled": "Mark as Full URL",
+4
View File
@@ -1043,6 +1043,10 @@
"anthropicSmallFastModel": "高速モデル",
"apiFormat": "API フォーマット",
"apiFormatHint": "プロバイダー API の入力フォーマットを選択",
"customUserAgent": "カスタム User-Agent",
"customUserAgentHint": "ローカルルーティング/プロキシ引き継ぎが有効な場合にのみ適用され、プロバイダー API へ転送するリクエストの User-Agent を置き換えます。",
"customUserAgentInvalid": "User-Agent に制御文字(改行など)を含めることはできません。含まれている場合は無視されます。",
"customUserAgentPresets": "プリセット",
"fullUrlLabel": "フル URL",
"fullUrlEnabled": "フル URL モード",
"fullUrlDisabled": "フル URL として設定",
+4
View File
@@ -1014,6 +1014,10 @@
"anthropicSmallFastModel": "快速模型",
"apiFormat": "API 格式",
"apiFormatHint": "選擇供應商 API 的輸入格式",
"customUserAgent": "自訂 User-Agent",
"customUserAgentHint": "僅在開啟本地路由/代理接管後生效,會取代轉發至供應商 API 請求中的 User-Agent。",
"customUserAgentInvalid": "User-Agent 不能包含控制字元(如換行字元),否則將被忽略。",
"customUserAgentPresets": "預設",
"fullUrlLabel": "完整 URL",
"fullUrlEnabled": "完整 URL 模式",
"fullUrlDisabled": "標記為完整 URL",
+4
View File
@@ -1043,6 +1043,10 @@
"anthropicSmallFastModel": "快速模型",
"apiFormat": "API 格式",
"apiFormatHint": "选择供应商 API 的输入格式",
"customUserAgent": "自定义 User-Agent",
"customUserAgentHint": "仅在开启本地路由/代理接管后生效,会替换转发到供应商 API 请求中的 User-Agent。",
"customUserAgentInvalid": "User-Agent 不能包含控制字符(如换行符),否则将被忽略。",
"customUserAgentPresets": "预设",
"fullUrlLabel": "完整 URL",
"fullUrlEnabled": "完整 URL 模式",
"fullUrlDisabled": "标记为完整 URL",