fix: warn user when no models to migrate during storage change (#433)

When user attempts to change model storage location with no models
downloaded, the migration API returns moved=0 early. Previously the UI
would still call setCustomModelsDir() and restart the server, causing
unexpected behavior (hang/connection lost).

This change checks migrationResult.moved === 0 and shows a helpful
toast message instead of proceeding with the storage change.

Fixes: #426

Co-authored-by: fuleinist <[email protected]>
This commit is contained in:
Chris Chen
2026-04-18 03:13:06 -07:00
committed by GitHub
co-authored by fuleinist
parent 9c76b5de2c
commit 882cabc7d2
@@ -977,7 +977,19 @@ export function ModelManagement() {
});
try {
// Start the migration (background task)
await apiClient.migrateModels(newDir);
const migrationResult = await apiClient.migrateModels(newDir);
// If no models to migrate, warn user and skip the change
if (migrationResult.moved === 0) {
setMigrating(false);
setMigrationProgress(null);
toast({
title: 'No models to migrate',
description: 'Download at least one model before changing the storage location.',
});
setPendingMigrateDir(null);
return;
}
// Connect to SSE for progress
await new Promise<void>((resolve, reject) => {