feat: add model download controller#149
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a framework-agnostic ModelDownloadController API for turning model cache/download operations into app-facing lifecycle snapshots, with cancellation, retry, cache-hit handling, verification, and redacted failure messages.
Changes:
- Introduces
ModelDownloadController, task stages, immutable snapshots, and exports them through the existing download manager barrel. - Adds unit tests covering cache hits/misses, validation, cancellation, retry, and URL redaction.
- Documents the new controller in lifecycle, chat app, recent releases, and changelog docs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/src/core/models/download/model_download_controller.dart |
Adds the controller, snapshot model, lifecycle stage enum, cancellation/retry handling, and error URL redaction. |
lib/src/core/models/download/model_download_manager.dart |
Exports the new controller through the existing download manager barrel. |
test/unit/core/models/download/model_download_controller_test.dart |
Adds unit coverage for controller behavior and failure redaction. |
website/docs/guides/model-lifecycle.md |
Adds lifecycle guide documentation and usage example for the controller. |
website/docs/examples/chat-app.md |
Notes how the chat app download UX relates to the new controller. |
website/docs/changelog/recent-releases.md |
Adds recent-release documentation for the controller. |
CHANGELOG.md |
Adds changelog entry for the new model download UX helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #149 +/- ##
==========================================
+ Coverage 78.32% 78.50% +0.17%
==========================================
Files 75 76 +1
Lines 9764 9885 +121
==========================================
+ Hits 7648 7760 +112
- Misses 2116 2125 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6cf3da5 to
35885bf
Compare
Summary
ModelDownloadController, a framework-agnostic app-facing helper that turns model cache/download operations into stable task snapshots.ensureModel()beforeready.Fixes #135
Production-readiness scope
ModelDownloadController.snapshotswithout depending on Flutter types.ModelDownloadManagerimplementations, remote cache checks, download progress callbacks, ready/failure/cancelled states, retry after failure/cancellation, and caller-visible redacted error messages.ModelLoadOptions.cancelTokenis rejected because the controller owns cooperative cancellation for the active task.Review Notes
DioExceptionType.cancelnow reports a paused cancellation, and the chat app adapter rejects unsupportedsha256options before cache/download success paths.Test Plan
dart analyzedart test test/unit/core/models/download --reporter compactdart test -p vm -j 1 --exclude-tags local-only --reporter compact— all passed, 1 skippednpm run buildinwebsite/git diff --check origin/main...HEADflutter analyzeinexample/chat_app/flutter testinexample/chat_app/flutter test test/model_download_controller_adapter_test.dart test/manage_models_screen_download_test.dartinexample/chat_app/2e3dcfaa17cc16da4b65e3d5e904e85a89b45cb6: Analyze & Lint, Docs Build Check, Linux/Web, macOS, Windows, Native Prompt Reuse Parity