fix: object is destroyed block app exit (#2623)
This commit is contained in:
parent
e0d6049d66
commit
9303e7aeb4
@ -335,7 +335,6 @@ export const chatCompletions = async (request: any, reply: any) => {
|
|||||||
headers['Authorization'] = `Bearer ${apiKey}`
|
headers['Authorization'] = `Bearer ${apiKey}`
|
||||||
headers['api-key'] = apiKey
|
headers['api-key'] = apiKey
|
||||||
}
|
}
|
||||||
console.debug(apiUrl)
|
|
||||||
|
|
||||||
if (requestedModel.engine === 'openai' && request.body.stop) {
|
if (requestedModel.engine === 'openai' && request.body.stop) {
|
||||||
// openai only allows max 4 stop words
|
// openai only allows max 4 stop words
|
||||||
|
|||||||
@ -94,8 +94,10 @@ class WindowManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
closeQuickAskWindow(): void {
|
closeQuickAskWindow(): void {
|
||||||
|
if (this._quickAskWindow?.isDestroyed()) return
|
||||||
this._quickAskWindow?.close()
|
this._quickAskWindow?.close()
|
||||||
this._quickAskWindow?.destroy()
|
this._quickAskWindow?.destroy()
|
||||||
|
this._quickAskWindow = undefined
|
||||||
this._quickAskWindowVisible = false
|
this._quickAskWindowVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,14 +124,18 @@ class WindowManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanUp(): void {
|
cleanUp(): void {
|
||||||
|
if (!this.mainWindow?.isDestroyed()) {
|
||||||
this.mainWindow?.close()
|
this.mainWindow?.close()
|
||||||
this.mainWindow?.destroy()
|
this.mainWindow?.destroy()
|
||||||
this.mainWindow = undefined
|
this.mainWindow = undefined
|
||||||
|
this._mainWindowVisible = false
|
||||||
|
}
|
||||||
|
if (!this._quickAskWindow?.isDestroyed()) {
|
||||||
this._quickAskWindow?.close()
|
this._quickAskWindow?.close()
|
||||||
this._quickAskWindow?.destroy()
|
this._quickAskWindow?.destroy()
|
||||||
this._quickAskWindow = undefined
|
this._quickAskWindow = undefined
|
||||||
this._quickAskWindowVisible = false
|
this._quickAskWindowVisible = false
|
||||||
this._mainWindowVisible = false
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,6 @@ import {
|
|||||||
ThreadState,
|
ThreadState,
|
||||||
Model,
|
Model,
|
||||||
AssistantTool,
|
AssistantTool,
|
||||||
events,
|
|
||||||
InferenceEvent,
|
|
||||||
} from '@janhq/core'
|
} from '@janhq/core'
|
||||||
import { atom, useAtomValue, useSetAtom } from 'jotai'
|
import { atom, useAtomValue, useSetAtom } from 'jotai'
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
|
|
||||||
import { InferenceEvent, MessageStatus, events } from '@janhq/core'
|
import { MessageStatus } from '@janhq/core'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Textarea,
|
Textarea,
|
||||||
@ -44,7 +44,7 @@ import {
|
|||||||
|
|
||||||
const ChatInput: React.FC = () => {
|
const ChatInput: React.FC = () => {
|
||||||
const activeThread = useAtomValue(activeThreadAtom)
|
const activeThread = useAtomValue(activeThreadAtom)
|
||||||
const { stateModel, activeModel } = useActiveModel()
|
const { stateModel } = useActiveModel()
|
||||||
const messages = useAtomValue(getCurrentChatMessagesAtom)
|
const messages = useAtomValue(getCurrentChatMessagesAtom)
|
||||||
|
|
||||||
const [currentPrompt, setCurrentPrompt] = useAtom(currentPromptAtom)
|
const [currentPrompt, setCurrentPrompt] = useAtom(currentPromptAtom)
|
||||||
|
|||||||
@ -4,10 +4,8 @@ import { useEffect, useRef, useState } from 'react'
|
|||||||
import {
|
import {
|
||||||
ConversationalExtension,
|
ConversationalExtension,
|
||||||
ExtensionTypeEnum,
|
ExtensionTypeEnum,
|
||||||
InferenceEvent,
|
|
||||||
MessageStatus,
|
MessageStatus,
|
||||||
ThreadMessage,
|
ThreadMessage,
|
||||||
events,
|
|
||||||
} from '@janhq/core'
|
} from '@janhq/core'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user