fix: 4094 - gpu mode toggle on by default but not affect for the first time launch
This commit is contained in:
parent
79287d5748
commit
d55b1dd2f8
@ -20,6 +20,7 @@ import {
|
||||
ModelEvent,
|
||||
SystemInformation,
|
||||
dirName,
|
||||
AppConfigurationEventName,
|
||||
} from '@janhq/core'
|
||||
import PQueue from 'p-queue'
|
||||
import ky from 'ky'
|
||||
@ -70,7 +71,7 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
|
||||
super.onLoad()
|
||||
|
||||
this.queue.add(() => this.clean())
|
||||
|
||||
|
||||
// Run the process watchdog
|
||||
const systemInfo = await systemInformation()
|
||||
this.queue.add(() => executeOnMain(NODE, 'run', systemInfo))
|
||||
@ -81,6 +82,15 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
|
||||
window.addEventListener('beforeunload', () => {
|
||||
this.clean()
|
||||
})
|
||||
|
||||
const currentMode = systemInfo.gpuSetting?.run_mode
|
||||
|
||||
events.on(AppConfigurationEventName.OnConfigurationUpdate, async () => {
|
||||
const systemInfo = await systemInformation()
|
||||
// Update run mode on settings update
|
||||
if (systemInfo.gpuSetting?.run_mode !== currentMode)
|
||||
this.setDefaultEngine(systemInfo)
|
||||
})
|
||||
}
|
||||
|
||||
async onUnload() {
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import {
|
||||
AppConfigurationEventName,
|
||||
GpuSetting,
|
||||
MonitoringExtension,
|
||||
OperatingSystemInfo,
|
||||
events,
|
||||
executeOnMain,
|
||||
} from '@janhq/core'
|
||||
|
||||
@ -37,6 +39,7 @@ export default class JanMonitoringExtension extends MonitoringExtension {
|
||||
|
||||
// Attempt to fetch nvidia info
|
||||
await executeOnMain(NODE, 'updateNvidiaInfo')
|
||||
events.emit(AppConfigurationEventName.OnConfigurationUpdate, {})
|
||||
}
|
||||
|
||||
onSettingUpdate<T>(key: string, value: T): void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user