| 1 | //! Tauri command `chat_download_progress`: bytes fetched so far for a model. |
| 2 | //! |
| 3 | //! Weight downloads run inside mistral.rs, which reports progress only to an |
| 4 | //! `indicatif` bar destined for the log — nothing the WebView can observe. The |
| 5 | //! HF cache directory is therefore the one shared surface between the transfer |
| 6 | //! and the UI, so Settings polls this while a model is loading to turn an |
| 7 | //! indeterminate spinner into a real percentage. |
| 8 | //! |
| 9 | //! A 646 MB UQFF model on a phone hotspot takes ten minutes or more; without |
| 10 | //! this the panel is indistinguishable from a hang for that whole time. |
| 11 | |
| 12 | /// Bytes of `model_id`'s weights present in the local HF cache, counting the |
| 13 | /// partially written file of a download still in flight. |
| 14 | /// |
| 15 | /// The caller already knows the model's expected total (`ModelInfo.size_bytes`) |
| 16 | /// and computes the percentage from it, so this stays a single number rather |
| 17 | /// than duplicating the size table on both sides of the IPC boundary. |
| 18 | /// |
| 19 | /// Returns `0` for an unknown id or an untouched cache, which the frontend |
| 20 | /// renders as an indeterminate state — the same thing it showed before. |
| 21 | #[cfg(any( |
| 22 | target_os = "macos", |
| 23 | target_os = "ios", |
| 24 | target_os = "android", |
| 25 | target_os = "windows" |
| 26 | ))] |
| 27 | #[tauri::command] |
| 28 | pub async fn chat_download_progress(model_id: String) -> u64 { |
| 29 | super::model_downloaded_bytes(&model_id) |
| 30 | } |
| 31 | |
| 32 | #[cfg(not(any( |
| 33 | target_os = "macos", |
| 34 | target_os = "ios", |
| 35 | target_os = "android", |
| 36 | target_os = "windows" |
| 37 | )))] |
| 38 | #[tauri::command] |
| 39 | pub async fn chat_download_progress(_model_id: String) -> u64 { |
| 40 | 0 |
| 41 | } |