Skip to content

Commit

Permalink
chore: prompt ui when offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Dec 6, 2024
1 parent 7b6a68f commit 88b107c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions web/containers/ModelDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ScrollArea,
Tabs,
useClickOutside,
useOnlineStatus,
} from '@janhq/joi'

import { useAtom, useAtomValue, useSetAtom } from 'jotai'
Expand All @@ -18,6 +19,7 @@ import {
ChevronDownIcon,
ChevronUpIcon,
DownloadCloudIcon,
WifiOff,
XIcon,
} from 'lucide-react'
import { twMerge } from 'tailwind-merge'
Expand Down Expand Up @@ -94,6 +96,8 @@ const ModelDropdown = ({

useClickOutside(() => setOpen(false), null, [dropdownOptions, toggle])

const { isOnline } = useOnlineStatus()

const [showEngineListModel, setShowEngineListModel] = useAtom(
showEngineListModelAtom
)
Expand Down Expand Up @@ -544,12 +548,16 @@ const ModelDropdown = ({
key={model.id}
className={twMerge(
'flex items-center justify-between gap-4 px-3 py-2 hover:bg-[hsla(var(--dropdown-menu-hover-bg))]',
!apiKey
(!apiKey || !isOnline) &&
!isLocalEngine(model.engine)
? 'cursor-not-allowed text-[hsla(var(--text-tertiary))]'
: 'text-[hsla(var(--text-primary))]'
)}
onClick={() => {
if (!apiKey && !isLocalEngine(model.engine))
if (
(!apiKey || !isOnline) &&
!isLocalEngine(model.engine)
)
return null
if (isDownloaded) {
onClickModelItem(model.id)
Expand Down Expand Up @@ -613,6 +621,12 @@ const ModelDropdown = ({
</div>
)
})}
{!isOnline && searchFilter === 'remote' && (
<div className="sticky bottom-0 flex items-start gap-2 border-t border-[hsla(var(--app-border))] bg-[hsla(var(--app-bg))] p-3 text-[hsla(var(--text-secondary))]">
<WifiOff />
<p>No internet connection. Please use on-device models.</p>
</div>
)}
</ScrollArea>
</div>
</div>
Expand Down

0 comments on commit 88b107c

Please sign in to comment.