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