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: hide Vulkan option for users who don't have GPU #4226

Merged
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
9 changes: 2 additions & 7 deletions web/containers/Providers/Jotai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import { Provider, atom } from 'jotai'

import { FileInfo } from '@/types/file'

export const editPromptAtom = atom<string>('')
export const currentPromptAtom = atom<string>('')
export const fileUploadAtom = atom<FileInfo[]>([])
Expand All @@ -12,13 +14,6 @@

export const selectedTextAtom = atom('')

export default function JotaiWrapper({ children }: PropsWithChildren) {

Check warning on line 17 in web/containers/Providers/Jotai.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

17 line is not covered with tests
return <Provider>{children}</Provider>
}

export type FileType = 'image' | 'pdf'

export type FileInfo = {
file: File
type: FileType
}
2 changes: 1 addition & 1 deletion web/screens/Settings/Advanced/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
const selectedGpu = gpuList
.filter((x) => gpusInUse.includes(x.id))
.map((y) => {
return y['name']

Check warning on line 82 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

82 line is not covered with tests
})

/**
Expand All @@ -88,7 +88,7 @@
* there is also a case where state update persist everytime user type in the input
*/
const updatePullOptions = useDebouncedCallback(
() => configurePullOptions(),

Check warning on line 91 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

91 line is not covered with tests
300
)
/**
Expand All @@ -101,7 +101,7 @@
if (value.trim().startsWith('http')) {
setProxy(value.trim())
} else {
setProxy('')

Check warning on line 104 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

104 line is not covered with tests
}
updatePullOptions()
},
Expand All @@ -119,10 +119,10 @@
relaunch: boolean = true
) => {
const appConfiguration: AppConfiguration =
await window.core?.api?.getAppConfigurations()
appConfiguration.quick_ask = e
await window.core?.api?.updateAppConfiguration(appConfiguration)
if (relaunch) window.core?.api?.relaunch()

Check warning on line 125 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

122-125 lines are not covered with tests
}

/**
Expand All @@ -132,15 +132,15 @@
* @returns void
*/
const updateVulkanEnabled = async (e: boolean, relaunch: boolean = true) => {
toaster({

Check warning on line 135 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

135 line is not covered with tests
title: 'Reload',
description: 'Vulkan settings updated. Reload now to apply the changes.',
})
stopModel()
setVulkanEnabled(e)
await saveSettings({ vulkan: e, gpusInUse: [] })

Check warning on line 141 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

139-141 lines are not covered with tests
// Relaunch to apply settings
if (relaunch) window.location.reload()

Check warning on line 143 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

143 line is not covered with tests
}

/**
Expand Down Expand Up @@ -188,7 +188,7 @@
try {
await fs.rm(`file://logs`)
} catch (err) {
console.error('Error clearing logs: ', err)

Check warning on line 191 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

191 line is not covered with tests
}

toaster({
Expand All @@ -204,10 +204,10 @@
* @returns
*/
const handleGPUChange = async (gpuId: string) => {
let updatedGpusInUse = [...gpusInUse]
if (updatedGpusInUse.includes(gpuId)) {
updatedGpusInUse = updatedGpusInUse.filter((id) => id !== gpuId)
if (

Check warning on line 210 in web/screens/Settings/Advanced/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

207-210 lines are not covered with tests
gpuEnabled &&
updatedGpusInUse.length === 0 &&
gpuId &&
Expand Down Expand Up @@ -436,7 +436,7 @@
)}

{/* Vulkan for AMD GPU/ APU and Intel Arc GPU */}
{!isMac && experimentalEnabled && (
{!isMac && gpuList.length > 0 && experimentalEnabled && (
<div className="flex w-full flex-col items-start justify-between gap-4 border-b border-[hsla(var(--app-border))] py-4 first:pt-0 last:border-none sm:flex-row">
<div className="space-y-1">
<div className="flex gap-x-2">
Expand Down
6 changes: 6 additions & 0 deletions web/types/file.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type FileType = 'image' | 'pdf'

export type FileInfo = {
file: File
type: FileType
}
4 changes: 2 additions & 2 deletions web/utils/messageRequestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
} from '@janhq/core'
import { ulid } from 'ulidx'

import { FileType } from '@/containers/Providers/Jotai'

import { Stack } from '@/utils/Stack'

import { FileType } from '@/types/file'

export class MessageRequestBuilder {
msgId: string
type: MessageRequestType
Expand Down
4 changes: 2 additions & 2 deletions web/utils/threadMessageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
ThreadMessage,
} from '@janhq/core'

import { FileInfo } from '@/containers/Providers/Jotai'

import { MessageRequestBuilder } from './messageRequestBuilder'

import { FileInfo } from '@/types/file'

export class ThreadMessageBuilder {
messageRequest: MessageRequestBuilder

Expand Down
Loading