Skip to content

Commit

Permalink
fix: wait for cortex process overlay should be on top (#3224)
Browse files Browse the repository at this point in the history
* fix: wait for cortex process overlay should be on top

* chore: update cortex.js
  • Loading branch information
louis-menlo authored Aug 1, 2024
1 parent b1fa059 commit 2231be0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
18 changes: 15 additions & 3 deletions web/containers/WaitingCortexModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
import { Modal } from '@janhq/joi'
import { useAtomValue } from 'jotai'
import { useAtom, useAtomValue } from 'jotai'

import Spinner from '../Loader/Spinner'

import { waitingForCortexAtom } from '@/helpers/atoms/App.atom'
import { hostAtom } from '@/helpers/atoms/AppConfig.atom'

Check failure on line 7 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

There should be at least one empty line between import groups

Check failure on line 7 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

There should be at least one empty line between import groups

Check failure on line 7 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

There should be at least one empty line between import groups
import { useCallback, useEffect } from 'react'

Check failure on line 8 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

There should be at least one empty line between import groups

Check failure on line 8 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

`react` import should occur before import of `@janhq/joi`

Check failure on line 8 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

There should be at least one empty line between import groups

Check failure on line 8 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

`react` import should occur before import of `@janhq/joi`

Check failure on line 8 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

There should be at least one empty line between import groups

Check failure on line 8 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

`react` import should occur before import of `@janhq/joi`
import useCortex from '@/hooks/useCortex'

Check failure on line 9 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

`@/hooks/useCortex` import should occur before import of `../Loader/Spinner`

Check failure on line 9 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

`@/hooks/useCortex` import should occur before import of `../Loader/Spinner`

Check failure on line 9 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

`@/hooks/useCortex` import should occur before import of `../Loader/Spinner`

const WaitingForCortexModal: React.FC = () => {
const host = useAtomValue(hostAtom)
const open = useAtomValue(waitingForCortexAtom)
const [waitingForCortex, setWaitingForCortex] = useAtom(waitingForCortexAtom)
const { isSystemAlive } = useCortex()

Check failure on line 15 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Delete `··`

Check failure on line 15 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

Delete `··`

Check failure on line 15 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Delete `··`
const checkSystemAlive = useCallback(async () => {
setWaitingForCortex(!(await isSystemAlive()))
}, [])

Check warning on line 18 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

React Hook useCallback has missing dependencies: 'isSystemAlive' and 'setWaitingForCortex'. Either include them or remove the dependency array

Check warning on line 18 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

React Hook useCallback has missing dependencies: 'isSystemAlive' and 'setWaitingForCortex'. Either include them or remove the dependency array

Check warning on line 18 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

React Hook useCallback has missing dependencies: 'isSystemAlive' and 'setWaitingForCortex'. Either include them or remove the dependency array

Check failure on line 19 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Delete `··`

Check failure on line 19 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

Delete `··`

Check failure on line 19 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Delete `··`
// Check health for the first time on mount
useEffect(() => {
checkSystemAlive()
}, [])

Check warning on line 23 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

React Hook useEffect has a missing dependency: 'checkSystemAlive'. Either include it or remove the dependency array

Check warning on line 23 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

React Hook useEffect has a missing dependency: 'checkSystemAlive'. Either include it or remove the dependency array

Check warning on line 23 in web/containers/WaitingCortexModal/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

React Hook useEffect has a missing dependency: 'checkSystemAlive'. Either include it or remove the dependency array

return (
<Modal
hideClose
open={open}
open={waitingForCortex}
title={'Waiting for cortex'}
content={
<div className="flex gap-x-2">
Expand Down
2 changes: 1 addition & 1 deletion web/helpers/atoms/App.atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const mainViewStateAtom = atom<MainViewState>(MainViewState.Thread)

export const defaultJanDataFolderAtom = atom<string>('')

export const waitingForCortexAtom = atom<boolean>(false)
export const waitingForCortexAtom = atom<boolean>(true)

// Store panel atom
export const showLeftPanelAtom = atom<boolean>(true)
Expand Down
10 changes: 10 additions & 0 deletions web/hooks/useCortex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,15 @@ const useCortex = () => {
[host]
)

const isSystemAlive = useCallback(async () => {
try {
await cortex.system.status();

Check failure on line 324 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Delete `;`

Check failure on line 324 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

Delete `;`

Check failure on line 324 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Delete `;`
return true;

Check failure on line 325 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Delete `;`

Check failure on line 325 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

Delete `;`

Check failure on line 325 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Delete `;`
} catch {

Check failure on line 326 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Delete `·`

Check failure on line 326 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

Delete `·`

Check failure on line 326 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Delete `·`
return false;

Check failure on line 327 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

Delete `;·`

Check failure on line 327 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

Delete `;·`

Check failure on line 327 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

Delete `;·`
}
}, [host])

Check warning on line 329 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

React Hook useCallback has a missing dependency: 'cortex.system'. Either include it or remove the dependency array

Check warning on line 329 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

React Hook useCallback has a missing dependency: 'cortex.system'. Either include it or remove the dependency array

Check warning on line 329 in web/hooks/useCortex.ts

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

React Hook useCallback has a missing dependency: 'cortex.system'. Either include it or remove the dependency array

return {
fetchAssistants,
fetchThreads,
Expand All @@ -345,6 +354,7 @@ const useCortex = () => {
createModel,
initializeEngine,
getEngineStatuses,
isSystemAlive
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"yaml": "^2.4.5",
"@huggingface/hub": "^0.15.1",
"embla-carousel-react": "^8.1.5",
"@cortexso/cortex.js": "^0.1.5",
"@cortexso/cortex.js": "^0.1.6",
"@microsoft/fetch-event-source": "^2.0.1",
"@janhq/core": "link:./core",
"@janhq/joi": "link:./joi",
Expand Down

0 comments on commit 2231be0

Please sign in to comment.