Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | import { UpdateSettingsRequest } from "@shared/proto/cline/state" import { Mode } from "@shared/storage/types" import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" import { useState } from "react" import { useExtensionState } from "@/context/ExtensionStateContext" import { StateServiceClient } from "@/services/grpc-client" import { TabButton } from "../../mcp/configuration/McpConfigurationView" import ApiOptions from "../ApiOptions" import Section from "../Section" import { syncModeConfigurations } from "../utils/providerUtils" import { useApiConfigurationHandlers } from "../utils/useApiConfigurationHandlers" interface ApiConfigurationSectionProps { renderSectionHeader: (tabId: string) => JSX.Element | null } const ApiConfigurationSection = ({ renderSectionHeader }: ApiConfigurationSectionProps) => { const { planActSeparateModelsSetting, mode, apiConfiguration } = useExtensionState() const [currentTab, setCurrentTab] = useState<Mode>(mode) const { handleFieldsChange } = useApiConfigurationHandlers() return ( <div> {renderSectionHeader("api-config")} <Section> {/* Tabs container */} {planActSeparateModelsSetting ? ( <div className="rounded-md mb-5"> <div className="flex gap-[1px] mb-[10px] -mt-2 border-0 border-b border-solid border-[var(--vscode-panel-border)]"> <TabButton disabled={currentTab === "plan"} isActive={currentTab === "plan"} onClick={() => setCurrentTab("plan")} style={{ opacity: 1, cursor: "pointer", }}> Plan Mode </TabButton> <TabButton disabled={currentTab === "act"} isActive={currentTab === "act"} onClick={() => setCurrentTab("act")} style={{ opacity: 1, cursor: "pointer", }}> Act Mode </TabButton> </div> {/* Content container */} <div className="-mb-3"> <ApiOptions currentMode={currentTab} showModelOptions={true} /> </div> </div> ) : ( <ApiOptions currentMode={mode} showModelOptions={true} /> )} <div className="mb-[5px]"> <VSCodeCheckbox checked={planActSeparateModelsSetting} className="mb-[5px]" onChange={async (e: any) => { const checked = e.target.checked === true try { // If unchecking the toggle, wait a bit for state to update, then sync configurations if (!checked) { await syncModeConfigurations(apiConfiguration, currentTab, handleFieldsChange) } await StateServiceClient.updateSettings( UpdateSettingsRequest.create({ planActSeparateModelsSetting: checked, }), ) } catch (error) { console.error("Failed to update separate models setting:", error) } }}> Use different models for Plan and Act modes </VSCodeCheckbox> <p className="text-xs mt-[5px] text-[var(--vscode-descriptionForeground)]"> Switching between Plan and Act mode will persist the API and model used in the previous mode. This may be helpful e.g. when using a strong reasoning model to architect a plan for a cheaper coding model to act on. </p> </div> </Section> </div> ) } export default ApiConfigurationSection |