Skip to content

Commit 1f52407

Browse files
committed
fix(webview/xai): provide complete ModelInfo fallback in useSelectedModel to satisfy UI type expectations
1 parent ad0852e commit 1f52407

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

webview-ui/src/components/ui/hooks/useSelectedModel.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,27 @@ function getSelectedModel({
165165
case "xai": {
166166
const id = apiConfiguration.apiModelId ?? xaiDefaultModelId
167167
const dynamicInfo = routerModels.xai?.[id]
168+
if (dynamicInfo) {
169+
return { id, info: dynamicInfo }
170+
}
168171
const staticInfo = xaiModels[id as keyof typeof xaiModels]
169-
const info = dynamicInfo ?? staticInfo
170-
return info ? { id, info } : { id, info: undefined }
172+
// Build a complete ModelInfo fallback to satisfy UI expectations until dynamic models load
173+
const info: ModelInfo = {
174+
...openAiModelInfoSaneDefaults,
175+
contextWindow:
176+
apiConfiguration.xaiModelContextWindow ??
177+
staticInfo?.contextWindow ??
178+
openAiModelInfoSaneDefaults.contextWindow,
179+
maxTokens: staticInfo?.maxTokens ?? openAiModelInfoSaneDefaults.maxTokens,
180+
supportsPromptCache: false, // Placeholder; dynamic API will provide real value
181+
supportsImages: false, // Placeholder; dynamic API will provide real value
182+
description: staticInfo?.description,
183+
supportsReasoningEffort:
184+
staticInfo && "supportsReasoningEffort" in staticInfo
185+
? staticInfo.supportsReasoningEffort
186+
: undefined,
187+
}
188+
return { id, info }
171189
}
172190
case "groq": {
173191
const id = apiConfiguration.apiModelId ?? groqDefaultModelId

0 commit comments

Comments
 (0)