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() {
|
||||
if (window && window.electronAPI) {
|
||||
window.electronAPI.onFileDownloadUpdate(
|
||||
async (_event: string, state: any | undefined) => {
|
||||
async (_event: string, state: DownloadState | undefined) => {
|
||||
if (!state) return
|
||||
state.downloadState = 'update'
|
||||
state.downloadState = 'downloading'
|
||||
events.emit(DownloadEvent.onFileDownloadUpdate, state)
|
||||
}
|
||||
)
|
||||
window.electronAPI.onFileDownloadError(
|
||||
async (_event: string, state: any) => {
|
||||
async (_event: string, state: DownloadState) => {
|
||||
state.downloadState = 'error'
|
||||
events.emit(DownloadEvent.onFileDownloadError, state)
|
||||
}
|
||||
)
|
||||
window.electronAPI.onFileDownloadSuccess(
|
||||
async (_event: string, state: any) => {
|
||||
async (_event: string, state: DownloadState) => {
|
||||
state.downloadState = 'end'
|
||||
events.emit(DownloadEvent.onFileDownloadSuccess, state)
|
||||
}
|
||||
|
||||
@ -85,14 +85,14 @@ const Advanced = () => {
|
||||
useEffect(() => {
|
||||
const setUseGpuIfPossible = async () => {
|
||||
const settings = await readSettings()
|
||||
setGpuEnabled(settings.run_mode === 'gpu')
|
||||
setGpuEnabled(settings.run_mode === 'gpu' && gpuList.length > 0)
|
||||
setGpusInUse(settings.gpus_in_use || [])
|
||||
if (settings.gpus) {
|
||||
setGpuList(settings.gpus)
|
||||
}
|
||||
}
|
||||
setUseGpuIfPossible()
|
||||
}, [readSettings])
|
||||
}, [readSettings, gpuList])
|
||||
|
||||
const clearLogs = async () => {
|
||||
if (await fs.existsSync(`file://logs`)) {
|
||||
@ -254,7 +254,10 @@ const Advanced = () => {
|
||||
</div>
|
||||
<div className="mt-2 w-full rounded-lg bg-secondary p-4">
|
||||
<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">
|
||||
<SelectValue placeholder={gpuSelectionPlaceHolder}>
|
||||
<span className="line-clamp-1 w-full pr-8">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user