diff --git a/core/http/react-ui/src/pages/ImportModel.jsx b/core/http/react-ui/src/pages/ImportModel.jsx index cf1345b89..d8cf73a96 100644 --- a/core/http/react-ui/src/pages/ImportModel.jsx +++ b/core/http/react-ui/src/pages/ImportModel.jsx @@ -241,14 +241,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 54f599e94..4f1e02391 100644 --- a/core/http/react-ui/src/pages/ModelEditor.jsx +++ b/core/http/react-ui/src/pages/ModelEditor.jsx @@ -297,6 +297,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 6bb9c143f..d0510d7b9 100644 --- a/docs/content/getting-started/models.md +++ b/docs/content/getting-started/models.md @@ -135,6 +135,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: