Skip to content
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
29 changes: 29 additions & 0 deletions __tests__/rntl/screens/DownloadManagerScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,35 @@ describe('DownloadManagerScreen', () => {
expect(getByText('3.0 MB/s')).toBeTruthy();
});

// Regression: downloadSpeed is 0 on the first progress tick of every download.
// The guard used to be `item.downloadSpeed && ... && (...)`, which evaluates to
// the number 0 and renders a bare "0" text node outside a <Text> β€” a hard crash
// on the real RN renderer. With the `!!(...)` fix the speed row is simply hidden.
it('hides the speed row when downloadSpeed is 0', () => {
mockDownloadStoreDownloads = {
'author/model-id/model-file.gguf': {
modelKey: 'author/model-id/model-file.gguf',
downloadId: 'dl-1',
modelId: 'author/model-id',
fileName: 'model-file.gguf',
quantization: 'Q4_K_M',
modelType: 'text',
status: 'running',
bytesDownloaded: 1024,
totalBytes: 4 * 1024 * 1024 * 1024,
combinedTotalBytes: 4 * 1024 * 1024 * 1024,
progress: 0.01,
downloadSpeed: 0,
createdAt: Date.now(),
lastProgressAt: Date.now(),
},
};

const { getByText, queryByText } = render(<DownloadManagerScreen />);
expect(getByText('model-file.gguf')).toBeTruthy(); // renders without crashing
expect(queryByText(/\/s$/)).toBeNull(); // no speed row rendered at 0 B/s
});

it('shows storage total when models exist', () => {
setupSingleModelState({ modelOverrides: { fileSize: 1024 * 1024 * 1024 } }, 1024 * 1024 * 1024);

Expand Down
1 change: 1 addition & 0 deletions src/screens/ChatScreen/ChatScreenComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const NoModelScreen: React.FC<{
isLoading={isModelLoading}
currentModelPath={llmService.getLoadedModelPath()}
onSelectionComplete={() => setShowModelSelector(false)}
onAddServer={() => navigation.navigate('RemoteServers')}
/>
</SafeAreaView>
);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/DownloadManagerScreen/items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const ActiveDownloadCard: React.FC<ActiveDownloadCardProps> = ({ item, on
<Text style={styles.progressText}>
{formatBytes(item.bytesDownloaded)} / {formatBytes(item.fileSize)}
</Text>
{item.downloadSpeed && item.downloadSpeed > 0 && item.status === 'running' && (
{!!(item.downloadSpeed && item.downloadSpeed > 0) && item.status === 'running' && (
<Text style={styles.progressSpeedText}>{formatSpeed(item.downloadSpeed)}</Text>
)}
</View>
Expand Down