Skip to content

Commit ae93c0d

Browse files
committed
fix: load configured models before background refresh
1 parent 7dd0586 commit ae93c0d

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

‎apps/kimi-code/src/App.tsx‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,16 +1961,12 @@ export default function App() {
19611961
};
19621962

19631963
const refreshModels = async (): Promise<void> => {
1964-
setModelsBusy(true);
19651964
try {
19661965
const nextModels = await invoke<Model[]>("refresh_models");
19671966
setModels(nextModels);
19681967
if (nextModels.length === 0) showNotice("当前账号没有可用模型");
19691968
} catch {
1970-
// 刷新失败时回退到配置中已缓存的模型列表。
1971-
await loadModels();
1972-
} finally {
1973-
setModelsBusy(false);
1969+
// Keep using the configured model list when the background refresh fails.
19741970
}
19751971
};
19761972

@@ -2024,15 +2020,18 @@ export default function App() {
20242020
.catch(() => {
20252021
// Vite's browser preview has no Tauri bridge.
20262022
});
2027-
invoke<AuthStatus>("auth_status")
2028-
.then((status) => {
2029-
if (!active) return;
2030-
setAuth(status);
2031-
if (status.loggedIn) void refreshModels();
2032-
})
2033-
.catch(() => {
2034-
// Vite's browser preview has no Tauri bridge; the actual desktop app does.
2035-
});
2023+
void loadModels().then(() => {
2024+
if (!active) return;
2025+
void invoke<AuthStatus>("auth_status")
2026+
.then((status) => {
2027+
if (!active) return;
2028+
setAuth(status);
2029+
if (status.loggedIn) void refreshModels();
2030+
})
2031+
.catch(() => {
2032+
// Vite's browser preview has no Tauri bridge; the actual desktop app does.
2033+
});
2034+
});
20362035
return () => {
20372036
active = false;
20382037
};

‎crates/agent-core-v2/src/app/desktop_client.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ impl KimiCodeDesktopClient {
428428
}
429429

430430
pub async fn list_models(&self) -> Result<Vec<DesktopModel>, String> {
431+
self.app
432+
.get(CONFIG_SERVICE_ID)
433+
.map_err(|error| error.to_string())?
434+
.ready()
435+
.await
436+
.map_err(|error| error.to_string())?;
431437
self.configured_desktop_models().await
432438
}
433439

0 commit comments

Comments
 (0)