Skip to content

Commit bb8dc88

Browse files
Fix TS errors
1 parent 5c32e54 commit bb8dc88

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/ui/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function App() {
1212

1313
useEffect(() => {
1414
if (!selectedModel && modelList.length > 0) {
15-
setSelectedModel(modelList[0].id);
15+
setSelectedModel(modelList[0]?.id ?? '');
1616
}
1717
}, [modelList, selectedModel]);
1818

src/ui/model/useEngine.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,21 @@ export function useEngine() {
3838
const currentActive = activeArtifactRef.current;
3939
if (currentActive && currentActive !== label) {
4040
const j = artifacts.findIndex(a => a.label === currentActive);
41-
if (j >= 0 && artifacts[j].status !== 'done') artifacts[j] = { ...artifacts[j], status: 'downloading' };
41+
if (j >= 0) {
42+
const cur = artifacts[j]!;
43+
if (cur.status !== 'done') artifacts[j] = { label: cur.label, status: 'downloading' };
44+
}
4245
}
4346
if (idx === -1) {
4447
artifacts.push({ label, status: 'downloading' });
45-
} else if (artifacts[idx].status === 'pending') {
46-
artifacts[idx] = { ...artifacts[idx], status: 'downloading' };
48+
} else {
49+
const cur = artifacts[idx]!;
50+
if (cur.status === 'pending') artifacts[idx] = { label: cur.label, status: 'downloading' };
4751
}
4852
activeArtifactRef.current = label;
4953
}
5054
if (pct >= 100) {
51-
artifacts = artifacts.map(a => ({ ...a, status: 'done' }));
55+
artifacts = artifacts.map(a => ({ label: a.label, status: 'done' }));
5256
activeArtifactRef.current = null;
5357
}
5458
return { pct, phase, artifacts };
@@ -67,7 +71,7 @@ export function useEngine() {
6771
const unload = useCallback(() => {
6872
engineRef.current = null;
6973
setState('idle');
70-
setProgress({ pct: 0, phase: '' });
74+
setProgress({ pct: 0, phase: '', artifacts: [] });
7175
}, []);
7276

7377
const clearCaches = useCallback(async () => {

0 commit comments

Comments
 (0)