fix: add import button for OpenCode/OpenClaw empty state and remove auto-import on startup

Previously OpenCode and OpenClaw auto-imported providers from live config
on app startup, which could confuse users. Now they follow the same
pattern as Claude/Codex/Gemini: manual import via the empty state button.
This commit is contained in:
Jason
2026-02-27 11:50:38 +08:00
parent 3bd0a7c02c
commit b2b20dadd7
3 changed files with 21 additions and 29 deletions
+12 -6
View File
@@ -179,7 +179,17 @@ export function ProviderList({
// Import current live config as default provider
const queryClient = useQueryClient();
const importMutation = useMutation({
mutationFn: () => providersApi.importDefault(appId),
mutationFn: async (): Promise<boolean> => {
if (appId === "opencode") {
const count = await providersApi.importOpenCodeFromLive();
return count > 0;
}
if (appId === "openclaw") {
const count = await providersApi.importOpenClawFromLive();
return count > 0;
}
return providersApi.importDefault(appId);
},
onSuccess: (imported) => {
if (imported) {
queryClient.invalidateQueries({ queryKey: ["providers", appId] });
@@ -245,15 +255,11 @@ export function ProviderList({
);
}
// Only show import button for standard apps (not additive-mode apps like OpenCode/OpenClaw)
const showImportButton =
appId === "claude" || appId === "codex" || appId === "gemini";
if (sortedProviders.length === 0) {
return (
<ProviderEmptyState
onCreate={onCreate}
onImport={showImportButton ? () => importMutation.mutate() : undefined}
onImport={() => importMutation.mutate()}
/>
);
}
+8
View File
@@ -110,6 +110,14 @@ export const providersApi = {
async getOpenClawLiveProviderIds(): Promise<string[]> {
return await invoke("get_openclaw_live_provider_ids");
},
/**
* 从 OpenClaw live 配置导入供应商到数据库
* OpenClaw 特有功能:由于累加模式,用户可能已在 openclaw.json 中配置供应商
*/
async importOpenClawFromLive(): Promise<number> {
return await invoke("import_openclaw_providers_from_live");
},
};
// ============================================================================