Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions apps/desktop/src/renderer/locales/settings-provider-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ const zhCopy = {
: '',
].filter(Boolean).join(' '),
connectionSuccess: (name: string) => `连接成功 · ${name}`, connectionFailed: (name: string) => `连接失败 · ${name}`,
connectionFallbackTitle: (name: string) => `连接可用 · ${name}`,
connectionFallbackDetail: (selected: readonly string[], tested: string) =>
`你选择的 ${selected.join('、')} 当前未响应,已改用 ${tested} 验证连接可用;任务中继续使用你选择的模型可能会失败。`,
connectionTestError: (name: string) => `连接测试出错 · ${name}`, modelsFetched: (count: number, name: string) => `已拉取 ${count} 个模型 · ${name}`,
modelsFetchFailed: (name: string) => `拉取模型失败 · ${name}`,
modelsFetchFailedDetail: (message: string, troubleshooting: string) => `${message} · 当前继续显示静态列表,请确认 ${troubleshooting} 后重试。`,
Expand Down Expand Up @@ -299,6 +302,9 @@ const enCopy: ProviderSettingsCopy = {
: '',
].filter(Boolean).join(' '),
connectionSuccess: (name: string) => `Connected · ${name}`, connectionFailed: (name: string) => `Connection failed · ${name}`,
connectionFallbackTitle: (name: string) => `Connection works · ${name}`,
connectionFallbackDetail: (selected: readonly string[], tested: string) =>
`Your selected ${selected.join(', ')} didn't respond; verified the connection with ${tested} instead. Tasks using your selected model may fail.`,
connectionTestError: (name: string) => `Connection test error · ${name}`, modelsFetched: (count: number, name: string) => `Fetched ${count} ${count === 1 ? 'model' : 'models'} · ${name}`,
modelsFetchFailed: (name: string) => `Failed to fetch models · ${name}`,
modelsFetchFailedDetail: (message: string, troubleshooting: string) => `${message} · The static list remains visible. Check ${troubleshooting} and try again.`,
Expand Down
30 changes: 26 additions & 4 deletions apps/desktop/src/renderer/settings/use-connection-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,32 @@ export function useConnectionDetail(props: ConnectionDetailProps) {
const result: ConnectionTestResult = await props.bridge.test(connection.slug);
if (!isConnectionDetailCurrent(lifecycle)) return;
if (result.ok) {
toast.success(
copy.connectionSuccess(connection.name),
`${result.modelTested} · ${result.latencyMs} ms`,
);
// The backend probes the enabled models first, then the provider
// fallbacks (opencode-free tries each in turn until one answers). When
// the model that actually answered isn't one the user enabled, a plain
// "connection succeeded · <model>" reads as if their selection never
// took — and hides that their chosen model is currently down. Name both
// facts instead.
const testedId = result.modelTested;
const modelLabel = (id: string): string =>
models.find((model) => model.id === id)?.displayName ?? id;
// Inline the `testedId !== undefined` check so it narrows `testedId` to
// string for `modelLabel(testedId)` below.
if (
testedId !== undefined &&
enabledModelIds.length > 0 &&
!enabledModelIds.includes(testedId)
) {
toast.warning(
copy.connectionFallbackTitle(connection.name),
copy.connectionFallbackDetail(enabledModelIds.map(modelLabel), modelLabel(testedId)),
);
} else {
toast.success(
copy.connectionSuccess(connection.name),
`${result.modelTested} · ${result.latencyMs} ms`,
);
}
} else {
reportHostError(
copy.connectionFailed(connection.name),
Expand Down