Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
bbbb6b2a
Unverified
Commit
bbbb6b2a
authored
Dec 10, 2025
by
Eva H
Committed by
GitHub
Dec 10, 2025
Browse files
app/ui: fix model capabilities not updating after download completion (#13179)
parent
76f88caf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
114 deletions
+19
-114
app/ui/app/src/hooks/useChats.ts
app/ui/app/src/hooks/useChats.ts
+19
-0
app/ui/app/src/hooks/useDownloadModel.ts
app/ui/app/src/hooks/useDownloadModel.ts
+0
-114
No files found.
app/ui/app/src/hooks/useChats.ts
View file @
bbbb6b2a
...
...
@@ -7,6 +7,7 @@ import { createQueryBatcher } from "./useQueryBatcher";
import
{
useRefetchModels
}
from
"
./useModels
"
;
import
{
useStreamingContext
}
from
"
@/contexts/StreamingContext
"
;
import
{
useSettings
}
from
"
./useSettings
"
;
import
{
getModelCapabilities
}
from
"
@/api
"
;
export
const
useChats
=
()
=>
{
return
useQuery
({
...
...
@@ -606,6 +607,24 @@ export const useSendMessage = (chatId: string) => {
queryClient
.
setQueryData
([
"
staleModels
"
],
newStaleMap
);
queryClient
.
invalidateQueries
({
queryKey
:
[
"
models
"
]
});
// Fetch fresh capabilities for the downloaded model
getModelCapabilities
(
selectedModel
.
model
)
.
then
((
capabilities
)
=>
{
queryClient
.
setQueryData
(
[
"
modelCapabilities
"
,
selectedModel
.
model
],
capabilities
,
);
})
.
catch
((
error
)
=>
{
console
.
error
(
"
Failed to fetch capabilities after download:
"
,
error
,
);
queryClient
.
invalidateQueries
({
queryKey
:
[
"
modelCapabilities
"
,
selectedModel
.
model
],
});
});
}
break
;
}
...
...
app/ui/app/src/hooks/useDownloadModel.ts
deleted
100644 → 0
View file @
76f88caf
import
{
useMutation
,
useQueryClient
}
from
"
@tanstack/react-query
"
;
import
{
useState
}
from
"
react
"
;
import
{
pullModel
}
from
"
@/api
"
;
import
{
useSelectedModel
}
from
"
./useSelectedModel
"
;
import
{
useSettings
}
from
"
./useSettings
"
;
interface
DownloadProgress
{
status
:
string
;
digest
?:
string
;
total
?:
number
;
completed
?:
number
;
done
?:
boolean
;
}
export
function
useDownloadModel
(
chatId
?:
string
)
{
const
queryClient
=
useQueryClient
();
const
{
selectedModel
}
=
useSelectedModel
(
chatId
);
const
{
setSettings
}
=
useSettings
();
const
[
downloadProgress
,
setDownloadProgress
]
=
useState
<
DownloadProgress
|
null
>
(
null
);
const
[
abortController
,
setAbortController
]
=
useState
<
AbortController
|
null
>
(
null
);
const
[
downloadingChatIds
,
setDownloadingChatIds
]
=
useState
<
Set
<
string
>>
(
new
Set
(),
);
const
mutation
=
useMutation
({
mutationFn
:
async
(
modelName
:
string
)
=>
{
const
controller
=
new
AbortController
();
setAbortController
(
controller
);
setDownloadProgress
({
status
:
"
Starting download...
"
});
if
(
chatId
)
{
setDownloadingChatIds
((
prev
)
=>
new
Set
(
prev
).
add
(
chatId
));
}
try
{
for
await
(
const
progress
of
pullModel
(
modelName
,
controller
.
signal
))
{
setDownloadProgress
(
progress
);
if
(
progress
.
status
===
"
success
"
)
{
// Update selected model to indicate it's now available locally
if
(
selectedModel
&&
selectedModel
.
model
===
modelName
)
{
setSettings
({
SelectedModel
:
modelName
});
}
// Invalidate models query to refresh the list
await
queryClient
.
invalidateQueries
({
queryKey
:
[
"
models
"
]
});
break
;
}
}
}
finally
{
setAbortController
(
null
);
if
(
chatId
)
{
setDownloadingChatIds
((
prev
)
=>
{
const
newSet
=
new
Set
(
prev
);
newSet
.
delete
(
chatId
);
return
newSet
;
});
}
}
},
onSuccess
:
()
=>
{
setDownloadProgress
(
null
);
if
(
chatId
)
{
setDownloadingChatIds
((
prev
)
=>
{
const
newSet
=
new
Set
(
prev
);
newSet
.
delete
(
chatId
);
return
newSet
;
});
}
},
onError
:
(
error
:
Error
)
=>
{
const
status
=
error
.
name
===
"
AbortError
"
?
"
Download cancelled
"
:
"
Download failed
"
;
setDownloadProgress
({
status
,
done
:
true
});
// Clear error message after delay
const
delay
=
error
.
name
===
"
AbortError
"
?
1500
:
3000
;
setTimeout
(()
=>
{
setDownloadProgress
(
null
);
if
(
chatId
)
{
setDownloadingChatIds
((
prev
)
=>
{
const
newSet
=
new
Set
(
prev
);
newSet
.
delete
(
chatId
);
return
newSet
;
});
}
},
delay
);
},
});
const
cancelDownload
=
()
=>
{
if
(
abortController
)
{
abortController
.
abort
();
setAbortController
(
null
);
if
(
chatId
)
{
setDownloadingChatIds
((
prev
)
=>
{
const
newSet
=
new
Set
(
prev
);
newSet
.
delete
(
chatId
);
return
newSet
;
});
}
}
};
return
{
downloadModel
:
mutation
.
mutate
,
isDownloading
:
mutation
.
isPending
&&
chatId
?
downloadingChatIds
.
has
(
chatId
)
:
false
,
downloadProgress
:
chatId
&&
downloadingChatIds
.
has
(
chatId
)
?
downloadProgress
:
null
,
error
:
mutation
.
error
,
cancelDownload
,
};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment