From ca984609caa34dd611d431ee4700b760f4ea3e24 Mon Sep 17 00:00:00 2001 From: celestial-vault <58194240+celestial-vault@users.noreply.github.com> Date: Thu, 26 Jun 2025 21:41:35 -0700 Subject: [PATCH] refactor out cline (#4512) --- .../src/components/settings/ApiOptions.tsx | 67 ++------------- .../settings/providers/ClineProvider.tsx | 86 +++++++++++++++++++ 2 files changed, 94 insertions(+), 59 deletions(-) create mode 100644 webview-ui/src/components/settings/providers/ClineProvider.tsx diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index bc029485..dbee31de 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -18,13 +18,13 @@ import { Fragment, memo, useCallback, useEffect, useMemo, useState } from "react import { useInterval } from "react-use" import styled from "styled-components" import * as vscodemodels from "vscode" -import { ClineAccountInfoCard } from "./ClineAccountInfoCard" import OllamaModelPicker from "./OllamaModelPicker" import OpenRouterModelPicker, { ModelDescriptionMarkdown, OPENROUTER_MODEL_PICKER_Z_INDEX } from "./OpenRouterModelPicker" import ThinkingBudgetSlider from "./ThinkingBudgetSlider" import { formatPrice } from "./utils/pricingUtils" import { normalizeApiConfiguration } from "./utils/providerUtils" +import { ClineProvider } from "./providers/ClineProvider" import { OpenRouterProvider } from "./providers/OpenRouterProvider" import { MistralProvider } from "./providers/MistralProvider" import { DeepSeekProvider } from "./providers/DeepSeekProvider" @@ -95,7 +95,6 @@ const ApiOptions = ({ const [vsCodeLmModels, setVsCodeLmModels] = useState([]) const [modelConfigurationSelected, setModelConfigurationSelected] = useState(false) const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false) - const [providerSortingSelected, setProviderSortingSelected] = useState(!!apiConfiguration?.openRouterProviderSorting) const handleInputChange = (field: keyof ApiConfiguration) => (event: any) => { const newValue = event.target.value @@ -259,10 +258,13 @@ const ApiOptions = ({ - {selectedProvider === "cline" && ( -
- -
+ {apiConfiguration && selectedProvider === "cline" && ( + )} {apiConfiguration && selectedProvider === "asksage" && ( @@ -849,57 +851,6 @@ const ApiOptions = ({

)} - {selectedProvider === "cline" && showModelOptions && ( - <> - { - const isChecked = e.target.checked === true - setProviderSortingSelected(isChecked) - if (!isChecked) { - setApiConfiguration({ - ...apiConfiguration, - openRouterProviderSorting: "", - }) - } - }}> - Sort underlying provider routing - - - {providerSortingSelected && ( -
- - { - setApiConfiguration({ - ...apiConfiguration, - openRouterProviderSorting: e.target.value, - }) - }}> - Default - Price - Throughput - Latency - - -

- {!apiConfiguration?.openRouterProviderSorting && - "Default behavior is to load balance requests across providers (like AWS, Google Vertex, Anthropic), prioritizing price while considering provider uptime"} - {apiConfiguration?.openRouterProviderSorting === "price" && - "Sort providers by price, prioritizing the lowest cost provider"} - {apiConfiguration?.openRouterProviderSorting === "throughput" && - "Sort providers by throughput, prioritizing the provider with the highest throughput (may increase cost)"} - {apiConfiguration?.openRouterProviderSorting === "latency" && - "Sort providers by response time, prioritizing the provider with the lowest latency"} -

-
- )} - - )} - {selectedProvider !== "openrouter" && selectedProvider !== "cline" && selectedProvider !== "anthropic" && @@ -943,8 +894,6 @@ const ApiOptions = ({ )} - {selectedProvider === "cline" && showModelOptions && } - {modelIdErrorMessage && (

(event: any) => void + showModelOptions: boolean + isPopup?: boolean +} + +/** + * The Cline provider configuration component + */ +export const ClineProvider = ({ apiConfiguration, handleInputChange, showModelOptions, isPopup }: ClineProviderProps) => { + const [providerSortingSelected, setProviderSortingSelected] = useState(!!apiConfiguration?.openRouterProviderSorting) + + // Create a wrapper for handling field changes more directly + const handleFieldChange = (field: keyof ApiConfiguration) => (value: any) => { + handleInputChange(field)({ target: { value } }) + } + + return ( +

+ {/* Cline Account Info Card */} +
+ +
+ + {showModelOptions && ( + <> + {/* Provider Sorting Options */} + { + const isChecked = e.target.checked === true + setProviderSortingSelected(isChecked) + if (!isChecked) { + handleFieldChange("openRouterProviderSorting")("") + } + }}> + Sort underlying provider routing + + + {providerSortingSelected && ( +
+ + { + handleFieldChange("openRouterProviderSorting")(e.target.value) + }}> + Default + Price + Throughput + Latency + + +

+ {!apiConfiguration?.openRouterProviderSorting && + "Default behavior is to load balance requests across providers (like AWS, Google Vertex, Anthropic), prioritizing price while considering provider uptime"} + {apiConfiguration?.openRouterProviderSorting === "price" && + "Sort providers by price, prioritizing the lowest cost provider"} + {apiConfiguration?.openRouterProviderSorting === "throughput" && + "Sort providers by throughput, prioritizing the provider with the highest throughput (may increase cost)"} + {apiConfiguration?.openRouterProviderSorting === "latency" && + "Sort providers by response time, prioritizing the provider with the lowest latency"} +

+
+ )} + + {/* OpenRouter Model Picker */} + + + )} +
+ ) +}