fix(web): guard the custom Claude models fetch against partial api clients

This commit is contained in:
2026-08-05 11:16:41 +08:00
parent f2cc29f5d7
commit dcb175bf0c
+12 -7
View File
@@ -269,13 +269,18 @@ export function NewSession(props: {
if (!props.api) {
return
}
props.api.getClaudeCustomModels().then((result) => {
if (!cancelled) {
setClaudeCustomModels(Array.isArray(result.models) ? result.models : [])
}
}).catch(() => {
// Custom models are optional — fall back to the built-in presets.
})
try {
props.api.getClaudeCustomModels().then((result) => {
if (!cancelled) {
setClaudeCustomModels(Array.isArray(result.models) ? result.models : [])
}
}).catch(() => {
// Custom models are optional — fall back to the built-in presets.
})
} catch {
// Partial api clients (tests, older hub versions) without the
// method must not break the New Session form.
}
return () => {
cancelled = true
}