fix: surface model download progress and failures - #117
Merged
Conversation
The "RECOMMENDED FOR YOU" hero is the only place the recommended model can be downloaded from — it is deliberately filtered out of the list below — but heroAction only rendered three states, falling back to a bare "Download" button for everything else. So a download that was already running showed no progress at all (a second click hits the isDownloading guard and no-ops), and a download that had failed silently reverted to "Download": downloadError was written by the service but read by no view in the app, so a rate limit, a dropped connection or a full disk was invisible. - Hero now carries the full state machine: progress bar + percentage, Cancel, and on failure the reason plus a "Try again" button. - ModelRow shows download failures too, and its button reads "Try again". - Map failures to actionable text (offline / timeout / HF rate limit / out of disk space) instead of a raw localizedDescription. - Detect installed Parakeet models with AsrModels.modelsExist instead of "the cache dir is non-empty", so a half-finished download no longer reports as installed and hides the Download button for a model that cannot load. - refreshDownloadedModels() no longer wipes downloadProgress: the screen refreshes on every appearance, which reset a running download's bar to 0%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
A user on a fresh install reported being unable to download the model recommended to them.
The
RECOMMENDED FOR YOUhero is the only place the recommended model can be downloaded —AIModelsView.swiftdeliberately filters it out of the list below to avoid duplication. ButheroActiononly handled three states (installed+active, installed, everything else → a plain "Download" button), so:guard isDownloading[variant] != trueinModelDownloadServiceand silently no-ops.downloadErrorwas written by the service but read by no view in the app — a Hugging Face rate limit, a dropped connection, or a full disk was completely invisible.A third defect compounded it: Parakeet install detection was "cache dir exists and is non-empty", so a half-finished download reported as installed — the Download button disappeared for a model that could never load.
The fix
AIModelsView— hero carries the full state machine: live progress bar + percentage + spinner, a Cancel button, and on failure the actual reason with a "Try again" button.ModelRow— download failures render as an error note on the card; the button reads "Try again".ModelDownloadServiceAsrModels.modelsExist(at:version:)whether every required file is present.userFacingMessage(for:)maps failures to actionable text (no connection / timed out / HF rate-limiting / out of disk space).refreshDownloadedModels()no longer doesdownloadProgress.removeAll()— the screen refreshes on every appearance, which reset an in-flight download's bar to 0%. New puremergedProgress(...)rebuilds the map in one assignment and preserves running downloads.Testing
8 new unit tests in
ModelDownloadServiceTestscovering the two new pure helpers (progress merge vs. in-flight downloads, and the failure-message mapping).Note: this was authored on a machine without Xcode, so local
xcodebuildcould not run — all files passswiftc -parseand CI is the build/test gate here.Caveat on expectations: if the original download was failing for an environmental reason (HF rate limit, flaky network, disk space), this does not make it succeed — it makes the reason visible and offers a retry that resumes from files already fetched.