fix: disable gpu drop down box if there's no GPU ready (#2046)
Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
This commit is contained in:
parent
fb13d57890
commit
b7e94aac02
@ -434,20 +434,20 @@ export default class JanModelExtension extends ModelExtension {
|
|||||||
handleDesktopEvents() {
|
handleDesktopEvents() {
|
||||||
if (window && window.electronAPI) {
|
if (window && window.electronAPI) {
|
||||||
window.electronAPI.onFileDownloadUpdate(
|
window.electronAPI.onFileDownloadUpdate(
|
||||||
async (_event: string, state: any | undefined) => {
|
async (_event: string, state: DownloadState | undefined) => {
|
||||||
if (!state) return
|
if (!state) return
|
||||||
state.downloadState = 'update'
|
state.downloadState = 'downloading'
|
||||||
events.emit(DownloadEvent.onFileDownloadUpdate, state)
|
events.emit(DownloadEvent.onFileDownloadUpdate, state)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
window.electronAPI.onFileDownloadError(
|
window.electronAPI.onFileDownloadError(
|
||||||
async (_event: string, state: any) => {
|
async (_event: string, state: DownloadState) => {
|
||||||
state.downloadState = 'error'
|
state.downloadState = 'error'
|
||||||
events.emit(DownloadEvent.onFileDownloadError, state)
|
events.emit(DownloadEvent.onFileDownloadError, state)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
window.electronAPI.onFileDownloadSuccess(
|
window.electronAPI.onFileDownloadSuccess(
|
||||||
async (_event: string, state: any) => {
|
async (_event: string, state: DownloadState) => {
|
||||||
state.downloadState = 'end'
|
state.downloadState = 'end'
|
||||||
events.emit(DownloadEvent.onFileDownloadSuccess, state)
|
events.emit(DownloadEvent.onFileDownloadSuccess, state)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,14 +85,14 @@ const Advanced = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const setUseGpuIfPossible = async () => {
|
const setUseGpuIfPossible = async () => {
|
||||||
const settings = await readSettings()
|
const settings = await readSettings()
|
||||||
setGpuEnabled(settings.run_mode === 'gpu')
|
setGpuEnabled(settings.run_mode === 'gpu' && gpuList.length > 0)
|
||||||
setGpusInUse(settings.gpus_in_use || [])
|
setGpusInUse(settings.gpus_in_use || [])
|
||||||
if (settings.gpus) {
|
if (settings.gpus) {
|
||||||
setGpuList(settings.gpus)
|
setGpuList(settings.gpus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setUseGpuIfPossible()
|
setUseGpuIfPossible()
|
||||||
}, [readSettings])
|
}, [readSettings, gpuList])
|
||||||
|
|
||||||
const clearLogs = async () => {
|
const clearLogs = async () => {
|
||||||
if (await fs.existsSync(`file://logs`)) {
|
if (await fs.existsSync(`file://logs`)) {
|
||||||
@ -254,7 +254,10 @@ const Advanced = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="mt-2 w-full rounded-lg bg-secondary p-4">
|
<div className="mt-2 w-full rounded-lg bg-secondary p-4">
|
||||||
<label className="mb-1 inline-block font-medium">Choose GPU</label>
|
<label className="mb-1 inline-block font-medium">Choose GPU</label>
|
||||||
<Select disabled={!gpuEnabled} value={selectedGpu.join()}>
|
<Select
|
||||||
|
disabled={gpuList.length === 0 || !gpuEnabled}
|
||||||
|
value={selectedGpu.join()}
|
||||||
|
>
|
||||||
<SelectTrigger className="w-[340px] bg-white">
|
<SelectTrigger className="w-[340px] bg-white">
|
||||||
<SelectValue placeholder={gpuSelectionPlaceHolder}>
|
<SelectValue placeholder={gpuSelectionPlaceHolder}>
|
||||||
<span className="line-clamp-1 w-full pr-8">
|
<span className="line-clamp-1 w-full pr-8">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user