diff --git a/src/components/ModelPicker.tsx b/src/components/ModelPicker.tsx index 6c414fa..f3a8f73 100644 --- a/src/components/ModelPicker.tsx +++ b/src/components/ModelPicker.tsx @@ -94,18 +94,10 @@ export function ModelPicker({ const modelDisplayName = getModelDisplayName(); - // Flatten the cloud models from all providers - const cloudModels = - !providersLoading && modelsByProviders - ? Object.entries(modelsByProviders).flatMap(([providerId, models]) => - models.map((model) => ({ - name: model.apiName, - displayName: model.displayName, - description: model.description || "", - tag: model.tag, - provider: providerId as ModelProvider, - })), - ) + // Get auto provider models (if any) + const autoModels = + !providersLoading && modelsByProviders && modelsByProviders["auto"] + ? modelsByProviders["auto"] : []; // Determine availability of local models @@ -130,58 +122,127 @@ export function ModelPicker({ - {" "} - {/* Increased width slightly */} Cloud Models + {/* Cloud models - loading state */} {providersLoading ? (
Loading models...
- ) : cloudModels.length === 0 ? ( + ) : !modelsByProviders || + Object.keys(modelsByProviders).length === 0 ? (
No cloud models available
) : ( /* Cloud models loaded */ - cloudModels.map((model) => ( - - - { - onModelSelect({ - name: model.name, - provider: model.provider, - }); - setOpen(false); - }} - > -
- - {model.displayName} + <> + {/* Auto models at top level if any */} + {autoModels.length > 0 && ( + <> + {autoModels.map((model) => ( + + + { + onModelSelect({ + name: model.apiName, + provider: "auto", + }); + setOpen(false); + }} + > +
+ + {model.displayName} + + auto + + + {model.tag && ( + + {model.tag} + + )} +
+
+
+ + {model.description} + +
+ ))} + {Object.keys(modelsByProviders).length > 1 && ( + + )} + + )} + + {/* Group other providers into submenus */} + {Object.entries(modelsByProviders).map(([providerId, models]) => { + // Skip auto provider as it's already handled + if (providerId === "auto") return null; + + return ( + + +
+ {providerId} - {model.provider} + {models.length} models - - {model.tag && ( - - {model.tag} - - )} -
- - - {model.description} - - )) +
+ + + {providerId} Models + + {models.map((model) => ( + + + { + onModelSelect({ + name: model.apiName, + provider: providerId as ModelProvider, + }); + setOpen(false); + }} + > +
+ {model.displayName} + {model.tag && ( + + {model.tag} + + )} +
+
+
+ + {model.description} + +
+ ))} +
+ + ); + })} + )} + {/* Local Models Parent SubMenu */}