feat(settings): add Ollama connection status check setting
- Add new setting to enable/disable Ollama connection status check - Update translations for the new setting across all supported languages
This commit is contained in:
@@ -113,6 +113,7 @@ export const Header: React.FC<Props> = ({
|
||||
<PageAssistSelect
|
||||
className="w-80"
|
||||
placeholder={t("common:selectAModel")}
|
||||
loadingText={t("common:selectAModel")}
|
||||
value={selectedModel}
|
||||
onChange={(e) => {
|
||||
setSelectedModel(e.value)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { cleanUrl } from "@/libs/clean-url"
|
||||
import { useStorage } from "@plasmohq/storage/hook"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { RotateCcw } from "lucide-react"
|
||||
import { useEffect, useState } from "react"
|
||||
@@ -12,6 +13,9 @@ import {
|
||||
export const PlaygroundEmpty = () => {
|
||||
const [ollamaURL, setOllamaURL] = useState<string>("")
|
||||
const { t } = useTranslation(["playground", "common"])
|
||||
|
||||
const [checkOllamaStatus] = useStorage("checkOllamaStatus", true)
|
||||
|
||||
const {
|
||||
data: ollamaInfo,
|
||||
status: ollamaStatus,
|
||||
@@ -23,19 +27,32 @@ export const PlaygroundEmpty = () => {
|
||||
const ollamaURL = await getOllamaURL()
|
||||
const isOk = await isOllamaRunning()
|
||||
|
||||
if (ollamaURL) {
|
||||
saveOllamaURL(ollamaURL)
|
||||
}
|
||||
|
||||
return {
|
||||
isOk,
|
||||
ollamaURL
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled: checkOllamaStatus
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (ollamaInfo?.ollamaURL) {
|
||||
setOllamaURL(ollamaInfo.ollamaURL)
|
||||
}
|
||||
}, [ollamaInfo])
|
||||
|
||||
if (!checkOllamaStatus) {
|
||||
return (
|
||||
<div className="mx-auto sm:max-w-xl px-4 mt-10">
|
||||
<div className="rounded-lg justify-center items-center flex flex-col border p-8 bg-gray-50 dark:bg-[#262626] dark:border-gray-600">
|
||||
<h1 className="text-sm font-medium text-center text-gray-500 dark:text-gray-400 flex gap-3 items-center justify-center">
|
||||
<span >👋</span>
|
||||
<span className="text-gray-700 dark:text-gray-300">
|
||||
{t("welcome")}
|
||||
</span>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div className="mx-auto sm:max-w-xl px-4 mt-10">
|
||||
<div className="rounded-lg justify-center items-center flex flex-col border p-8 bg-gray-50 dark:bg-[#262626] dark:border-gray-600">
|
||||
|
||||
@@ -16,13 +16,12 @@ import {
|
||||
import { useStorage } from "@plasmohq/storage/hook"
|
||||
|
||||
export const GeneralSettings = () => {
|
||||
const { clearChat } =
|
||||
useMessageOption()
|
||||
const { clearChat } = useMessageOption()
|
||||
|
||||
const [ speechToTextLanguage, setSpeechToTextLanguage ] = useStorage(
|
||||
"speechToTextLanguage",
|
||||
"en-US"
|
||||
)
|
||||
const [speechToTextLanguage, setSpeechToTextLanguage] = useStorage(
|
||||
"speechToTextLanguage",
|
||||
"en-US"
|
||||
)
|
||||
const [copilotResumeLastChat, setCopilotResumeLastChat] = useStorage(
|
||||
"copilotResumeLastChat",
|
||||
false
|
||||
@@ -41,6 +40,11 @@ export const GeneralSettings = () => {
|
||||
const [sendNotificationAfterIndexing, setSendNotificationAfterIndexing] =
|
||||
useStorage("sendNotificationAfterIndexing", false)
|
||||
|
||||
const [checkOllamaStatus, setCheckOllamaStatus] = useStorage(
|
||||
"checkOllamaStatus",
|
||||
true
|
||||
)
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const { mode, toggleDarkMode } = useDarkMode()
|
||||
@@ -160,6 +164,19 @@ export const GeneralSettings = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row justify-between">
|
||||
<div className="inline-flex items-center gap-2">
|
||||
<span className="text-gray-700 dark:text-neutral-50">
|
||||
{t("generalSettings.settings.ollamaStatus.label")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Switch
|
||||
checked={checkOllamaStatus}
|
||||
onChange={(checked) => setCheckOllamaStatus(checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row justify-between">
|
||||
<span className="text-gray-700 dark:text-neutral-50 ">
|
||||
{t("generalSettings.settings.darkMode.label")}
|
||||
|
||||
@@ -235,14 +235,16 @@ export const PageAssistSelect: React.FC<SelectProps> = ({
|
||||
onClick={() => !disabled && !isLoading && setIsOpen(!isOpen)}
|
||||
onKeyDown={handleKeyDown}
|
||||
className={`${defaultSelectClass} ${className}`}>
|
||||
<span className="!truncate flex items-center gap-2 ">
|
||||
{isLoading && <LoadingIndicator />}
|
||||
<span className="!truncate flex items-center gap-2 select-none">
|
||||
{isLoading && <LoadingIndicator />}
|
||||
{isLoading ? (
|
||||
loadingText
|
||||
) : selectedOption ? (
|
||||
selectedOption.label
|
||||
) : (
|
||||
<span className="dark:text-gray-400 text-sm">{placeholder}</span>
|
||||
<span className="dark:text-gray-500 font-semibold text-[14px]">
|
||||
{placeholder}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<ChevronDown
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { cleanUrl } from "@/libs/clean-url"
|
||||
import { useStorage } from "@plasmohq/storage/hook"
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query"
|
||||
import { Select } from "antd"
|
||||
import { RotateCcw } from "lucide-react"
|
||||
@@ -17,13 +18,15 @@ export const EmptySidePanel = () => {
|
||||
const [ollamaURL, setOllamaURL] = useState<string>("")
|
||||
const { t } = useTranslation(["playground", "common"])
|
||||
const queryClient = useQueryClient()
|
||||
const [checkOllamaStatus] = useStorage("checkOllamaStatus", true)
|
||||
|
||||
const {
|
||||
data: ollamaInfo,
|
||||
status: ollamaStatus,
|
||||
refetch,
|
||||
isRefetching
|
||||
} = useQuery({
|
||||
queryKey: ["ollamaStatus"],
|
||||
queryKey: ["ollamaStatus", checkOllamaStatus],
|
||||
queryFn: async () => {
|
||||
const ollamaURL = await getOllamaURL()
|
||||
const isOk = await isOllamaRunning()
|
||||
@@ -32,7 +35,7 @@ export const EmptySidePanel = () => {
|
||||
queryKey: ["getAllModelsForSelect"]
|
||||
})
|
||||
return {
|
||||
isOk,
|
||||
isOk: checkOllamaStatus ? isOk : true,
|
||||
models,
|
||||
ollamaURL
|
||||
}
|
||||
@@ -59,7 +62,7 @@ export const EmptySidePanel = () => {
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{!isRefetching && ollamaStatus === "success" ? (
|
||||
{!isRefetching && ollamaStatus === "success" && checkOllamaStatus ? (
|
||||
ollamaInfo.isOk ? (
|
||||
<div className="inline-flex items-center space-x-2">
|
||||
<div className="w-3 h-3 bg-green-500 rounded-full"></div>
|
||||
|
||||
Reference in New Issue
Block a user