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: app crashes on select cloud model first time onboarding #4470

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
2 changes: 2 additions & 0 deletions web/screens/Settings/Engines/RemoteEngineSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
engines &&
Object.entries(engines)
.filter(([key]) => key === name)
.flatMap(([_, engineArray]) => engineArray as EngineConfig)[0]

Check warning on line 44 in web/screens/Settings/Engines/RemoteEngineSettings.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

'_' is defined but never used

Check warning on line 44 in web/screens/Settings/Engines/RemoteEngineSettings.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

'_' is defined but never used

Check warning on line 44 in web/screens/Settings/Engines/RemoteEngineSettings.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

'_' is defined but never used

Check warning on line 44 in web/screens/Settings/Engines/RemoteEngineSettings.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

'_' is defined but never used

const debounceRef = useRef<NodeJS.Timeout | null>(null)

Expand Down Expand Up @@ -115,6 +115,8 @@
}
}, [engine])

if (!engine) return null

return (
<ScrollArea className="h-full w-full">
<div className="block w-full px-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
)

if (manualRecommendModel.length === 2) {
return (

Check warning on line 65 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

65 line is not covered with tests
x.id === manualRecommendationModel[0] ||
x.id === manualRecommendationModel[1]
)
Expand Down Expand Up @@ -95,13 +95,13 @@
const getRows = (array: string[], itemsPerRow: number) => {
const rows = []
for (let i = 0; i < array.length; i += itemsPerRow) {
rows.push(array.slice(i, i + itemsPerRow))

Check warning on line 98 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

98 line is not covered with tests
}
return rows
}

const rows = getRows(
groupByEngine.sort((a, b) => a.localeCompare(b)),

Check warning on line 104 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

104 line is not covered with tests
itemsPerRow
)

Expand All @@ -125,7 +125,7 @@
<div className="relative" ref={refDropdown}>
<Input
value={searchValue}
onFocus={() => setIsOpen(true)}

Check warning on line 128 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

128 line is not covered with tests
onChange={(e) => {
setSearchValue(e.target.value)
}}
Expand All @@ -146,10 +146,10 @@
</div>
) : (
filteredModels.map((model) => {
const isDownloading = downloadingModels.some(
(md) => md === model.id

Check warning on line 150 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

149-150 lines are not covered with tests
)
return (

Check warning on line 152 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

152 line is not covered with tests
<div
key={model.id}
className="flex items-center justify-between gap-4 px-3 py-2 hover:bg-[hsla(var(--dropdown-menu-hover-bg))]"
Expand All @@ -172,7 +172,7 @@
size={18}
className="cursor-pointer text-[hsla(var(--app-link))]"
onClick={() =>
downloadModel(

Check warning on line 175 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

175 line is not covered with tests
model.sources[0].url,
model.id,
model.name
Expand All @@ -181,9 +181,9 @@
/>
) : (
Object.values(downloadStates)
.filter((x) => x.modelId === model.id)

Check warning on line 184 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

184 line is not covered with tests
.map((item) => (
<ProgressCircle

Check warning on line 186 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

186 line is not covered with tests
key={item.modelId}
percentage={
formatDownloadPercentage(
Expand Down Expand Up @@ -211,7 +211,7 @@
<p
className="cursor-pointer text-sm text-[hsla(var(--text-secondary))]"
onClick={() => {
setMainViewState(MainViewState.Hub)

Check warning on line 214 in web/screens/Thread/ThreadCenterPanel/ChatBody/OnDeviceStarterScreen/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

214 line is not covered with tests
}}
>
See All
Expand Down Expand Up @@ -298,40 +298,46 @@
key={rowIndex}
className="my-2 flex items-center gap-4 md:gap-10"
>
{row.map((remoteEngine) => {
const engineLogo = getLogoEngine(
remoteEngine as InferenceEngine
{row
.filter(
(e) =>
engines?.[e as InferenceEngine]?.[0]?.type ===
'remote'
)
.map((remoteEngine) => {
const engineLogo = getLogoEngine(
remoteEngine as InferenceEngine
)

return (
<div
className="flex cursor-pointer flex-col items-center justify-center gap-4"
key={remoteEngine}
onClick={() => {
setMainViewState(MainViewState.Settings)
setSelectedSetting(
remoteEngine as InferenceEngine
)
}}
>
{engineLogo && (
<Image
width={48}
height={48}
src={engineLogo}
alt="Engine logo"
className="h-10 w-10 flex-shrink-0"
/>
)}

<p className="font-medium">
{getTitleByEngine(
remoteEngine as InferenceEngine
return (
<div
className="flex cursor-pointer flex-col items-center justify-center gap-4"
key={remoteEngine}
onClick={() => {
setMainViewState(MainViewState.Settings)
setSelectedSetting(
remoteEngine as InferenceEngine
)
}}
>
{engineLogo && (
<Image
width={48}
height={48}
src={engineLogo}
alt="Engine logo"
className="h-10 w-10 flex-shrink-0"
/>
)}
</p>
</div>
)
})}

<p className="font-medium">
{getTitleByEngine(
remoteEngine as InferenceEngine
)}
</p>
</div>
)
})}
</div>
)
})}
Expand Down
Loading