mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(web): guard the custom Claude models fetch against partial api clients
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user