Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: object is destroyed block app exit #2623

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: object is destroyed block app exit
  • Loading branch information
louis-jan committed Apr 5, 2024
commit f9a1f3a4e3c45f1039b96298e3eb2a5950626eb7
1 change: 0 additions & 1 deletion core/src/node/api/restful/helper/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 335,6 @@ export const chatCompletions = async (request: any, reply: any) => {
headers['Authorization'] = `Bearer ${apiKey}`
headers['api-key'] = apiKey
}
console.debug(apiUrl)

if (requestedModel.engine === 'openai' && request.body.stop) {
// openai only allows max 4 stop words
Expand Down
22 changes: 14 additions & 8 deletions electron/managers/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 94,10 @@ class WindowManager {
}

closeQuickAskWindow(): void {
if (this._quickAskWindow?.isDestroyed()) return
this._quickAskWindow?.close()
this._quickAskWindow?.destroy()
this._quickAskWindow = undefined
this._quickAskWindowVisible = false
}

Expand All @@ -122,14 124,18 @@ class WindowManager {
}

cleanUp(): void {
this.mainWindow?.close()
this.mainWindow?.destroy()
this.mainWindow = undefined
this._quickAskWindow?.close()
this._quickAskWindow?.destroy()
this._quickAskWindow = undefined
this._quickAskWindowVisible = false
this._mainWindowVisible = false
if (!this.mainWindow?.isDestroyed()) {
this.mainWindow?.close()
this.mainWindow?.destroy()
this.mainWindow = undefined
this._mainWindowVisible = false
}
if (!this._quickAskWindow?.isDestroyed()) {
this._quickAskWindow?.close()
this._quickAskWindow?.destroy()
this._quickAskWindow = undefined
this._quickAskWindowVisible = false
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions web/hooks/useCreateNewThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 9,6 @@ import {
ThreadState,
Model,
AssistantTool,
events,
InferenceEvent,
} from '@janhq/core'
import { atom, useAtomValue, useSetAtom } from 'jotai'

Expand Down
4 changes: 2 additions & 2 deletions web/screens/Chat/ChatInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useEffect, useRef, useState } from 'react'

import { InferenceEvent, MessageStatus, events } from '@janhq/core'
import { MessageStatus } from '@janhq/core'

import {
Textarea,
Expand Down Expand Up @@ -44,7 44,7 @@ import {

const ChatInput: React.FC = () => {
const activeThread = useAtomValue(activeThreadAtom)
const { stateModel, activeModel } = useActiveModel()
const { stateModel } = useActiveModel()
const messages = useAtomValue(getCurrentChatMessagesAtom)

const [currentPrompt, setCurrentPrompt] = useAtom(currentPromptAtom)
Expand Down
2 changes: 0 additions & 2 deletions web/screens/Chat/EditChatInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 4,8 @@ import { useEffect, useRef, useState } from 'react'
import {
ConversationalExtension,
ExtensionTypeEnum,
InferenceEvent,
MessageStatus,
ThreadMessage,
events,
} from '@janhq/core'

import {
Expand Down
Loading