diff --git a/core/http/react-ui/src/pages/ImportModel.jsx b/core/http/react-ui/src/pages/ImportModel.jsx index d8093297e..882b19075 100644 --- a/core/http/react-ui/src/pages/ImportModel.jsx +++ b/core/http/react-ui/src/pages/ImportModel.jsx @@ -280,14 +280,15 @@ export default function ImportModel() { pollRef.current = setInterval(async () => { try { const data = await modelsApi.getJobStatus(jobId) - if (data.error || (data.message && data.message.startsWith('error:'))) { + if (data.cancelled || data.error || (data.message && data.message.startsWith('error:'))) { transferRateRef.current.reset(jobId) clearInterval(pollRef.current) pollRef.current = null setIsSubmitting(false) setJob(null) let msg = 'Unknown error' - if (typeof data.error === 'string') msg = data.error + if (data.cancelled) msg = 'Import cancelled' + else if (typeof data.error === 'string') msg = data.error else if (data.error?.message) msg = data.error.message else if (data.message) msg = data.message if (msg.startsWith('error: ')) msg = msg.substring(7) diff --git a/core/http/react-ui/src/pages/ModelEditor.jsx b/core/http/react-ui/src/pages/ModelEditor.jsx index 393dda1e3..5c16f59fb 100644 --- a/core/http/react-ui/src/pages/ModelEditor.jsx +++ b/core/http/react-ui/src/pages/ModelEditor.jsx @@ -301,6 +301,7 @@ export default function ModelEditor() { await new Promise(r => setTimeout(r, 1000)) let data try { data = await modelsApi.getJobStatus(jobId) } catch { continue } + if (data?.cancelled) throw new Error('Import cancelled') if (data?.error) { throw new Error(typeof data.error === 'string' ? data.error : 'model asset download failed') } diff --git a/docs/content/getting-started/models.md b/docs/content/getting-started/models.md index 4f5234a36..c182ae659 100644 --- a/docs/content/getting-started/models.md +++ b/docs/content/getting-started/models.md @@ -157,6 +157,10 @@ answers a queued import with a job id and a status URL to poll (`/models/jobs/{id}` — the same shape gallery installs use), and a download-free import with a plain success response. +If you cancel a queued import, the import page and model editor report the +cancellation and stay on the current page. They report success only after the +job succeeds. + ## Method 2: Installing from Hugging Face LocalAI can directly install models from Hugging Face: