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 <p.kosseff@gmail.com>
(cherry picked from commit 0f54bdcb38)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
localai-org-maint-bot authored and Ettore Di Giacinto committed 2026-10-13 08:14:30 +00:00
1 parent addcec0c28
commit 91fefbd78f
3 files changed
+8 -2

No files matched your search

+3 -2
View File
@@ -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)
@@ -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')
}
+4
View File
@@ -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: