Skip to content

Commit

Permalink
fix: loader bar selected model right panel
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 22, 2024
1 parent ad33823 commit 612445b
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 72 deletions.
146 changes: 74 additions & 72 deletions web/containers/DropdownListSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,85 +158,87 @@ export default function DropdownListSidebar() {
}

return (
<div
className={twMerge(
'relative w-full overflow-hidden rounded-md',
stateModel.loading && 'pointer-events-none bg-blue-200 text-blue-600'
)}
>
<Select value={selectedModel?.id} onValueChange={onValueSelected}>
<SelectTrigger className="relative w-full">
<SelectValue placeholder="Choose model to start">
{stateModel.loading && (
<div
className="z-5 absolute left-0 top-0 h-full w-full rounded-md bg-blue-100/80"
style={{ width: `${loader}%` }}
/>
)}
<span
className={twMerge(
'relative z-20',
stateModel.loading && 'font-medium'
<>
<div
className={twMerge(
'relative w-full overflow-hidden rounded-md',
stateModel.loading && 'pointer-events-none bg-blue-200 text-blue-600'
)}
>
<Select value={selectedModel?.id} onValueChange={onValueSelected}>
<SelectTrigger className="relative w-full">
<SelectValue placeholder="Choose model to start">
{stateModel.loading && (
<div
className="z-5 absolute left-0 top-0 h-full w-full rounded-md bg-blue-100/80"
style={{ width: `${loader}%` }}
/>
)}
>
{selectedName}
</span>
</SelectValue>
</SelectTrigger>
<SelectPortal>
<SelectContent className="right-2 block w-full min-w-[450px] pr-0">
<div className="flex w-full items-center space-x-2 px-4 py-2">
<MonitorIcon size={20} className="text-muted-foreground" />
<span>Local</span>
</div>
<div className="border-b border-border" />
{downloadedModels.length === 0 ? (
<div className="px-4 py-2">
<p>{`Oops, you don't have a model yet.`}</p>
<span
className={twMerge(
'relative z-20',
stateModel.loading && 'font-medium'
)}
>
{selectedName}
</span>
</SelectValue>
</SelectTrigger>
<SelectPortal>
<SelectContent className="right-2 block w-full min-w-[450px] pr-0">
<div className="flex w-full items-center space-x-2 px-4 py-2">
<MonitorIcon size={20} className="text-muted-foreground" />
<span>Local</span>
</div>
) : (
<SelectGroup>
{downloadedModels.map((x, i) => (
<SelectItem
key={i}
value={x.id}
className={twMerge(
x.id === selectedModel?.id && 'bg-secondary'
)}
>
<div className="flex w-full justify-between">
<span className="line-clamp-1 block">{x.name}</span>
<div className="space-x-2">
<span className="font-bold text-muted-foreground">
{toGibibytes(x.metadata.size)}
</span>
{x.engine == InferenceEngine.nitro && (
<ModelLabel size={x.metadata.size} />
)}
<div className="border-b border-border" />
{downloadedModels.length === 0 ? (
<div className="px-4 py-2">
<p>{`Oops, you don't have a model yet.`}</p>
</div>
) : (
<SelectGroup>
{downloadedModels.map((x, i) => (
<SelectItem
key={i}
value={x.id}
className={twMerge(
x.id === selectedModel?.id && 'bg-secondary'
)}
>
<div className="flex w-full justify-between">
<span className="line-clamp-1 block">{x.name}</span>
<div className="space-x-2">
<span className="font-bold text-muted-foreground">
{toGibibytes(x.metadata.size)}
</span>
{x.engine == InferenceEngine.nitro && (
<ModelLabel size={x.metadata.size} />
)}
</div>
</div>
</div>
</SelectItem>
))}
</SelectGroup>
)}
<div className="border-b border-border" />
<div className="w-full px-4 py-2">
<Button
block
className="bg-blue-100 font-bold text-blue-600 hover:bg-blue-100 hover:text-blue-600"
onClick={() => setMainViewState(MainViewState.Hub)}
>
Explore The Hub
</Button>
</div>
</SelectContent>
</SelectPortal>
</Select>
</SelectItem>
))}
</SelectGroup>
)}
<div className="border-b border-border" />
<div className="w-full px-4 py-2">
<Button
block
className="bg-blue-100 font-bold text-blue-600 hover:bg-blue-100 hover:text-blue-600"
onClick={() => setMainViewState(MainViewState.Hub)}
>
Explore The Hub
</Button>
</div>
</SelectContent>
</SelectPortal>
</Select>
</div>

<OpenAiKeyInput
selectedModel={selectedModel}
serverEnabled={serverEnabled}
/>
</div>
</>
)
}
1 change: 1 addition & 0 deletions web/containers/OpenAiKeyInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const OpenAiKeyInput: React.FC<Props> = ({ selectedModel, serverEnabled }) => {
readOpenAISettings().then((settings) => {
setOpenAISettings(settings)
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

if (!selectedModel || selectedModel.engine !== InferenceEngine.openai) {
Expand Down

0 comments on commit 612445b

Please sign in to comment.