The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): localize custom endpoint editing and feedback
brooklyn!053acdb02b97
diff --git a/apps/desktop/src/app/settings/custom-endpoints-settings.test.tsx b/apps/desktop/src/app/settings/custom-endpoints-settings.test.tsxindex 6bd0b33f45d..7cbbee812bb 100644--- a/apps/desktop/src/app/settings/custom-endpoints-settings.test.tsx+++ b/apps/desktop/src/app/settings/custom-endpoints-settings.test.tsx@@ -3,6 +3,7 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-libraimport { atom } from 'nanostores'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { type I18nContextValue, I18nProvider, useI18n } from '@/i18n'import type { CustomEndpointsResponse } from '@/types/hermes'const getCustomEndpoints = vi.fn()@@ -75,6 +76,45 @@ afterEach(async () => {})describe('CustomEndpointsSettings', () => {+ it('localizes endpoint editing on language changes without changing transport or draft identifiers', async () => {+ getCustomEndpoints.mockResolvedValue(emptyResponse)+ saveCustomEndpoint.mockResolvedValue(savedResponse)+ const { CustomEndpointsSettings } = await import('./custom-endpoints-settings')+ let language!: I18nContextValue++ function Surface() {+ language = useI18n()++ return <CustomEndpointsSettings />+ }++ render(+ <I18nProvider configClient={null} initialLocale="zh">+ <Surface />+ </I18nProvider>+ )+ await screen.findByText('暂无自定义端点')+ fireEvent.change(screen.getByRole('textbox', { name: '名称' }), { target: { value: 'Fixture Ω' } })+ fireEvent.change(screen.getByRole('textbox', { name: '端点 URL' }), { target: { value: 'http://fixture.test/v1' } })+ fireEvent.change(screen.getByRole('combobox', { name: '默认模型' }), { target: { value: 'fixture-model' } })+ fireEvent.click(screen.getByRole('button', { name: 'Responses API' }))+ await act(() => language.setLocale('zh-hant'))+ expect((screen.getByRole('textbox', { name: '名稱' }) as HTMLInputElement).value).toBe('Fixture Ω')+ expect(screen.getByText('API 模式')).toBeTruthy()+ expect(screen.getByRole('button', { name: '自動偵測' })).toBeTruthy()+ expect(saveCustomEndpoint).not.toHaveBeenCalled()+ fireEvent.click(screen.getByRole('button', { name: '儲存' }))+ expect(saveCustomEndpoint).toHaveBeenCalledWith(+ expect.objectContaining({+ name: 'Fixture Ω',+ api_mode: 'codex_responses',+ base_url: 'http://fixture.test/v1',+ model: 'fixture-model'+ }),+ 'default'+ )+ })+it('sends the chosen API mode and discovered alias metadata on Save (#93622)', async () => {getCustomEndpoints.mockResolvedValue(emptyResponse)validateCustomEndpoint.mockResolvedValue({diff --git a/apps/desktop/src/app/settings/custom-endpoints-settings.tsx b/apps/desktop/src/app/settings/custom-endpoints-settings.tsxindex 15374349d9d..f58fedd2936 100644--- a/apps/desktop/src/app/settings/custom-endpoints-settings.tsx+++ b/apps/desktop/src/app/settings/custom-endpoints-settings.tsx@@ -47,7 +47,6 @@ interface EndpointForm {}// Same choices as `hermes model`'s custom-provider setup; '' = runtime auto-detect.-// This panel is not internationalized — keep the literals it has.const API_MODE_OPTIONS: readonly { id: CustomEndpointApiMode; label: string }[] = [{ id: '', label: 'Auto-detect' },{ id: 'chat_completions', label: 'Chat Completions' },@@ -105,6 +104,14 @@ function toPayload(export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: CustomEndpointsSettingsProps) {const { t } = useI18n()+ const ce = t.settings.customEndpoints+ const copyRef = useRef(ce)+ copyRef.current = ce++ const apiModeOptions = API_MODE_OPTIONS.map(option =>+ option.id === '' ? { ...option, label: ce.autoDetect } : option+ )+// Shared settings "Applies to" scope: read/write this profile's endpoints,// not whichever Bot is active in the left rail. Undefined follows the// active profile (request-shaped — never pass null, which retargets primary).@@ -156,7 +163,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: CsetDiscoveredModels(current.models)}} catch (err) {- notifyError(err, 'Could not load custom endpoints')+ notifyError(err, copyRef.current.couldNotLoad)} finally {if (!cancelled) {setLoading(false)@@ -195,10 +202,10 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: CtriggerHaptic('success')onConfigSaved?.()- notify({ kind: 'success', message: 'Custom endpoint saved.' })+ notify({ kind: 'success', message: ce.endpointSaved })} catch (err) {if (mounted.current) {- notifyError(err, 'Save failed')+ notifyError(err, ce.saveFailed)}} finally {if (mounted.current) {@@ -235,21 +242,21 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C// The backend also POSTed the transport the runtime will use; name it so an// auto-detected mode is visible before Save (#93622).- const transport = API_MODE_OPTIONS.find(option => option.id === response.transport_checked)?.label- const reachable = transport ? `Endpoint is reachable (${transport} route served).` : 'Endpoint is reachable.'+ const transport = apiModeOptions.find(option => option.id === response.transport_checked)?.label+ const reachable = transport ? ce.endpointReachableTransport(transport) : ce.endpointReachablenotify({kind: 'success',- message: response.models.length ? `${reachable} Found ${response.models.length} models.` : reachable+ message: response.models.length ? ce.endpointReachableModels(reachable, response.models.length) : reachable})} else {notify({kind: response.reachable ? 'warning' : 'error',- message: response.message || 'Endpoint validation failed.'+ message: response.message || ce.endpointValidationFailed})}} catch (err) {if (mounted.current) {- notifyError(err, 'Validation failed')+ notifyError(err, ce.validationFailed)}} finally {if (mounted.current) {@@ -278,7 +285,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: CtriggerHaptic('success')} catch (err) {if (mounted.current) {- notifyError(err, 'Activation failed')+ notifyError(err, ce.activationFailed)}} finally {if (mounted.current) {@@ -288,8 +295,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C}async function handleDelete(endpoint: CustomEndpoint) {- // This panel is not internationalized at all — keep the literal it had.- if (!(await confirm({ destructive: true, title: `Delete ${endpoint.name}?` }))) {+ if (!(await confirm({ destructive: true, title: ce.deleteConfirm(endpoint.name) }))) {return}@@ -313,7 +319,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: CtriggerHaptic('success')} catch (err) {if (mounted.current) {- notifyError(err, 'Delete failed')+ notifyError(err, ce.deleteFailed)}} finally {if (mounted.current) {@@ -358,7 +364,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C{endpoint.is_current && (<Pill tone="primary"><Check className="size-3" />- Active+ {ce.active}</Pill>)}{endpoint.source === 'direct-config' && <Pill>config.yaml</Pill>}@@ -368,7 +374,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C</div><div className="mt-1 flex flex-wrap gap-2 text-xs text-muted-foreground"><span>{endpoint.model}</span>- {endpoint.has_api_key && <span>{endpoint.api_key_preview ?? 'API key set'}</span>}+ {endpoint.has_api_key && <span>{endpoint.api_key_preview ?? ce.apiKeySet}</span>}</div></button><div className="flex items-center gap-2 sm:justify-end">@@ -379,7 +385,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: Cvariant="outline">{activating === endpoint.id ? <Loader2 className="animate-spin" /> : <Zap />}- Use+ {ce.use}</Button>{endpoint.source !== 'direct-config' && (<Button@@ -406,11 +412,11 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C</section><section>- <SectionHeading icon={Plus} title={form.id ? 'Edit Endpoint' : 'Add Endpoint'} />+ <SectionHeading icon={Plus} title={form.id ? ce.editTitle : ce.addTitle} /><div className="grid gap-3 rounded-md border border-border/50 p-3"><div className="grid gap-3 sm:grid-cols-2"><label className="grid gap-1.5 text-xs text-muted-foreground">- Name+ {ce.fields.name}<InputonChange={event => setForm(current => ({ ...current, name: event.target.value }))}placeholder={t.settings.customEndpoints.namePlaceholder}@@ -418,7 +424,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C/></label><label className="grid gap-1.5 text-xs text-muted-foreground">- Provider ID+ {ce.fields.providerId}<InputonChange={event => setForm(current => ({ ...current, id: event.target.value }))}placeholder="axet-proxy"@@ -427,7 +433,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C</label></div><label className="grid gap-1.5 text-xs text-muted-foreground">- Endpoint URL+ {ce.fields.endpointUrl}<InputonChange={event => setForm(current => ({ ...current, baseUrl: event.target.value }))}placeholder="http://127.0.0.1:8081/v1"@@ -435,17 +441,17 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C/></label><fieldset className="grid min-w-0 gap-1.5 text-xs text-muted-foreground">- <legend className="mb-1.5">API Mode</legend>+ <legend className="mb-1.5">{ce.apiMode}</legend><SegmentedControlclassName="w-full max-w-full"onChange={apiMode => setForm(current => ({ ...current, apiMode }))}- options={API_MODE_OPTIONS}+ options={apiModeOptions}value={form.apiMode}/></fieldset><div className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_12rem]"><label className="grid gap-1.5 text-xs text-muted-foreground">- Default Model+ {ce.fields.defaultModel}<Inputlist="custom-endpoint-models"onChange={event => setForm(current => ({ ...current, model: event.target.value }))}@@ -459,7 +465,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C</datalist></label><label className="grid gap-1.5 text-xs text-muted-foreground">- Context+ {ce.fields.context}<InputinputMode="numeric"onChange={event => setForm(current => ({ ...current, contextLength: event.target.value }))}@@ -469,10 +475,10 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C</label></div><label className="grid gap-1.5 text-xs text-muted-foreground">- API Key+ {ce.fields.apiKey}<InputonChange={event => setForm(current => ({ ...current, apiKey: event.target.value }))}- placeholder={form.id ? 'Leave blank to keep current key' : 'Optional'}+ placeholder={form.id ? ce.fields.apiKeyNewPlaceholder : ce.fields.apiKeyPlaceholder}type="password"value={form.apiKey}/>@@ -483,14 +489,14 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: Cchecked={form.makeDefault}onCheckedChange={checked => setForm(current => ({ ...current, makeDefault: checked === true }))}/>- Use for new chats+ {ce.fields.useNewChats}</label><label className="flex items-center gap-2"><Checkboxchecked={form.discoverModels}onCheckedChange={checked => setForm(current => ({ ...current, discoverModels: checked === true }))}/>- Discover models+ {ce.fields.discoverModels}</label></div><div className="flex flex-wrap gap-2">@@ -500,11 +506,11 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: Cvariant="outline">{testing ? <Loader2 className="animate-spin" /> : <Zap />}- Test+ {ce.test}</Button><Button disabled={saving || !canSave} onClick={() => void handleSave()}>{saving ? <Loader2 className="animate-spin" /> : <Save />}- Save+ {ce.save}</Button><ButtonclassName={cn(!form.id && 'hidden')}@@ -516,7 +522,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: Ctype="button"variant="ghost">- New endpoint+ {ce.newEndpoint}</Button></div></div>diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 8013f4eec8b..6f5294e3740 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -1195,6 +1195,39 @@ export const en: Translations = {backendIdleTimeoutTitle: 'Backend Idle Timeout'},customEndpoints: {+ active: 'Active',+ apiKeySet: 'API key set',+ use: 'Use',+ editTitle: 'Edit Endpoint',+ addTitle: 'Add Endpoint',+ fields: {+ name: 'Name',+ providerId: 'Provider ID',+ endpointUrl: 'Endpoint URL',+ defaultModel: 'Default Model',+ context: 'Context',+ apiKey: 'API Key',+ apiKeyNewPlaceholder: 'Leave blank to keep current key',+ apiKeyPlaceholder: 'Optional',+ useNewChats: 'Use for new chats',+ discoverModels: 'Discover models'+ },+ test: 'Test',+ save: 'Save',+ newEndpoint: 'New endpoint',+ apiMode: 'API Mode',+ autoDetect: 'Auto-detect',+ couldNotLoad: 'Could not load custom endpoints',+ endpointSaved: 'Custom endpoint saved.',+ saveFailed: 'Save failed',+ endpointReachable: 'Endpoint is reachable.',+ endpointReachableTransport: transport => `Endpoint is reachable (${transport} route served).`,+ endpointReachableModels: (reachable, count) => `${reachable} Found ${count} models.`,+ endpointValidationFailed: 'Endpoint validation failed.',+ validationFailed: 'Validation failed',+ activationFailed: 'Activation failed',+ deleteConfirm: name => `Delete ${name}?`,+ deleteFailed: 'Delete failed',title: 'Custom Endpoints',deleteEndpoint: 'Delete endpoint',emptyDescription: 'Add an OpenAI-compatible endpoint below.',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 5db61ae2790..716bb47ffcb 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -993,6 +993,39 @@ export interface Translations {backendIdleTimeoutTitle: string}customEndpoints: {+ active: string+ apiKeySet: string+ use: string+ editTitle: string+ addTitle: string+ fields: {+ name: string+ providerId: string+ endpointUrl: string+ defaultModel: string+ context: string+ apiKey: string+ apiKeyNewPlaceholder: string+ apiKeyPlaceholder: string+ useNewChats: string+ discoverModels: string+ }+ test: string+ save: string+ newEndpoint: string+ apiMode: string+ autoDetect: string+ couldNotLoad: string+ endpointSaved: string+ saveFailed: string+ endpointReachable: string+ endpointReachableTransport: (transport: string) => string+ endpointReachableModels: (reachable: string, count: number) => string+ endpointValidationFailed: string+ validationFailed: string+ activationFailed: string+ deleteConfirm: (name: string) => string+ deleteFailed: stringtitle: stringdeleteEndpoint: stringemptyDescription: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 98efd90f5fb..74f37d7280a 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -955,6 +955,39 @@ export const zhHant = defineLocale({backendIdleTimeoutTitle: '後端閒置逾時(毫秒)'},customEndpoints: {+ active: '已啟用',+ apiKeySet: '已設定 API 金鑰',+ use: '使用',+ editTitle: '編輯端點',+ addTitle: '新增端點',+ fields: {+ name: '名稱',+ providerId: '供應商 ID',+ endpointUrl: '端點 URL',+ defaultModel: '預設模型',+ context: '上下文',+ apiKey: 'API 金鑰',+ apiKeyNewPlaceholder: '留空以保留目前金鑰',+ apiKeyPlaceholder: '選填',+ useNewChats: '用於新對話',+ discoverModels: '探索模型'+ },+ test: '測試',+ save: '儲存',+ newEndpoint: '新增端點',+ apiMode: 'API 模式',+ autoDetect: '自動偵測',+ couldNotLoad: '無法載入自訂端點',+ endpointSaved: '自訂端點已儲存。',+ saveFailed: '儲存失敗',+ endpointReachable: '端點可連線。',+ endpointReachableTransport: transport => `端點可連線(${transport} 路由已回應)。`,+ endpointReachableModels: (reachable, count) => `${reachable} 找到 ${count} 個模型。`,+ endpointValidationFailed: '端點驗證失敗。',+ validationFailed: '驗證失敗',+ activationFailed: '啟用失敗',+ deleteConfirm: name => `刪除 ${name}?`,+ deleteFailed: '刪除失敗',title: '自訂端點',deleteEndpoint: '刪除端點',emptyDescription: '在下方新增 OpenAI 相容端點。',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex f284c8c9113..8c361ae721e 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -1165,6 +1165,39 @@ export const zh = defineLocale({backendIdleTimeoutTitle: '后端空闲超时(毫秒)'},customEndpoints: {+ active: '已启用',+ apiKeySet: '已设置 API 密钥',+ use: '使用',+ editTitle: '编辑端点',+ addTitle: '添加端点',+ fields: {+ name: '名称',+ providerId: '提供商 ID',+ endpointUrl: '端点 URL',+ defaultModel: '默认模型',+ context: '上下文',+ apiKey: 'API 密钥',+ apiKeyNewPlaceholder: '留空以保留当前密钥',+ apiKeyPlaceholder: '可选',+ useNewChats: '用于新对话',+ discoverModels: '发现模型'+ },+ test: '测试',+ save: '保存',+ newEndpoint: '新建端点',+ apiMode: 'API 模式',+ autoDetect: '自动检测',+ couldNotLoad: '无法加载自定义端点',+ endpointSaved: '自定义端点已保存。',+ saveFailed: '保存失败',+ endpointReachable: '端点可连接。',+ endpointReachableTransport: transport => `端点可连接(${transport} 路由已响应)。`,+ endpointReachableModels: (reachable, count) => `${reachable} 找到 ${count} 个模型。`,+ endpointValidationFailed: '端点验证失败。',+ validationFailed: '验证失败',+ activationFailed: '启用失败',+ deleteConfirm: name => `删除 ${name}?`,+ deleteFailed: '删除失败',title: '自定义端点',deleteEndpoint: '删除端点',emptyDescription: '在下方添加兼容 OpenAI 的端点。',