From 0957e860465e5ce733b236a441614551dd095ed2 Mon Sep 17 00:00:00 2001 From: celestial-vault <58194240+celestial-vault@users.noreply.github.com> Date: Sun, 12 Oct 2025 22:33:51 -0700 Subject: [PATCH] remote config disable ui (#6794) * pass remote config state to frontend and disable corresponding UI components * move state-keys to shared folder * fix field potentially undefined type error * move workspace types to shared folder * fix url validation runtime error * add lock and tooltip to api provider dropdown and remove filtering --- src/core/controller/index.ts | 3 +- .../controller/state/updateSettingsCli.ts | 2 +- src/core/controller/task/newTask.ts | 2 +- src/core/mentions/index.ts | 3 +- src/core/storage/StateManager.ts | 39 ++- src/core/storage/disk.ts | 2 +- src/core/storage/remote-config/fetch.ts | 6 +- src/core/storage/remote-config/utils.ts | 4 +- src/core/storage/utils/state-helpers.ts | 2 +- src/core/workspace/WorkspaceResolver.ts | 2 +- src/core/workspace/WorkspaceRootManager.ts | 2 +- .../__tests__/WorkspacePathAdapter.test.ts | 2 +- .../__tests__/WorkspaceResolver.test.ts | 2 +- src/core/workspace/__tests__/setup.test.ts | 4 +- src/core/workspace/detection.ts | 2 +- src/core/workspace/index.ts | 2 - src/core/workspace/setup.ts | 2 +- src/services/search/file-search.ts | 3 +- src/shared/ExtensionMessage.ts | 4 +- .../multi-root/types.ts} | 0 src/{core => shared}/storage/state-keys.ts | 20 +- .../src/components/settings/ApiOptions.tsx | 27 +- .../settings/common/BaseUrlField.tsx | 16 +- .../settings/providers/BedrockProvider.tsx | 299 +++++++++++++----- .../settings/providers/OpenAICompatible.tsx | 114 +++++-- .../sections/FeatureSettingsSection.tsx | 70 +++- .../sections/GeneralSettingsSection.tsx | 40 ++- .../src/context/ExtensionStateContext.tsx | 1 + 28 files changed, 480 insertions(+), 195 deletions(-) rename src/{core/workspace/WorkspaceRoot.ts => shared/multi-root/types.ts} (100%) rename src/{core => shared}/storage/state-keys.ts (93%) diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index 88ef7f35..a47f6cd8 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -12,6 +12,7 @@ import { ChatContent } from "@shared/ChatContent" import { ExtensionState, Platform } from "@shared/ExtensionMessage" import { HistoryItem } from "@shared/HistoryItem" import { McpMarketplaceCatalog } from "@shared/mcp" +import { Settings } from "@shared/storage/state-keys" import { Mode } from "@shared/storage/types" import { TelemetrySetting } from "@shared/TelemetrySetting" import { UserInfo } from "@shared/UserInfo" @@ -42,7 +43,6 @@ import { writeMcpMarketplaceCatalogToCache, } from "../storage/disk" import { PersistenceErrorEvent, StateManager } from "../storage/StateManager" -import { Settings } from "../storage/state-keys" import { Task } from "../task" import { sendMcpMarketplaceCatalogEvent } from "./mcp/subscribeToMcpMarketplaceCatalog" import { appendClineStealthModels } from "./models/refreshOpenRouterModels" @@ -818,6 +818,7 @@ export class Controller { }, lastDismissedInfoBannerVersion, lastDismissedModelBannerVersion, + remoteConfigSettings: this.stateManager.getRemoteConfigSettings(), } } diff --git a/src/core/controller/state/updateSettingsCli.ts b/src/core/controller/state/updateSettingsCli.ts index 880e742c..57297ce1 100644 --- a/src/core/controller/state/updateSettingsCli.ts +++ b/src/core/controller/state/updateSettingsCli.ts @@ -7,8 +7,8 @@ import { UpdateSettingsRequestCli, } from "@shared/proto/cline/state" import { convertProtoToApiProvider } from "@shared/proto-conversions/models/api-configuration-conversion" +import { Settings } from "@shared/storage/state-keys" import { TelemetrySetting } from "@shared/TelemetrySetting" -import { Settings } from "@/core/storage/state-keys" import { HostProvider } from "@/hosts/host-provider" import { TerminalInfo } from "@/integrations/terminal/TerminalRegistry" import { ShowMessageType } from "@/shared/proto/host/window" diff --git a/src/core/controller/task/newTask.ts b/src/core/controller/task/newTask.ts index 452163e5..68f8aeae 100644 --- a/src/core/controller/task/newTask.ts +++ b/src/core/controller/task/newTask.ts @@ -1,7 +1,7 @@ import { String } from "@shared/proto/cline/common" import { PlanActMode, OpenaiReasoningEffort as ProtoOpenaiReasoningEffort } from "@shared/proto/cline/state" import { NewTaskRequest } from "@shared/proto/cline/task" -import { Settings } from "@/core/storage/state-keys" +import { Settings } from "@shared/storage/state-keys" import { convertProtoToApiProvider } from "@/shared/proto-conversions/models/api-configuration-conversion" import { DEFAULT_BROWSER_SETTINGS } from "../../../shared/BrowserSettings" import { convertProtoToAutoApprovalSettings } from "../../../shared/proto-conversions/models/auto-approval-settings-conversion" diff --git a/src/core/mentions/index.ts b/src/core/mentions/index.ts index 8c9cb1cc..dc3d7eed 100644 --- a/src/core/mentions/index.ts +++ b/src/core/mentions/index.ts @@ -5,6 +5,7 @@ import { getLatestTerminalOutput } from "@integrations/terminal/get-latest-outpu import { UrlContentFetcher } from "@services/browser/UrlContentFetcher" import { telemetryService } from "@services/telemetry" import { mentionRegexGlobal } from "@shared/context-mentions" +import { WorkspaceRoot } from "@shared/multi-root/types" import { openExternal } from "@utils/env" import { getCommitInfo, getWorkingState } from "@utils/git" import fs from "fs/promises" @@ -16,7 +17,7 @@ import { DiagnosticSeverity } from "@/shared/proto/index.cline" import { isDirectory } from "@/utils/fs" import { getCwd } from "@/utils/path" import { FileContextTracker } from "../context/context-tracking/FileContextTracker" -import type { WorkspaceRoot, WorkspaceRootManager } from "../workspace" +import type { WorkspaceRootManager } from "../workspace" export async function openMention(mention?: string): Promise { if (!mention) { diff --git a/src/core/storage/StateManager.ts b/src/core/storage/StateManager.ts index 83f9bb11..99d19164 100644 --- a/src/core/storage/StateManager.ts +++ b/src/core/storage/StateManager.ts @@ -1,4 +1,16 @@ import { ApiConfiguration } from "@shared/api" +import { + GlobalState, + GlobalStateAndSettings, + GlobalStateAndSettingsKey, + GlobalStateKey, + LocalState, + LocalStateKey, + SecretKey, + Secrets, + Settings, + SettingsKey, +} from "@shared/storage/state-keys" import chokidar, { FSWatcher } from "chokidar" import type { ExtensionContext } from "vscode" import { HostProvider } from "@/hosts/host-provider" @@ -11,18 +23,6 @@ import { writeTaskSettingsToStorage, } from "./disk" import { STATE_MANAGER_NOT_INITIALIZED } from "./error-messages" -import { - GlobalState, - GlobalStateAndSettings, - GlobalStateAndSettingsKey, - GlobalStateKey, - LocalState, - LocalStateKey, - SecretKey, - Secrets, - Settings, - SettingsKey, -} from "./state-keys" import { readGlobalStateFromDisk, readSecretsFromDisk, readWorkspaceStateFromDisk } from "./utils/state-helpers" export interface PersistenceErrorEvent { error: Error @@ -323,6 +323,18 @@ export class StateManager { this.remoteConfigCache[key] = value } + /** + * Set method for remote config field - updates cache immediately (no persistence) + * Remote config is read-only from the extension's perspective and only stored in memory + */ + getRemoteConfigSettings(): Partial { + if (!this.isInitialized) { + throw new Error(STATE_MANAGER_NOT_INITIALIZED) + } + + return this.remoteConfigCache + } + /** * Clear remote config cache * Used when switching organizations or when remote config is no longer applicable @@ -727,6 +739,9 @@ export class StateManager { if (!this.isInitialized) { throw new Error(STATE_MANAGER_NOT_INITIALIZED) } + if (this.remoteConfigCache[key] !== undefined) { + return this.remoteConfigCache[key] + } return this.globalStateCache[key] } diff --git a/src/core/storage/disk.ts b/src/core/storage/disk.ts index b1db37f6..4f685464 100644 --- a/src/core/storage/disk.ts +++ b/src/core/storage/disk.ts @@ -4,6 +4,7 @@ import { execa } from "@packages/execa" import { ClineMessage } from "@shared/ExtensionMessage" import { HistoryItem } from "@shared/HistoryItem" import { RemoteConfig } from "@shared/remote-config/schema" +import { GlobalState, Settings } from "@shared/storage/state-keys" import { fileExistsAtPath, isDirectory } from "@utils/fs" import fs from "fs/promises" import os from "os" @@ -11,7 +12,6 @@ import * as path from "path" import { HostProvider } from "@/hosts/host-provider" import { McpMarketplaceCatalog } from "@/shared/mcp" import { StateManager } from "./StateManager" -import { GlobalState, Settings } from "./state-keys" export const GlobalFileNames = { apiConversationHistory: "api_conversation_history.json", diff --git a/src/core/storage/remote-config/fetch.ts b/src/core/storage/remote-config/fetch.ts index b3524f2f..8b665904 100644 --- a/src/core/storage/remote-config/fetch.ts +++ b/src/core/storage/remote-config/fetch.ts @@ -42,7 +42,7 @@ export async function fetchRemoteConfig(): Promise { } const response: AxiosResponse<{ - data?: { Value: string; Enabled: boolean } + data?: { value: string; enabled: boolean } error: string success: boolean }> = await axios.request({ @@ -73,12 +73,12 @@ export async function fetchRemoteConfig(): Promise { } // Check if config is enabled - if (!configData.Enabled) { + if (!configData.enabled) { return undefined } // Parse the JSON-encoded Value field - const parsedConfig = JSON.parse(configData.Value) + const parsedConfig = JSON.parse(configData.value) // Validate against schema const validatedConfig = RemoteConfigSchema.parse(parsedConfig) diff --git a/src/core/storage/remote-config/utils.ts b/src/core/storage/remote-config/utils.ts index fe9a671e..07bd8342 100644 --- a/src/core/storage/remote-config/utils.ts +++ b/src/core/storage/remote-config/utils.ts @@ -1,6 +1,6 @@ -import { RemoteConfig } from "../../../shared/remote-config/schema" +import { RemoteConfig } from "@shared/remote-config/schema" +import { GlobalStateAndSettings } from "@shared/storage/state-keys" import { StateManager } from "../StateManager" -import { GlobalStateAndSettings } from "../state-keys" /** * Transforms RemoteConfig schema to GlobalStateAndSettings shape diff --git a/src/core/storage/utils/state-helpers.ts b/src/core/storage/utils/state-helpers.ts index 3994b209..eb1a5158 100644 --- a/src/core/storage/utils/state-helpers.ts +++ b/src/core/storage/utils/state-helpers.ts @@ -1,4 +1,5 @@ import { ANTHROPIC_MIN_THINKING_BUDGET, ApiProvider, fireworksDefaultModelId, type OcaModelInfo } from "@shared/api" +import { GlobalStateAndSettings, LocalState, SecretKey, Secrets } from "@shared/storage/state-keys" import { ExtensionContext } from "vscode" import { Controller } from "@/core/controller" import { DEFAULT_AUTO_APPROVAL_SETTINGS } from "@/shared/AutoApprovalSettings" @@ -9,7 +10,6 @@ import { DEFAULT_FOCUS_CHAIN_SETTINGS } from "@/shared/FocusChainSettings" import { DEFAULT_MCP_DISPLAY_MODE } from "@/shared/McpDisplayMode" import { OpenaiReasoningEffort } from "@/shared/storage/types" import { readTaskHistoryFromState } from "../disk" -import { GlobalStateAndSettings, LocalState, SecretKey, Secrets } from "../state-keys" export async function readSecretsFromDisk(context: ExtensionContext): Promise { const [ apiKey, diff --git a/src/core/workspace/WorkspaceResolver.ts b/src/core/workspace/WorkspaceResolver.ts index c5eb7aac..0ca9db5d 100644 --- a/src/core/workspace/WorkspaceResolver.ts +++ b/src/core/workspace/WorkspaceResolver.ts @@ -5,11 +5,11 @@ * Phase 1+: Will handle multi-root path resolution */ +import { WorkspaceRoot } from "@shared/multi-root/types" import * as path from "path" import { MigrationReporter, type UsageStats } from "./MigrationReporter" import { parseWorkspaceInlinePath } from "./utils/parseWorkspaceInlinePath" import { WorkspacePathAdapter } from "./WorkspacePathAdapter" -import { WorkspaceRoot } from "./WorkspaceRoot" /** * Maximum number of example paths to store per component for debugging purposes. diff --git a/src/core/workspace/WorkspaceRootManager.ts b/src/core/workspace/WorkspaceRootManager.ts index 095f2374..cb028f9e 100644 --- a/src/core/workspace/WorkspaceRootManager.ts +++ b/src/core/workspace/WorkspaceRootManager.ts @@ -3,10 +3,10 @@ * This class handles workspace root resolution, path mapping, and workspace context */ +import { VcsType, WorkspaceRoot } from "@shared/multi-root/types" import { execa } from "execa" import * as path from "path" import { getGitRemoteUrls, getLatestGitCommitHash } from "../../utils/git" -import { VcsType, WorkspaceRoot } from "./WorkspaceRoot" export interface WorkspaceContext { workspaceRoots: WorkspaceRoot[] diff --git a/src/core/workspace/__tests__/WorkspacePathAdapter.test.ts b/src/core/workspace/__tests__/WorkspacePathAdapter.test.ts index fe593164..52e0ee55 100644 --- a/src/core/workspace/__tests__/WorkspacePathAdapter.test.ts +++ b/src/core/workspace/__tests__/WorkspacePathAdapter.test.ts @@ -3,12 +3,12 @@ * Tests the core functionality of path resolution in single and multi-root workspaces */ +import { VcsType, WorkspaceRoot } from "@shared/multi-root/types" import { expect } from "chai" import { afterEach, beforeEach, describe, it } from "mocha" import * as path from "path" import * as sinon from "sinon" import { createWorkspacePathAdapter, WorkspacePathAdapter } from "../WorkspacePathAdapter" -import { VcsType, WorkspaceRoot } from "../WorkspaceRoot" import { WorkspaceRootManager } from "../WorkspaceRootManager" import "@utils/path" diff --git a/src/core/workspace/__tests__/WorkspaceResolver.test.ts b/src/core/workspace/__tests__/WorkspaceResolver.test.ts index f339447b..9ab862c6 100644 --- a/src/core/workspace/__tests__/WorkspaceResolver.test.ts +++ b/src/core/workspace/__tests__/WorkspaceResolver.test.ts @@ -3,13 +3,13 @@ * These tests ensure behavior preservation during refactoring */ +import { VcsType, WorkspaceRoot } from "@shared/multi-root/types" import { expect } from "chai" import { afterEach, beforeEach, describe, it } from "mocha" import * as path from "path" import * as sinon from "sinon" import { Logger } from "../../../services/logging/Logger" import { WorkspaceResolver } from "../WorkspaceResolver" -import { VcsType, WorkspaceRoot } from "../WorkspaceRoot" describe("WorkspaceResolver", () => { let resolver: WorkspaceResolver diff --git a/src/core/workspace/__tests__/setup.test.ts b/src/core/workspace/__tests__/setup.test.ts index 27bc971c..f72148d6 100644 --- a/src/core/workspace/__tests__/setup.test.ts +++ b/src/core/workspace/__tests__/setup.test.ts @@ -1,4 +1,5 @@ -import { VcsType } from "@core/workspace" +import type { WorkspaceRoot } from "@shared/multi-root/types" +import { VcsType } from "@shared/multi-root/types" import { expect } from "chai" import * as path from "path" import sinon from "sinon" @@ -7,7 +8,6 @@ import * as featureFlags from "@/services/feature-flags" import * as telemetry from "@/services/telemetry" import * as pathUtils from "@/utils/path" import { setupWorkspaceManager } from "../setup" -import type { WorkspaceRoot } from "../WorkspaceRoot" import { WorkspaceRootManager } from "../WorkspaceRootManager" describe("setupWorkspaceManager", () => { diff --git a/src/core/workspace/detection.ts b/src/core/workspace/detection.ts index 01a0640f..1525840e 100644 --- a/src/core/workspace/detection.ts +++ b/src/core/workspace/detection.ts @@ -1,4 +1,4 @@ -import { VcsType, WorkspaceRoot } from "@core/workspace" +import { VcsType, WorkspaceRoot } from "@shared/multi-root/types" import * as path from "path" import { HostProvider } from "@/hosts/host-provider" import { getLatestGitCommitHash, isGitRepository } from "@/utils/git" diff --git a/src/core/workspace/index.ts b/src/core/workspace/index.ts index d20f14c9..f05c7f42 100644 --- a/src/core/workspace/index.ts +++ b/src/core/workspace/index.ts @@ -20,8 +20,6 @@ export { WorkspaceResolver, workspaceResolver, } from "./WorkspaceResolver" -export type { WorkspaceRoot } from "./WorkspaceRoot" -export { VcsType } from "./WorkspaceRoot" export type { WorkspaceContext } from "./WorkspaceRootManager" export { createLegacyWorkspaceRoot, WorkspaceRootManager } from "./WorkspaceRootManager" diff --git a/src/core/workspace/setup.ts b/src/core/workspace/setup.ts index 11bcd0ef..44742a79 100644 --- a/src/core/workspace/setup.ts +++ b/src/core/workspace/setup.ts @@ -1,3 +1,4 @@ +import type { WorkspaceRoot } from "@shared/multi-root/types" import { HostProvider } from "@/hosts/host-provider" import { telemetryService } from "@/services/telemetry" import type { HistoryItem } from "@/shared/HistoryItem" @@ -5,7 +6,6 @@ import { ShowMessageType } from "@/shared/proto/host/window" import { getCwd, getDesktopDir } from "@/utils/path" import { StateManager } from "../storage/StateManager" import { isMultiRootEnabled } from "./multi-root-utils" -import type { WorkspaceRoot } from "./WorkspaceRoot" import { WorkspaceRootManager } from "./WorkspaceRootManager" type DetectRoots = () => Promise diff --git a/src/services/search/file-search.ts b/src/services/search/file-search.ts index 272e4a1f..852008f6 100644 --- a/src/services/search/file-search.ts +++ b/src/services/search/file-search.ts @@ -1,9 +1,10 @@ +import type { WorkspaceRoot } from "@shared/multi-root/types" import * as childProcess from "child_process" import * as fs from "fs" import type { FzfResultItem } from "fzf" import * as path from "path" import * as readline from "readline" -import type { WorkspaceRoot, WorkspaceRootManager } from "@/core/workspace" +import { WorkspaceRootManager } from "@/core/workspace" import { HostProvider } from "@/hosts/host-provider" import { GetOpenTabsRequest } from "@/shared/proto/host/window" import { getBinaryLocation } from "@/utils/fs" diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index 48d19dba..1b8a4b43 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -1,6 +1,7 @@ // type that represents json data that is sent from extension to webview, called ExtensionMessage and has 'type' enum which can be 'plusButtonClicked' or 'settingsButtonClicked' or 'hello' -import { WorkspaceRoot } from "../core/workspace" +import { WorkspaceRoot } from "@shared/multi-root/types" +import { GlobalStateAndSettings } from "@shared/storage/state-keys" import { AutoApprovalSettings } from "./AutoApprovalSettings" import { ApiConfiguration } from "./api" import { BrowserSettings } from "./BrowserSettings" @@ -83,6 +84,7 @@ export interface ExtensionState { lastDismissedInfoBannerVersion: number lastDismissedModelBannerVersion: number hooksEnabled?: ClineFeatureSetting + remoteConfigSettings?: Partial } export interface ClineMessage { diff --git a/src/core/workspace/WorkspaceRoot.ts b/src/shared/multi-root/types.ts similarity index 100% rename from src/core/workspace/WorkspaceRoot.ts rename to src/shared/multi-root/types.ts diff --git a/src/core/storage/state-keys.ts b/src/shared/storage/state-keys.ts similarity index 93% rename from src/core/storage/state-keys.ts rename to src/shared/storage/state-keys.ts index b7b04547..b0310435 100644 --- a/src/core/storage/state-keys.ts +++ b/src/shared/storage/state-keys.ts @@ -1,16 +1,16 @@ +import { AutoApprovalSettings } from "@shared/AutoApprovalSettings" import { ApiProvider, ModelInfo, type OcaModelInfo } from "@shared/api" +import { BrowserSettings } from "@shared/BrowserSettings" +import { ClineRulesToggles } from "@shared/cline-rules" +import { DictationSettings } from "@shared/DictationSettings" import { FocusChainSettings } from "@shared/FocusChainSettings" +import { HistoryItem } from "@shared/HistoryItem" +import { McpDisplayMode } from "@shared/McpDisplayMode" +import { WorkspaceRoot } from "@shared/multi-root/types" +import { Mode, OpenaiReasoningEffort } from "@shared/storage/types" +import { TelemetrySetting } from "@shared/TelemetrySetting" +import { UserInfo } from "@shared/UserInfo" import { LanguageModelChatSelector } from "vscode" -import { WorkspaceRoot } from "@/core/workspace/WorkspaceRoot" -import { AutoApprovalSettings } from "@/shared/AutoApprovalSettings" -import { BrowserSettings } from "@/shared/BrowserSettings" -import { ClineRulesToggles } from "@/shared/cline-rules" -import { DictationSettings } from "@/shared/DictationSettings" -import { HistoryItem } from "@/shared/HistoryItem" -import { McpDisplayMode } from "@/shared/McpDisplayMode" -import { Mode, OpenaiReasoningEffort } from "@/shared/storage/types" -import { TelemetrySetting } from "@/shared/TelemetrySetting" -import { UserInfo } from "@/shared/UserInfo" export type SecretKey = keyof Secrets export type GlobalStateKey = keyof GlobalState diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index aa4d2e3d..80990b8d 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -5,6 +5,7 @@ import Fuse from "fuse.js" import { KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from "react" import { useInterval } from "react-use" import styled from "styled-components" +import HeroTooltip from "@/components/common/HeroTooltip" import { normalizeApiConfiguration } from "@/components/settings/utils/providerUtils" import { PLATFORM_CONFIG, PlatformType } from "@/config/platform.config" import { useExtensionState } from "@/context/ExtensionStateContext" @@ -83,7 +84,7 @@ declare module "vscode" { const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, isPopup, currentMode }: ApiOptionsProps) => { // Use full context state for immediate save payload - const { apiConfiguration } = useExtensionState() + const { apiConfiguration, remoteConfigSettings } = useExtensionState() const { selectedProvider } = normalizeApiConfiguration(apiConfiguration, currentMode) @@ -125,7 +126,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is const dropdownListRef = useRef(null) const providerOptions = useMemo(() => { - const providers = [ + let providers = [ { value: "cline", label: "Cline" }, { value: "openrouter", label: "OpenRouter" }, { value: "gemini", label: "Google Gemini" }, @@ -166,11 +167,11 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is if (PLATFORM_CONFIG.type !== PlatformType.VSCODE) { // Don't include VS Code LM API for non-VSCode platforms - return providers.filter((option) => option.value !== "vscode-lm") + providers = providers.filter((option) => option.value !== "vscode-lm") } return providers - }, []) + }, [remoteConfigSettings]) const currentProviderLabel = useMemo(() => { return providerOptions.find((option) => option.value === selectedProvider)?.label || selectedProvider @@ -295,12 +296,24 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is `} - + {remoteConfigSettings?.planModeApiProvider !== undefined ? ( + +
+ + +
+
+ ) : ( + + )} { setIsDropdownVisible(true) diff --git a/webview-ui/src/components/settings/common/BaseUrlField.tsx b/webview-ui/src/components/settings/common/BaseUrlField.tsx index 1279bc80..4bb128f6 100644 --- a/webview-ui/src/components/settings/common/BaseUrlField.tsx +++ b/webview-ui/src/components/settings/common/BaseUrlField.tsx @@ -11,6 +11,8 @@ interface BaseUrlFieldProps { defaultValue?: string label?: string placeholder?: string + disabled?: boolean + showLockIcon?: boolean } /** @@ -21,6 +23,8 @@ export const BaseUrlField = ({ onChange, label = "Use custom base URL", placeholder = "Default: https://api.example.com", + disabled = false, + showLockIcon = false, }: BaseUrlFieldProps) => { const [isEnabled, setIsEnabled] = useState(!!initialValue) const [localValue, setLocalValue] = useDebouncedInput(initialValue || "", onChange) @@ -35,16 +39,20 @@ export const BaseUrlField = ({ return (
- - {label} - +
+ + {label} + + {showLockIcon && } +
{isEnabled && ( setLocalValue(e.target.value.trim())} placeholder={placeholder} style={{ width: "100%", marginTop: 3 }} - type="url" + type={disabled ? "text" : "url"} value={localValue} /> )} diff --git a/webview-ui/src/components/settings/providers/BedrockProvider.tsx b/webview-ui/src/components/settings/providers/BedrockProvider.tsx index 2685e6cd..d70ee0cf 100644 --- a/webview-ui/src/components/settings/providers/BedrockProvider.tsx +++ b/webview-ui/src/components/settings/providers/BedrockProvider.tsx @@ -2,6 +2,7 @@ import { bedrockDefaultModelId, bedrockModels, CLAUDE_SONNET_1M_SUFFIX } from "@ import { Mode } from "@shared/storage/types" import { VSCodeCheckbox, VSCodeDropdown, VSCodeOption, VSCodeRadio, VSCodeRadioGroup } from "@vscode/webview-ui-toolkit/react" import { useState } from "react" +import HeroTooltip from "@/components/common/HeroTooltip" import { useExtensionState } from "@/context/ExtensionStateContext" import { DebouncedTextField } from "../common/DebouncedTextField" import { ModelInfoView } from "../common/ModelInfoView" @@ -20,7 +21,7 @@ interface BedrockProviderProps { } export const BedrockProvider = ({ showModelOptions, isPopup, currentMode }: BedrockProviderProps) => { - const { apiConfiguration } = useExtensionState() + const { apiConfiguration, remoteConfigSettings } = useExtensionState() const { handleFieldChange, handleModeFieldChange, handleModeFieldsChange } = useApiConfigurationHandlers() const { selectedModelId, selectedModelInfo } = normalizeApiConfiguration(apiConfiguration, currentMode) @@ -95,100 +96,234 @@ export const BedrockProvider = ({ showModelOptions, isPopup, currentMode }: Bedr )} - - - handleFieldChange("awsRegion", e.target.value)} - style={{ width: "100%" }} - value={apiConfiguration?.awsRegion || ""}> - Select a region... - {/* The user will have to choose a region that supports the model they use, but this shouldn't be a problem since they'd have to request access for it in that region in the first place. */} - us-east-1 - us-east-2 - us-west-1 - us-west-2 - {/* af-south-1 */} - {/* ap-east-1 */} - ap-south-1 - ap-northeast-1 - ap-northeast-2 - ap-northeast-3 - ap-southeast-1 - ap-southeast-2 - ca-central-1 - eu-central-1 - eu-central-2 - eu-west-1 - eu-west-2 - eu-west-3 - eu-north-1 - eu-south-1 - eu-south-2 - {/* me-south-1 */} - sa-east-1 - us-gov-east-1 - us-gov-west-1 - {/* us-gov-east-1 */} - - + {remoteConfigSettings?.awsRegion !== undefined ? ( + + +
+ + +
+ handleFieldChange("awsRegion", e.target.value)} + style={{ width: "100%" }} + value={apiConfiguration?.awsRegion || ""}> + Select a region... + {/* The user will have to choose a region that supports the model they use, but this shouldn't be a problem since they'd have to request access for it in that region in the first place. */} + us-east-1 + us-east-2 + us-west-1 + us-west-2 + {/* af-south-1 */} + {/* ap-east-1 */} + ap-south-1 + ap-northeast-1 + ap-northeast-2 + ap-northeast-3 + ap-southeast-1 + ap-southeast-2 + ca-central-1 + eu-central-1 + eu-central-2 + eu-west-1 + eu-west-2 + eu-west-3 + eu-north-1 + eu-south-1 + eu-south-2 + {/* me-south-1 */} + sa-east-1 + us-gov-east-1 + us-gov-west-1 + {/* us-gov-east-1 */} + +
+
+ ) : ( + + + handleFieldChange("awsRegion", e.target.value)} + style={{ width: "100%" }} + value={apiConfiguration?.awsRegion || ""}> + Select a region... + {/* The user will have to choose a region that supports the model they use, but this shouldn't be a problem since they'd have to request access for it in that region in the first place. */} + us-east-1 + us-east-2 + us-west-1 + us-west-2 + {/* af-south-1 */} + {/* ap-east-1 */} + ap-south-1 + ap-northeast-1 + ap-northeast-2 + ap-northeast-3 + ap-southeast-1 + ap-southeast-2 + ca-central-1 + eu-central-1 + eu-central-2 + eu-west-1 + eu-west-2 + eu-west-3 + eu-north-1 + eu-south-1 + eu-south-2 + {/* me-south-1 */} + sa-east-1 + us-gov-east-1 + us-gov-west-1 + {/* us-gov-east-1 */} + + + )}
- { - const isChecked = e.target.checked === true - setAwsEndpointSelected(isChecked) - if (!isChecked) { - handleFieldChange("awsBedrockEndpoint", "") - } - }}> - Use custom VPC endpoint - + {remoteConfigSettings?.awsBedrockEndpoint !== undefined ? ( + +
+
+ { + const isChecked = e.target.checked === true + setAwsEndpointSelected(isChecked) + if (!isChecked) { + handleFieldChange("awsBedrockEndpoint", "") + } + }}> + Use custom VPC endpoint + + +
- {awsEndpointSelected && ( - handleFieldChange("awsBedrockEndpoint", value)} - placeholder="Enter VPC Endpoint URL (optional)" - style={{ width: "100%", marginTop: 3, marginBottom: 5 }} - type="url" - /> + {awsEndpointSelected && ( + handleFieldChange("awsBedrockEndpoint", value)} + placeholder="Enter VPC Endpoint URL (optional)" + style={{ width: "100%", marginTop: 3, marginBottom: 5 }} + type="text" + /> + )} +
+
+ ) : ( + <> + { + const isChecked = e.target.checked === true + setAwsEndpointSelected(isChecked) + if (!isChecked) { + handleFieldChange("awsBedrockEndpoint", "") + } + }}> + Use custom VPC endpoint + + + {awsEndpointSelected && ( + handleFieldChange("awsBedrockEndpoint", value)} + placeholder="Enter VPC Endpoint URL (optional)" + style={{ width: "100%", marginTop: 3, marginBottom: 5 }} + type="url" + /> + )} + )} - { - const isChecked = e.target.checked === true + {remoteConfigSettings?.awsUseCrossRegionInference !== undefined ? ( + +
+ { + const isChecked = e.target.checked === true - handleFieldChange("awsUseCrossRegionInference", isChecked) - }}> - Use cross-region inference - - - {apiConfiguration?.awsUseCrossRegionInference && selectedModelInfo.supportsGlobalEndpoint && ( + handleFieldChange("awsUseCrossRegionInference", isChecked) + }}> + Use cross-region inference + + +
+
+ ) : ( { const isChecked = e.target.checked === true - handleFieldChange("awsUseGlobalInference", isChecked) + + handleFieldChange("awsUseCrossRegionInference", isChecked) }}> - Use global inference profile + Use cross-region inference )} - {selectedModelInfo.supportsPromptCache && ( - { - const isChecked = e.target.checked === true - handleFieldChange("awsBedrockUsePromptCache", isChecked) - }}> - Use prompt caching - - )} + {apiConfiguration?.awsUseCrossRegionInference && + selectedModelInfo.supportsGlobalEndpoint && + (remoteConfigSettings?.awsUseGlobalInference !== undefined ? ( + +
+ { + const isChecked = e.target.checked === true + handleFieldChange("awsUseGlobalInference", isChecked) + }}> + Use global inference profile + + +
+
+ ) : ( + { + const isChecked = e.target.checked === true + handleFieldChange("awsUseGlobalInference", isChecked) + }}> + Use global inference profile + + ))} + + {selectedModelInfo.supportsPromptCache && + (remoteConfigSettings?.awsBedrockUsePromptCache !== undefined ? ( + +
+ { + const isChecked = e.target.checked === true + handleFieldChange("awsBedrockUsePromptCache", isChecked) + }}> + Use prompt caching + + +
+
+ ) : ( + { + const isChecked = e.target.checked === true + handleFieldChange("awsBedrockUsePromptCache", isChecked) + }}> + Use prompt caching + + ))}

{ - const { apiConfiguration } = useExtensionState() + const { apiConfiguration, remoteConfigSettings } = useExtensionState() const { handleFieldChange, handleModeFieldChange } = useApiConfigurationHandlers() const [modelConfigurationSelected, setModelConfigurationSelected] = useState(false) @@ -69,17 +70,39 @@ export const OpenAICompatibleProvider = ({ showModelOptions, isPopup, currentMod return (

- { - handleFieldChange("openAiBaseUrl", value) - debouncedRefreshOpenAiModels(value, apiConfiguration?.openAiApiKey) - }} - placeholder={"Enter base URL..."} - style={{ width: "100%", marginBottom: 10 }} - type="url"> - Base URL - + {remoteConfigSettings?.openAiBaseUrl !== undefined ? ( + +
+
+ Base URL + +
+ { + handleFieldChange("openAiBaseUrl", value) + debouncedRefreshOpenAiModels(value, apiConfiguration?.openAiApiKey) + }} + placeholder={"Enter base URL..."} + style={{ width: "100%" }} + type="url" + /> +
+
+ ) : ( + { + handleFieldChange("openAiBaseUrl", value) + debouncedRefreshOpenAiModels(value, apiConfiguration?.openAiApiKey) + }} + placeholder={"Enter base URL..."} + style={{ width: "100%", marginBottom: 10 }} + type="url"> + Base URL + + )} { const headerEntries = Object.entries(apiConfiguration?.openAiHeaders ?? {}) + return (
-
- Custom Headers - { - const currentHeaders = { ...(apiConfiguration?.openAiHeaders || {}) } - const headerCount = Object.keys(currentHeaders).length - const newKey = `header${headerCount + 1}` - currentHeaders[newKey] = "" - handleFieldChange("openAiHeaders", currentHeaders) - }}> - Add Header - -
+ {remoteConfigSettings?.openAiHeaders !== undefined ? ( +
+ +
+ Custom Headers + +
+
+ Add Header +
+ ) : ( +
+ Custom Headers + { + const currentHeaders = { ...(apiConfiguration?.openAiHeaders || {}) } + const headerCount = Object.keys(currentHeaders).length + const newKey = `header${headerCount + 1}` + currentHeaders[newKey] = "" + handleFieldChange("openAiHeaders", currentHeaders) + }}> + Add Header + +
+ )}
{headerEntries.map(([key, value], index) => (
{ const currentHeaders = apiConfiguration?.openAiHeaders ?? {} @@ -137,6 +174,7 @@ export const OpenAICompatibleProvider = ({ showModelOptions, isPopup, currentMod style={{ width: "40%" }} /> { handleFieldChange("openAiHeaders", { @@ -149,6 +187,7 @@ export const OpenAICompatibleProvider = ({ showModelOptions, isPopup, currentMod /> { const { [key]: _, ...rest } = apiConfiguration?.openAiHeaders ?? {} handleFieldChange("openAiHeaders", rest) @@ -162,12 +201,25 @@ export const OpenAICompatibleProvider = ({ showModelOptions, isPopup, currentMod ) })()} - handleFieldChange("azureApiVersion", value)} - placeholder={`Default: ${azureOpenAiDefaultApiVersion}`} - /> + {remoteConfigSettings?.azureApiVersion !== undefined ? ( + + handleFieldChange("azureApiVersion", value)} + placeholder={`Default: ${azureOpenAiDefaultApiVersion}`} + showLockIcon={true} + /> + + ) : ( + handleFieldChange("azureApiVersion", value)} + placeholder={`Default: ${azureOpenAiDefaultApiVersion}`} + /> + )}
setModelConfigurationSelected((val) => !val)} diff --git a/webview-ui/src/components/settings/sections/FeatureSettingsSection.tsx b/webview-ui/src/components/settings/sections/FeatureSettingsSection.tsx index 21f49870..4a3430b3 100644 --- a/webview-ui/src/components/settings/sections/FeatureSettingsSection.tsx +++ b/webview-ui/src/components/settings/sections/FeatureSettingsSection.tsx @@ -3,6 +3,7 @@ import { McpDisplayMode } from "@shared/McpDisplayMode" import { OpenaiReasoningEffort } from "@shared/storage/types" import { VSCodeCheckbox, VSCodeDropdown, VSCodeOption, VSCodeTextField } from "@vscode/webview-ui-toolkit/react" import { memo } from "react" +import HeroTooltip from "@/components/common/HeroTooltip" import McpDisplayModeDropdown from "@/components/mcp/chat-display/McpDisplayModeDropdown" import { useExtensionState } from "@/context/ExtensionStateContext" import Section from "../Section" @@ -26,6 +27,7 @@ const FeatureSettingsSection = ({ renderSectionHeader }: FeatureSettingsSectionP focusChainSettings, multiRootSetting, hooksEnabled, + remoteConfigSettings, } = useExtensionState() const handleReasoningEffortChange = (newValue: OpenaiReasoningEffort) => { @@ -52,14 +54,32 @@ const FeatureSettingsSection = ({ renderSectionHeader }: FeatureSettingsSectionP

- { - const checked = e.target.checked === true - updateSetting("mcpMarketplaceEnabled", checked) - }}> - Enable MCP Marketplace - + {remoteConfigSettings?.mcpMarketplaceEnabled !== undefined ? ( + +
+ { + const checked = e.target.checked === true + updateSetting("mcpMarketplaceEnabled", checked) + }}> + Enable MCP Marketplace + + +
+
+ ) : ( + { + const checked = e.target.checked === true + updateSetting("mcpMarketplaceEnabled", checked) + }}> + Enable MCP Marketplace + + )}

Enables the MCP Marketplace tab for discovering and installing MCP servers.

@@ -284,14 +304,32 @@ const FeatureSettingsSection = ({ renderSectionHeader }: FeatureSettingsSectionP
)}
- { - const checked = e.target.checked === true - updateSetting("yoloModeToggled", checked) - }}> - Enable YOLO Mode - + {remoteConfigSettings?.yoloModeToggled !== undefined ? ( + +
+ { + const checked = e.target.checked === true + updateSetting("yoloModeToggled", checked) + }}> + Enable YOLO Mode + + +
+
+ ) : ( + { + const checked = e.target.checked === true + updateSetting("yoloModeToggled", checked) + }}> + Enable YOLO Mode + + )}

EXPERIMENTAL & DANGEROUS: This mode disables safety checks and user confirmations. Cline will automatically approve all actions without asking. Use with extreme caution. diff --git a/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx b/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx index 4b8e4e5e..176c7c2e 100644 --- a/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx +++ b/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx @@ -1,4 +1,5 @@ import { VSCodeCheckbox, VSCodeLink } from "@vscode/webview-ui-toolkit/react" +import HeroTooltip from "@/components/common/HeroTooltip" import { useExtensionState } from "@/context/ExtensionStateContext" import PreferredLanguageSetting from "../PreferredLanguageSetting" import Section from "../Section" @@ -9,7 +10,8 @@ interface GeneralSettingsSectionProps { } const GeneralSettingsSection = ({ renderSectionHeader }: GeneralSettingsSectionProps) => { - const { telemetrySetting } = useExtensionState() + const { telemetrySetting, remoteConfigSettings } = useExtensionState() + const isDisabledByRemoteConfig = remoteConfigSettings?.telemetrySetting === "disabled" return (

@@ -18,15 +20,33 @@ const GeneralSettingsSection = ({ renderSectionHeader }: GeneralSettingsSectionP
- { - const checked = e.target.checked === true - updateSetting("telemetrySetting", checked ? "enabled" : "disabled") - }}> - Allow error and usage reporting - + {isDisabledByRemoteConfig ? ( + +
+ { + const checked = e.target.checked === true + updateSetting("telemetrySetting", checked ? "enabled" : "disabled") + }}> + Allow error and usage reporting + + +
+
+ ) : ( + { + const checked = e.target.checked === true + updateSetting("telemetrySetting", checked ? "enabled" : "disabled") + }}> + Allow error and usage reporting + + )}

Help improve Cline by sending usage data and error reports. No code, prompts, or personal information are ever sent. See our{" "} diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index e6447433..5ba4cc43 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -213,6 +213,7 @@ export const ExtensionStateContextProvider: React.FC<{ favoritedModelIds: [], lastDismissedInfoBannerVersion: 0, lastDismissedModelBannerVersion: 0, + remoteConfigSettings: {}, // NEW: Add workspace information with defaults workspaceRoots: [],