fix(tui): don't fallback to first provider when agents loading

When using the placeholder agent (before real agents load), return
undefined instead of falling back to the first provider's model.
This prevents showing google-vertex-anthropic models before the
agent's configured model loads.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Artur Do Lago
2026-01-10 00:02:23 +01:00
parent b83f23ae27
commit da2d7beac8
@@ -205,15 +205,19 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
const currentModel = createMemo(() => {
const a = agent.current()
// If using placeholder agent (no name), don't return any model yet
if (!a?.name) {
return undefined
}
// Agent's configured model takes priority - trust it without validation
// Custom models (like cerebras/zai-glm-4.7) may not be in the provider list
if (a?.model) {
if (a.model) {
return a.model
}
// For non-configured agents, use cached selection or fallback (with validation)
return (
getFirstValidModel(
() => modelStore.model[a?.name ?? ""], // Cached selection
() => modelStore.model[a.name], // Cached selection
fallbackModel, // Global fallback
) ?? undefined
)