fix disabled right panel while server running
This commit is contained in:
parent
2d9120f34a
commit
f7fe1a1530
@ -3,6 +3,9 @@
|
||||
|
||||
&-track {
|
||||
@apply relative h-1.5 w-full grow overflow-hidden rounded-full bg-gray-200 dark:bg-gray-800;
|
||||
[data-disabled] {
|
||||
@apply cursor-not-allowed opacity-50;
|
||||
}
|
||||
}
|
||||
|
||||
&-range {
|
||||
|
||||
@ -18,6 +18,7 @@ import useUpdateModelParameters from '@/hooks/useUpdateModelParameters'
|
||||
import { getConfigurationsData } from '@/utils/componentSettings'
|
||||
import { toSettingParams } from '@/utils/modelParam'
|
||||
|
||||
import { serverEnabledAtom } from '@/helpers/atoms/LocalServer.atom'
|
||||
import {
|
||||
engineParamsUpdateAtom,
|
||||
getActiveThreadIdAtom,
|
||||
@ -43,6 +44,8 @@ const Checkbox: React.FC<Props> = ({ name, title, checked, description }) => {
|
||||
|
||||
const setEngineParamsUpdate = useSetAtom(engineParamsUpdateAtom)
|
||||
|
||||
const serverEnabled = useAtomValue(serverEnabledAtom)
|
||||
|
||||
const { stopModel } = useActiveModel()
|
||||
|
||||
const onCheckedChange = (checked: boolean) => {
|
||||
@ -74,7 +77,11 @@ const Checkbox: React.FC<Props> = ({ name, title, checked, description }) => {
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<Switch checked={checked} onCheckedChange={onCheckedChange} />
|
||||
<Switch
|
||||
checked={checked}
|
||||
onCheckedChange={onCheckedChange}
|
||||
disabled={serverEnabled}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -129,12 +129,6 @@ export default function DropdownListSidebar() {
|
||||
const model = downloadedModels.find((m) => m.id === modelId)
|
||||
setSelectedModel(model)
|
||||
|
||||
await stopModel()
|
||||
|
||||
if (activeModel?.id !== modelId) {
|
||||
await startModel(modelId)
|
||||
}
|
||||
|
||||
if (serverEnabled) {
|
||||
window.core?.api?.stopServer()
|
||||
setServerEnabled(false)
|
||||
@ -209,11 +203,6 @@ export default function DropdownListSidebar() {
|
||||
className={twMerge(
|
||||
x.id === selectedModel?.id && 'bg-secondary'
|
||||
)}
|
||||
onPointerUp={() => {
|
||||
if (x.id === selectedModel?.id) {
|
||||
startModel(x.id)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="flex w-full justify-between">
|
||||
<span className="line-clamp-1 block">{x.name}</span>
|
||||
|
||||
@ -18,6 +18,7 @@ import { getConfigurationsData } from '@/utils/componentSettings'
|
||||
|
||||
import { toSettingParams } from '@/utils/modelParam'
|
||||
|
||||
import { serverEnabledAtom } from '@/helpers/atoms/LocalServer.atom'
|
||||
import {
|
||||
engineParamsUpdateAtom,
|
||||
getActiveThreadIdAtom,
|
||||
@ -52,6 +53,8 @@ const ModelConfigInput: React.FC<Props> = ({
|
||||
|
||||
const { stopModel } = useActiveModel()
|
||||
|
||||
const serverEnabled = useAtomValue(serverEnabledAtom)
|
||||
|
||||
const onValueChanged = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
if (!threadId) return
|
||||
if (engineParams.some((x) => x.name.includes(name))) {
|
||||
@ -85,6 +88,7 @@ const ModelConfigInput: React.FC<Props> = ({
|
||||
placeholder={placeholder}
|
||||
onChange={onValueChanged}
|
||||
value={value}
|
||||
disabled={serverEnabled}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -21,6 +21,7 @@ import useUpdateModelParameters from '@/hooks/useUpdateModelParameters'
|
||||
import { getConfigurationsData } from '@/utils/componentSettings'
|
||||
import { toSettingParams } from '@/utils/modelParam'
|
||||
|
||||
import { serverEnabledAtom } from '@/helpers/atoms/LocalServer.atom'
|
||||
import {
|
||||
engineParamsUpdateAtom,
|
||||
getActiveThreadIdAtom,
|
||||
@ -49,6 +50,8 @@ const SliderRightPanel: React.FC<Props> = ({
|
||||
const { updateModelParameter } = useUpdateModelParameters()
|
||||
const threadId = useAtomValue(getActiveThreadIdAtom)
|
||||
|
||||
const serverEnabled = useAtomValue(serverEnabledAtom)
|
||||
|
||||
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom)
|
||||
|
||||
const modelSettingParams = toSettingParams(activeModelParams)
|
||||
@ -100,6 +103,7 @@ const SliderRightPanel: React.FC<Props> = ({
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
disabled={serverEnabled}
|
||||
/>
|
||||
<div className="relative mt-2 flex items-center justify-between text-gray-400">
|
||||
<p className="text-sm">{min}</p>
|
||||
@ -114,6 +118,7 @@ const SliderRightPanel: React.FC<Props> = ({
|
||||
min={min}
|
||||
max={max}
|
||||
value={String(value)}
|
||||
disabled={serverEnabled}
|
||||
onBlur={(e) => {
|
||||
if (Number(e.target.value) > Number(max)) {
|
||||
onValueChanged([Number(max)])
|
||||
|
||||
@ -34,7 +34,7 @@ import { useActiveModel } from '@/hooks/useActiveModel'
|
||||
import { useServerLog } from '@/hooks/useServerLog'
|
||||
|
||||
import { getConfigurationsData } from '@/utils/componentSettings'
|
||||
import { toRuntimeParams, toSettingParams } from '@/utils/modelParam'
|
||||
import { toSettingParams } from '@/utils/modelParam'
|
||||
|
||||
import EngineSetting from '../Chat/EngineSetting'
|
||||
|
||||
@ -58,9 +58,9 @@ const LocalServerScreen = () => {
|
||||
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom)
|
||||
|
||||
const modelEngineParams = toSettingParams(activeModelParams)
|
||||
const modelRuntimeParams = toRuntimeParams(activeModelParams)
|
||||
|
||||
const componentDataEngineSetting = getConfigurationsData(modelEngineParams)
|
||||
const componentDataRuntimeSetting = getConfigurationsData(modelRuntimeParams)
|
||||
|
||||
const { openServerLog, clearServerLog } = useServerLog()
|
||||
const { activeModel, startModel, stateModel } = useActiveModel()
|
||||
const [selectedModel] = useAtom(selectedModelAtom)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user