mirror of
https://github.com/cline/cline.git
synced 2026-10-25 10:26:36 +08:00
feat(desktop): preselect the in-use provider on the BYOK page
This commit is contained in:
@@ -29,12 +29,14 @@ import {
|
||||
setStoredAppIcon,
|
||||
} from "@/lib/app-icon";
|
||||
import { desktopClient } from "@/lib/desktop-client";
|
||||
import { readModelSelectionStorageFromWindow } from "@/lib/model-selection";
|
||||
import { resetOnboarding } from "@/lib/onboarding";
|
||||
import {
|
||||
getProviderAuthKind,
|
||||
isProviderConnected,
|
||||
runProviderOAuthLogin,
|
||||
} from "@/lib/provider-connection";
|
||||
import { normalizeProviderId } from "@/lib/provider-id";
|
||||
import {
|
||||
invalidateProviderCatalogCache,
|
||||
notifyVoiceInputSettingsChanged,
|
||||
@@ -138,6 +140,9 @@ export function SettingsView({
|
||||
const [selectedProviderId, setSelectedProviderId] = useState<string | null>(
|
||||
null,
|
||||
);
|
||||
const [inUseProviderId] = useState(() =>
|
||||
normalizeProviderId(readModelSelectionStorageFromWindow().lastProvider),
|
||||
);
|
||||
const [addingProvider, setAddingProvider] = useState(false);
|
||||
// Bumped by every optimistic provider mutation and catalog load. An
|
||||
// in-flight catalog response is discarded when the generation moved on,
|
||||
@@ -427,9 +432,13 @@ export function SettingsView({
|
||||
);
|
||||
|
||||
// The detail panel is always open: with no explicit selection, default to
|
||||
// the first connected provider (the one in use), then the first provider.
|
||||
// the provider the chat uses, then the first connected one, then the first.
|
||||
const effectiveSelectedProviderId =
|
||||
selectedProviderId ??
|
||||
providers.find(
|
||||
(provider) =>
|
||||
provider.id === inUseProviderId && isProviderConnected(provider),
|
||||
)?.id ??
|
||||
providers.find(isProviderConnected)?.id ??
|
||||
providers[0]?.id ??
|
||||
null;
|
||||
|
||||
Reference in New Issue
Block a user