Skip to content

Commit

Permalink
fix disabled right panel while server running
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 17, 2024
1 parent 2d9120f commit f7fe1a1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
3 changes: 3 additions & 0 deletions uikit/src/slider/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 8 additions & 1 deletion web/containers/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) => {
Expand Down Expand Up @@ -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>
)
}
Expand Down
11 changes: 0 additions & 11 deletions web/containers/DropdownListSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 4 additions & 0 deletions web/containers/ModelConfigInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getConfigurationsData } from '@/utils/componentSettings'

import { toSettingParams } from '@/utils/modelParam'

import { serverEnabledAtom } from '@/helpers/atoms/LocalServer.atom'
import {
engineParamsUpdateAtom,
getActiveThreadIdAtom,
Expand Down Expand Up @@ -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))) {
Expand Down Expand Up @@ -85,6 +88,7 @@ const ModelConfigInput: React.FC<Props> = ({
placeholder={placeholder}
onChange={onValueChanged}
value={value}
disabled={serverEnabled}
/>
</div>
)
Expand Down
5 changes: 5 additions & 0 deletions web/containers/SliderRightPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand All @@ -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)])
Expand Down
6 changes: 3 additions & 3 deletions web/screens/LocalServer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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)
Expand Down

0 comments on commit f7fe1a1

Please sign in to comment.