Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat(chat): live model-load progress for llamacpp router

Akarshan Biswas8b21ace7db99
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 0321810ec..8f41d3654 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -6749,6 +6749,7 @@ version = "0.8.3"
dependencies = [
"base64 0.22.1",
"byteorder",
+ "futures-util",
"hmac",
"jan-utils",
"lddtree",
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.lock b/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.lock
index 98d8f8317..070239019 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.lock
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.lock
@@ -3418,6 +3418,7 @@ version = "0.8.3"
dependencies = [
"base64 0.22.1",
"byteorder",
+ "futures-util",
"hmac",
"jan-utils",
"lddtree",
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml b/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
index 69c68344c..d07b50954 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
@@ -26,6 +26,7 @@ thiserror = "2.0.12"
tokio = { version = "1", features = ["full"] }
tauri-plugin-hardware = { path = "../tauri-plugin-hardware" }
serde_json = "1.0.149"
+futures-util = "0.3"
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
reqwest = { version = "0.12", features = ["json", "blocking", "stream", "native-tls"] }
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/src/commands.rs b/src-tauri/plugins/tauri-plugin-llamacpp/src/commands.rs
index 6e6b463d7..b8d3ed534 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/src/commands.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/src/commands.rs
@@ -39,7 +39,110 @@ async fn http_client() -> reqwest::Client {
.unwrap_or_else(|_| reqwest::Client::new())
}
-async fn post_load(port: u16, api_key: &str, model_id: &str) -> ServerResult<()> {
+/// Payload for the `llamacpp-model-load-progress` event, mirrored from the
+/// router's `/models/sse` `status_change` events (`progress.value` is 0.0-1.0).
+#[derive(serde::Serialize, Clone)]
+pub struct LoadProgressPayload {
+ pub model: String,
+ pub stage: Option<String>,
+ pub value: f64,
+}
+
+/// Parses one SSE "event block" (text up to and including a `\n\n`
+/// separator) and returns a progress payload if it's a `status_change` event
+/// for `model_id` carrying a non-null `progress` field. Returns `None` for
+/// any other event, a different model, or malformed input - callers should
+/// simply skip the block.
+fn parse_load_progress_event(block: &str, model_id: &str) -> Option<LoadProgressPayload> {
+ for line in block.lines() {
+ let data = line
+ .strip_prefix("data: ")
+ .or_else(|| line.strip_prefix("data:"))?;
+ let json: serde_json::Value = serde_json::from_str(data).ok()?;
+ if json.get("model").and_then(|v| v.as_str()) != Some(model_id) {
+ continue;
+ }
+ if json.get("event").and_then(|v| v.as_str()) != Some("status_change") {
+ continue;
+ }
+ let progress = json.get("data").and_then(|d| d.get("progress"))?;
+ if progress.is_null() {
+ continue;
+ }
+ let value = progress.get("value").and_then(|v| v.as_f64()).unwrap_or(0.0);
+ let stage = progress
+ .get("current")
+ .and_then(|v| v.as_str())
+ .map(|s| s.to_string());
+ return Some(LoadProgressPayload {
+ model: model_id.to_string(),
+ stage,
+ value,
+ });
+ }
+ None
+}
+
+/// Subscribes to the router's `/models/sse` feed and re-emits `progress`
+/// updates for `model_id` as Tauri events, until the connection drops or the
+/// task is aborted by the caller once loading finishes.
+///
+/// `/models/sse` was introduced upstream in build b9747 (server: real-time
+/// model load progress tracking, #24828); this plugin doesn't track backend
+/// build numbers, so rather than gating ahead of time we just check the
+/// response here. Older backends 404 (or otherwise fail) and we return
+/// immediately without emitting anything - the UI already has a workaround,
+/// falling back to its plain "Loading model..." spinner (`loadingModel`,
+/// entirely unaffected by this listener) in `PromptProgress.tsx`.
+fn spawn_load_progress_listener<R: Runtime>(
+ app_handle: tauri::AppHandle<R>,
+ port: u16,
+ api_key: String,
+ model_id: String,
+) -> tokio::task::JoinHandle<()> {
+ tokio::spawn(async move {
+ use futures_util::StreamExt;
+
+ let client = http_client().await;
+ let url = format!("http://127.0.0.1:{}/models/sse", port);
+ let resp = match client.get(&url).bearer_auth(&api_key).send().await {
+ Ok(r) => r,
+ Err(e) => {
+ log::debug!("model load progress: failed to connect to /models/sse: {}", e);
+ return;
+ }
+ };
+ if !resp.status().is_success() {
+ log::debug!(
+ "model load progress unavailable on this backend (/models/sse returned {}); \
+ falling back to the plain loading indicator",
+ resp.status()
+ );
+ return;
+ }
+
+ let mut stream = resp.bytes_stream();
+ let mut buf = String::new();
+ while let Some(chunk) = stream.next().await {
+ let Ok(bytes) = chunk else { break };
+ buf.push_str(&String::from_utf8_lossy(&bytes));
+
+ while let Some(pos) = buf.find("\n\n") {
+ let event_block: String = buf.drain(..pos + 2).collect();
+ if let Some(payload) = parse_load_progress_event(&event_block, &model_id) {
+ let _ = app_handle.emit("llamacpp-model-load-progress", payload);
+ }
+ }
+ }
+ })
+}
+
+async fn post_load<R: Runtime>(
+ app_handle: &tauri::AppHandle<R>,
+ port: u16,
+ api_key: &str,
+ model_id: &str,
+) -> ServerResult<()> {
let client = http_client().await;
let url = format!("http://127.0.0.1:{}/models/load", port);
let resp = client
@@ -67,9 +170,18 @@ async fn post_load(port: u16, api_key: &str, model_id: &str) -> ServerResult<()>
}
}
+ let progress_task = spawn_load_progress_listener(
+ app_handle.clone(),
+ port,
+ api_key.to_string(),
+ model_id.to_string(),
+ );
+
// /models/load returns success once loading is *initiated*; poll /models
// until the entry transitions from "loading" to "loaded" (or fails).
- wait_until_loaded(port, api_key, model_id, Duration::from_secs(600)).await
+ let result = wait_until_loaded(port, api_key, model_id, Duration::from_secs(600)).await;
+ progress_task.abort();
+ result
}
async fn wait_until_loaded(
@@ -336,7 +448,7 @@ pub async fn load_llama_model<R: Runtime>(
let (port, api_key, pid) = router_endpoint(&app_handle)
.await
.map_err(ServerError::InvalidArgument)?;
- post_load(port, &api_key, &model_id).await?;
+ post_load(&app_handle, port, &api_key, &model_id).await?;
Ok(SessionInfo {
pid: pid as i32,
port: port as i32,
@@ -386,7 +498,7 @@ pub async fn ensure_session_ready<R: Runtime>(
is_embedding: bool,
) -> Result<SessionInfo, String> {
let (port, api_key, pid) = router_endpoint(&app_handle).await?;
- post_load(port, &api_key, &model_id)
+ post_load(&app_handle, port, &api_key, &model_id)
.await
.map_err(|e| e.to_string())?;
Ok(SessionInfo {
@@ -694,3 +806,100 @@ pub async fn force_kill_router_tree<R: Runtime>(
}
Ok(())
}
+
+#[cfg(test)]
+mod load_progress_tests {
+ use super::parse_load_progress_event;
+
+ fn sse_block(model: &str, event: &str, data: serde_json::Value) -> String {
+ let payload = serde_json::json!({ "model": model, "event": event, "data": data });
+ format!("data: {}\n\n", payload)
+ }
+
+ #[test]
+ fn parses_a_matching_progress_event() {
+ let block = sse_block(
+ "model-1",
+ "status_change",
+ serde_json::json!({
+ "status": "loading",
+ "progress": { "stages": ["text_model"], "current": "text_model", "value": 0.42 }
+ }),
+ );
+ let payload = parse_load_progress_event(&block, "model-1").expect("should parse");
+ assert_eq!(payload.model, "model-1");
+ assert_eq!(payload.stage.as_deref(), Some("text_model"));
+ assert!((payload.value - 0.42).abs() < f64::EPSILON);
+ }
+
+ #[test]
+ fn ignores_events_for_a_different_model() {
+ let block = sse_block(
+ "other-model",
+ "status_change",
+ serde_json::json!({ "progress": { "current": "text_model", "value": 0.5 } }),
+ );
+ assert!(parse_load_progress_event(&block, "model-1").is_none());
+ }
+
+ #[test]
+ fn ignores_non_status_change_events() {
+ let block = sse_block(
+ "model-1",
+ "download_progress",
+ serde_json::json!({ "done": 10, "total": 100 }),
+ );
+ assert!(parse_load_progress_event(&block, "model-1").is_none());
+ }
+
+ #[test]
+ fn ignores_status_change_without_progress() {
+ let block = sse_block("model-1", "status_change", serde_json::json!({ "status": "loaded" }));
+ assert!(parse_load_progress_event(&block, "model-1").is_none());
+ }
+
+ #[test]
+ fn ignores_null_progress() {
+ let block = sse_block(
+ "model-1",
+ "status_change",
+ serde_json::json!({ "status": "loaded", "progress": null }),
+ );
+ assert!(parse_load_progress_event(&block, "model-1").is_none());
+ }
+
+ #[test]
+ fn ignores_malformed_json() {
+ let block = "data: not json at all\n\n".to_string();
+ assert!(parse_load_progress_event(&block, "model-1").is_none());
+ }
+
+ #[test]
+ fn ignores_blocks_with_no_data_line() {
+ let block = "event: ping\n\n".to_string();
+ assert!(parse_load_progress_event(&block, "model-1").is_none());
+ }
+
+ #[test]
+ fn defaults_missing_value_to_zero() {
+ let block = sse_block(
+ "model-1",
+ "status_change",
+ serde_json::json!({ "progress": { "current": "text_model" } }),
+ );
+ let payload = parse_load_progress_event(&block, "model-1").expect("should parse");
+ assert_eq!(payload.value, 0.0);
+ assert_eq!(payload.stage.as_deref(), Some("text_model"));
+ }
+
+ #[test]
+ fn defaults_missing_stage_to_none() {
+ let block = sse_block(
+ "model-1",
+ "status_change",
+ serde_json::json!({ "progress": { "value": 0.9 } }),
+ );
+ let payload = parse_load_progress_event(&block, "model-1").expect("should parse");
+ assert!(payload.stage.is_none());
+ }
+}
diff --git a/web-app/src/components/PromptProgress.tsx b/web-app/src/components/PromptProgress.tsx
index 02ffdd86d..295325a1c 100644
--- a/web-app/src/components/PromptProgress.tsx
+++ b/web-app/src/components/PromptProgress.tsx
@@ -14,6 +14,10 @@ export function PromptProgress({ hideIdle = false }: { hideIdle?: boolean }) {
(threadId ? state.loadingModels[threadId] : undefined) ??
state.loadingModel
)
+ const loadProgress = useAppState((state) =>
+ (threadId ? state.modelLoadProgressByThread[threadId] : undefined) ??
+ state.modelLoadProgress
+ )
const percentage =
promptProgress && promptProgress.total > 0
@@ -32,8 +36,13 @@ export function PromptProgress({ hideIdle = false }: { hideIdle?: boolean }) {
return null
}
+ const loadPercentage =
+ loadingModel && loadProgress ? Math.round(loadProgress.value * 100) : undefined
+
const label = loadingModel
- ? 'Loading model…'
+ ? loadPercentage !== undefined
+ ? `Loading model: ${loadPercentage}%`
+ : 'Loading model…'
: showReading
? `Reading: ${percentage}%`
: 'Working…'
@@ -50,6 +59,9 @@ export function PromptProgress({ hideIdle = false }: { hideIdle?: boolean }) {
{showReading && !loadingModel && (
<Progress value={percentage} className="h-1 bg-secondary/60" />
)}
+ {loadingModel && loadPercentage !== undefined && (
+ <Progress value={loadPercentage} className="h-1 bg-secondary/60" />
+ )}
{detail && (
<div className="text-xs text-muted-foreground tabular-nums">
{detail}
diff --git a/web-app/src/components/__tests__/PromptProgress.test.tsx b/web-app/src/components/__tests__/PromptProgress.test.tsx
index d103e05c9..0e9e8c0e4 100644
--- a/web-app/src/components/__tests__/PromptProgress.test.tsx
+++ b/web-app/src/components/__tests__/PromptProgress.test.tsx
@@ -57,6 +57,34 @@ describe('PromptProgress', () => {
).toBeInTheDocument()
})
+ it('should show load percentage while loading model', () => {
+ mockUseAppState.mockImplementation((selector) =>
+ selector({
+ promptProgress: undefined,
+ loadingModel: true,
+ modelLoadProgress: { modelId: 'model-1', value: 0.42 },
+ })
+ )
+
+ render(<PromptProgress />)
+
+ expect(screen.getByText('Loading model: 42%')).toBeInTheDocument()
+ })
+
+ it('should fall back to generic loading label when no progress event has arrived yet', () => {
+ mockUseAppState.mockImplementation((selector) =>
+ selector({
+ promptProgress: undefined,
+ loadingModel: true,
+ modelLoadProgress: undefined,
+ })
+ )
+
+ render(<PromptProgress />)
+
+ expect(screen.getByText('Loading model…')).toBeInTheDocument()
+ })
+
it('should handle zero total gracefully', () => {
const mockProgress = {
cache: 0,
diff --git a/web-app/src/containers/dialogs/LlamacppOomListener.tsx b/web-app/src/containers/dialogs/LlamacppOomListener.tsx
index 7fe136f2b..b9ddcc232 100644
--- a/web-app/src/containers/dialogs/LlamacppOomListener.tsx
+++ b/web-app/src/containers/dialogs/LlamacppOomListener.tsx
@@ -9,6 +9,12 @@ import {
stampErrorOnLastUserMessage,
} from './llamacppRouterError'
+type LoadProgressPayload = {
+ model: string
+ stage?: string
+ value: number
+}
+
export default function LlamacppOomListener() {
useEffect(() => {
if (!isPlatformTauri()) return
@@ -35,9 +41,25 @@ export default function LlamacppOomListener() {
console.warn('listen llamacpp-router-backend-error failed:', e)
return () => {}
})
+ const unlistenLoadProgress = listen<LoadProgressPayload>(
+ 'llamacpp-model-load-progress',
+ (event) => {
+ const { model, stage, value } = event.payload
+ const progress = { modelId: model, stage, value }
+ useAppState.getState().updateModelLoadProgress(progress)
+ const threadId = useAppState.getState().currentStreamThreadId
+ if (threadId) {
+ useAppState.getState().updateThreadModelLoadProgress(threadId, progress)
+ }
+ }
+ ).catch((e) => {
+ console.warn('listen llamacpp-model-load-progress failed:', e)
+ return () => {}
+ })
return () => {
void unlistenOom.then((fn) => fn?.())
void unlistenBackend.then((fn) => fn?.())
+ void unlistenLoadProgress.then((fn) => fn?.())
}
}, [])
diff --git a/web-app/src/containers/dialogs/__tests__/LlamacppOomListener.test.tsx b/web-app/src/containers/dialogs/__tests__/LlamacppOomListener.test.tsx
new file mode 100644
index 000000000..c77bc64f9
--- /dev/null
+++ b/web-app/src/containers/dialogs/__tests__/LlamacppOomListener.test.tsx
@@ -0,0 +1,75 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+import { render } from '@testing-library/react'
+import { act } from '@testing-library/react'
+import LlamacppOomListener from '../LlamacppOomListener'
+import { useAppState } from '@/hooks/useAppState'
+
+let loadProgressHandler: ((event: { payload: unknown }) => void) | undefined
+
+vi.mock('@tauri-apps/api/event', () => ({
+ listen: vi.fn((eventName: string, handler: (event: { payload: unknown }) => void) => {
+ if (eventName === 'llamacpp-model-load-progress') {
+ loadProgressHandler = handler
+ }
+ return Promise.resolve(() => {})
+ }),
+}))
+
+vi.mock('@/lib/platform/utils', () => ({
+ isPlatformTauri: () => true,
+}))
+
+describe('LlamacppOomListener - model load progress', () => {
+ beforeEach(() => {
+ loadProgressHandler = undefined
+ act(() => {
+ useAppState.setState({
+ modelLoadProgress: undefined,
+ modelLoadProgressByThread: {},
+ currentStreamThreadId: undefined,
+ })
+ })
+ })
+
+ it('updates global model load progress on event', async () => {
+ render(<LlamacppOomListener />)
+ await act(async () => {
+ await Promise.resolve()
+ })
+
+ expect(loadProgressHandler).toBeDefined()
+ act(() => {
+ loadProgressHandler?.({
+ payload: { model: 'model-1', stage: 'text_model', value: 0.75 },
+ })
+ })
+
+ expect(useAppState.getState().modelLoadProgress).toEqual({
+ modelId: 'model-1',
+ stage: 'text_model',
+ value: 0.75,
+ })
+ })
+
+ it('also updates per-thread progress when a stream thread is active', async () => {
+ act(() => {
+ useAppState.setState({ currentStreamThreadId: 'thread-1' })
+ })
+ render(<LlamacppOomListener />)
+ await act(async () => {
+ await Promise.resolve()
+ })
+
+ act(() => {
+ loadProgressHandler?.({
+ payload: { model: 'model-1', value: 0.3 },
+ })
+ })
+
+ expect(useAppState.getState().modelLoadProgressByThread['thread-1']).toEqual({
+ modelId: 'model-1',
+ stage: undefined,
+ value: 0.3,
+ })
+ })
+})
diff --git a/web-app/src/hooks/__tests__/useAppState.coverage.test.ts b/web-app/src/hooks/__tests__/useAppState.coverage.test.ts
index 979ae9740..c706b740f 100644
--- a/web-app/src/hooks/__tests__/useAppState.coverage.test.ts
+++ b/web-app/src/hooks/__tests__/useAppState.coverage.test.ts
@@ -171,6 +171,38 @@ describe('useAppState - coverage', () => {
expect(result.current.liveTokenStatsByThread['t1']).toBeUndefined()
})
+ it('should update model load progress globally and per-thread', () => {
+ const { result } = renderHook(() => useAppState())
+ const progress = { modelId: 'model-1', value: 0.42, stage: 'text_model' }
+
+ act(() => {
+ result.current.updateModelLoadProgress(progress)
+ result.current.updateThreadModelLoadProgress('t1', progress)
+ })
+ expect(result.current.modelLoadProgress).toEqual(progress)
+ expect(result.current.modelLoadProgressByThread['t1']).toEqual(progress)
+
+ act(() => {
+ result.current.updateModelLoadProgress(undefined)
+ result.current.updateThreadModelLoadProgress('t1', undefined)
+ })
+ expect(result.current.modelLoadProgress).toBeUndefined()
+ expect(result.current.modelLoadProgressByThread['t1']).toBeUndefined()
+ })
+
+ it('should clear modelLoadProgressByThread on clearThreadState', () => {
+ const { result } = renderHook(() => useAppState())
+
+ act(() => {
+ result.current.updateThreadModelLoadProgress('t1', {
+ modelId: 'model-1',
+ value: 0.5,
+ })
+ result.current.clearThreadState('t1')
+ })
+ expect(result.current.modelLoadProgressByThread['t1']).toBeUndefined()
+ })
+
it('should set active models', () => {
const { result } = renderHook(() => useAppState())
diff --git a/web-app/src/hooks/useAppState.ts b/web-app/src/hooks/useAppState.ts
index 2e9a7d6b8..13c5272ca 100644
--- a/web-app/src/hooks/useAppState.ts
+++ b/web-app/src/hooks/useAppState.ts
@@ -16,6 +16,12 @@ export type LiveTokenStats = {
promptPerSecond: number | null
}
+export type ModelLoadProgress = {
+ modelId: string
+ value: number
+ stage?: string
+}
+
type AppErrorMessage = {
message?: string
title?: string
@@ -34,6 +40,7 @@ type AppState = {
errorMessage?: AppErrorMessage
promptProgress?: PromptProgress
liveTokenStats?: LiveTokenStats
+ modelLoadProgress?: ModelLoadProgress
activeModels: string[]
cancelToolCall?: () => void
@@ -41,6 +48,7 @@ type AppState = {
loadingModels: Record<string, boolean>
promptProgresses: Record<string, PromptProgress>
liveTokenStatsByThread: Record<string, LiveTokenStats>
+ modelLoadProgressByThread: Record<string, ModelLoadProgress>
cancelToolCalls: Record<string, () => void>
errorMessages: Record<string, AppErrorMessage>
busyThreads: Record<string, boolean>
@@ -65,6 +73,7 @@ type AppState = {
setErrorMessage: (error: AppErrorMessage | undefined) => void
updatePromptProgress: (progress: PromptProgress | undefined) => void
updateLiveTokenStats: (stats: LiveTokenStats | undefined) => void
+ updateModelLoadProgress: (progress: ModelLoadProgress | undefined) => void
setActiveModels: (models: string[]) => void
updateThreadStreamingContent: (
@@ -80,6 +89,10 @@ type AppState = {
threadId: string,
stats: LiveTokenStats | undefined
) => void
+ updateThreadModelLoadProgress: (
+ threadId: string,
+ progress: ModelLoadProgress | undefined
+ ) => void
setThreadCancelToolCall: (
threadId: string,
cancel: (() => void) | undefined
@@ -109,6 +122,7 @@ export const useAppState = create<AppState>()((set) => ({
loadingModels: {},
promptProgresses: {},
liveTokenStatsByThread: {},
+ modelLoadProgressByThread: {},
cancelToolCalls: {},
errorMessages: {},
busyThreads: {},
@@ -195,6 +209,11 @@ export const useAppState = create<AppState>()((set) => ({
liveTokenStats: stats,
}))
},
+ updateModelLoadProgress: (progress) => {
+ set(() => ({
+ modelLoadProgress: progress,
+ }))
+ },
setActiveModels: (models: string[]) => {
set(() => ({
activeModels: models,
@@ -235,6 +254,13 @@ export const useAppState = create<AppState>()((set) => ({
else delete next[threadId]
return { liveTokenStatsByThread: next }
}),
+ updateThreadModelLoadProgress: (threadId, progress) =>
+ set((state) => {
+ const next = { ...state.modelLoadProgressByThread }
+ if (progress) next[threadId] = progress
+ else delete next[threadId]
+ return { modelLoadProgressByThread: next }
+ }),
setThreadCancelToolCall: (threadId, cancel) =>
set((state) => {
const next = { ...state.cancelToolCalls }
@@ -255,6 +281,7 @@ export const useAppState = create<AppState>()((set) => ({
const loadingModels = { ...state.loadingModels }
const promptProgresses = { ...state.promptProgresses }
const liveTokenStatsByThread = { ...state.liveTokenStatsByThread }
+ const modelLoadProgressByThread = { ...state.modelLoadProgressByThread }
const cancelToolCalls = { ...state.cancelToolCalls }
const errorMessages = { ...state.errorMessages }
const busyThreads = { ...state.busyThreads }
@@ -263,6 +290,7 @@ export const useAppState = create<AppState>()((set) => ({
delete loadingModels[threadId]
delete promptProgresses[threadId]
delete liveTokenStatsByThread[threadId]
+ delete modelLoadProgressByThread[threadId]
delete cancelToolCalls[threadId]
delete errorMessages[threadId]
delete busyThreads[threadId]
@@ -272,6 +300,7 @@ export const useAppState = create<AppState>()((set) => ({
loadingModels,
promptProgresses,
liveTokenStatsByThread,
+ modelLoadProgressByThread,
cancelToolCalls,
errorMessages,
busyThreads,
diff --git a/web-app/src/lib/custom-chat-transport.ts b/web-app/src/lib/custom-chat-transport.ts
index 4541bbce1..daa036761 100644
--- a/web-app/src/lib/custom-chat-transport.ts
+++ b/web-app/src/lib/custom-chat-transport.ts
@@ -895,6 +895,8 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {
if (!loaded.includes(modelId)) {
useAppState.getState().updateLoadingModel(true)
useAppState.getState().updateThreadLoadingModel(threadId, true)
+ useAppState.getState().updateModelLoadProgress(undefined)
+ useAppState.getState().updateThreadModelLoadProgress(threadId, undefined)
}
} catch {
// Ignore probe failures; the router will still load on demand
@@ -923,9 +925,13 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {
)
useAppState.getState().updateLoadingModel(false)
useAppState.getState().updateThreadLoadingModel(threadId, false)
+ useAppState.getState().updateModelLoadProgress(undefined)
+ useAppState.getState().updateThreadModelLoadProgress(threadId, undefined)
} catch (error) {
useAppState.getState().updateLoadingModel(false)
useAppState.getState().updateThreadLoadingModel(threadId, false)
+ useAppState.getState().updateModelLoadProgress(undefined)
+ useAppState.getState().updateThreadModelLoadProgress(threadId, undefined)
console.error('Failed to create model:', error)
throw new Error(
`Failed to create model: ${error instanceof Error ? error.message : JSON.stringify(error)}`