From 0f54bdcb38dafe6d59c0436e95e8ea0bd18a266b Mon Sep 17 00:00:00 2001
From: localai-org-maint-bot
<306269227+localai-org-maint-bot@users.noreply.github.com>
Date: Tue, 6 Oct 2026 18:03:11 +0000
Subject: [PATCH] fix(ui): stop cancelled imports before success
Cancelled gallery jobs also set processed. Handle cancellation before
completion so imports do not announce success or open a missing model.
Assisted-by: Codex:gpt-6
Signed-off-by: Plamen K. Kosseff
---
core/http/react-ui/src/pages/ImportModel.jsx | 5 +++--
core/http/react-ui/src/pages/ModelEditor.jsx | 1 +
docs/content/getting-started/models.md | 4 ++++
3 files changed, 8 insertions(+), 2 deletions(-)
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: