From 663e75203b5390201640a909ef241908fcfb0b3d Mon Sep 17 00:00:00 2001 From: Igor Tceglevskii Date: Mon, 13 Oct 2025 11:46:26 -0700 Subject: [PATCH] feat: add environment-based visual indicators to UI (#6777) --- src/config.ts | 13 ++++--- src/core/controller/index.ts | 4 +- src/shared/ExtensionMessage.ts | 2 + webview-ui/src/assets/ClineLogoVariable.tsx | 39 ++++++++++++------- .../src/components/account/AccountView.tsx | 9 ++++- .../components/account/AccountWelcomeView.tsx | 39 +++++++++++-------- .../chat/task-header/TaskHeader.tsx | 13 +++++-- .../src/components/history/HistoryView.tsx | 5 ++- .../configuration/McpConfigurationView.tsx | 11 +++++- .../src/components/settings/SettingsView.tsx | 9 ++++- .../src/components/welcome/HomeHeader.tsx | 5 ++- .../src/context/ExtensionStateContext.tsx | 2 + webview-ui/src/utils/environmentColors.ts | 29 ++++++++++++++ 13 files changed, 131 insertions(+), 49 deletions(-) create mode 100644 webview-ui/src/utils/environmentColors.ts diff --git a/src/config.ts b/src/config.ts index a5019434..35869ae6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,6 +5,7 @@ export enum Environment { } export interface EnvironmentConfig { + environment: Environment appBaseUrl: string apiBaseUrl: string mcpBaseUrl: string @@ -32,10 +33,11 @@ function getClineEnv(): Environment { } // Config getter function to avoid storing all configs in memory -function getEnvironmentConfig(env: Environment): EnvironmentConfig { - switch (env) { +function getEnvironmentConfig(environment: Environment): EnvironmentConfig { + switch (environment) { case Environment.staging: return { + environment, appBaseUrl: "https://staging-app.cline.bot", apiBaseUrl: "https://core-api.staging.int.cline.bot", mcpBaseUrl: "https://api.cline.bot/v1/mcp", @@ -50,6 +52,7 @@ function getEnvironmentConfig(env: Environment): EnvironmentConfig { } case Environment.local: return { + environment, appBaseUrl: "http://localhost:3000", apiBaseUrl: "http://localhost:7777", mcpBaseUrl: "https://api.cline.bot/v1/mcp", @@ -61,6 +64,7 @@ function getEnvironmentConfig(env: Environment): EnvironmentConfig { } default: return { + environment, appBaseUrl: "https://app.cline.bot", apiBaseUrl: "https://api.cline.bot", mcpBaseUrl: "https://api.cline.bot/v1/mcp", @@ -77,9 +81,8 @@ function getEnvironmentConfig(env: Environment): EnvironmentConfig { } // Get environment once at module load -const CLINE_ENVIRONMENT = getClineEnv() -const _configCache = getEnvironmentConfig(CLINE_ENVIRONMENT) +const _configCache = getEnvironmentConfig(getClineEnv()) -console.info("Cline environment:", CLINE_ENVIRONMENT) +console.info("Cline environment:", _configCache.environment) export const clineEnvConfig = _configCache diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index a47f6cd8..a251a914 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -754,6 +754,7 @@ export class Controller { const platform = process.platform as Platform const distinctId = getDistinctId() const version = ExtensionRegistryInfo.version + const environment = clineEnvConfig.environment // Set feature flag in dictation settings based on platform const updatedDictationSettings = { @@ -784,6 +785,8 @@ export class Controller { telemetrySetting, planActSeparateModelsSetting, enableCheckpointsSetting: enableCheckpointsSetting ?? true, + platform, + environment, distinctId, globalClineRulesToggles: globalClineRulesToggles || {}, localClineRulesToggles: localClineRulesToggles || {}, @@ -800,7 +803,6 @@ export class Controller { terminalOutputLineLimit, customPrompt, taskHistory: processedTaskHistory, - platform, shouldShowAnnouncement, favoritedModelIds, autoCondenseThreshold, diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index 1b8a4b43..c2734688 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -2,6 +2,7 @@ import { WorkspaceRoot } from "@shared/multi-root/types" import { GlobalStateAndSettings } from "@shared/storage/state-keys" +import type { Environment } from "../config" import { AutoApprovalSettings } from "./AutoApprovalSettings" import { ApiConfiguration } from "./api" import { BrowserSettings } from "./BrowserSettings" @@ -51,6 +52,7 @@ export interface ExtensionState { planActSeparateModelsSetting: boolean enableCheckpointsSetting?: boolean platform: Platform + environment?: Environment shouldShowAnnouncement: boolean taskHistory: HistoryItem[] telemetrySetting: TelemetrySetting diff --git a/webview-ui/src/assets/ClineLogoVariable.tsx b/webview-ui/src/assets/ClineLogoVariable.tsx index d807490d..7bc97bf9 100644 --- a/webview-ui/src/assets/ClineLogoVariable.tsx +++ b/webview-ui/src/assets/ClineLogoVariable.tsx @@ -1,21 +1,32 @@ import { SVGProps } from "react" +import type { Environment } from "../../../src/config" +import { getEnvironmentColor } from "../utils/environmentColors" /** - * ClineLogoVariable component renders the Cline logo with automatic theme adaptation. + * ClineLogoVariable component renders the Cline logo with automatic theme adaptation + * and environment-based color indicators. * - * This component uses the VS Code theme variable `--vscode-icon-foreground` for the fill color, - * which automatically adjusts based on the active VS Code theme (light, dark, high contrast) - * to ensure optimal contrast with the background. + * This component uses VS Code theme variables for the fill color, with environment-specific colors: + * - Local: yellow/orange (development/experimental) + * - Staging: blue (stable testing) + * - Production: gray/white (default icon color) * - * @param {SVGProps} props - Standard SVG props including className, style, etc. - * @returns {JSX.Element} SVG Cline logo that adapts to VS Code themes + * @param {SVGProps & { environment?: Environment }} props - Standard SVG props plus optional environment + * @returns {JSX.Element} SVG Cline logo that adapts to VS Code themes and environment */ -const ClineLogoVariable = (props: SVGProps) => ( - - - -) +const ClineLogoVariable = (props: SVGProps & { environment?: Environment }) => { + const { environment, ...svgProps } = props + + // Determine fill color based on environment + const fillColor = environment ? getEnvironmentColor(environment) : "var(--vscode-icon-foreground)" + + return ( + + + + ) +} export default ClineLogoVariable diff --git a/webview-ui/src/components/account/AccountView.tsx b/webview-ui/src/components/account/AccountView.tsx index e86b5d62..f677404e 100644 --- a/webview-ui/src/components/account/AccountView.tsx +++ b/webview-ui/src/components/account/AccountView.tsx @@ -6,7 +6,9 @@ import deepEqual from "fast-deep-equal" import { memo, useCallback, useEffect, useRef, useState } from "react" import { useInterval } from "react-use" import { type ClineUser, handleSignOut } from "@/context/ClineAuthContext" +import { useExtensionState } from "@/context/ExtensionStateContext" import { AccountServiceClient } from "@/services/grpc-client" +import { getEnvironmentColor } from "@/utils/environmentColors" import VSCodeButtonLink from "../common/VSCodeButtonLink" import { AccountWelcomeView } from "./AccountWelcomeView" import { CreditBalance } from "./CreditBalance" @@ -34,10 +36,15 @@ type CachedData = { } const AccountView = ({ onDone, clineUser, organizations, activeOrganization }: AccountViewProps) => { + const { environment } = useExtensionState() + const titleColor = getEnvironmentColor(environment) + return (
-

Account

+

+ Account +

Done
diff --git a/webview-ui/src/components/account/AccountWelcomeView.tsx b/webview-ui/src/components/account/AccountWelcomeView.tsx index 5a1f21f7..afb07ce4 100644 --- a/webview-ui/src/components/account/AccountWelcomeView.tsx +++ b/webview-ui/src/components/account/AccountWelcomeView.tsx @@ -1,23 +1,28 @@ import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react" import { handleSignIn } from "@/context/ClineAuthContext" -import ClineLogoWhite from "../../assets/ClineLogoWhite" +import { useExtensionState } from "@/context/ExtensionStateContext" +import ClineLogoVariable from "../../assets/ClineLogoVariable" -export const AccountWelcomeView = () => ( -
- +export const AccountWelcomeView = () => { + const { environment } = useExtensionState() -

- Sign up for an account to get access to the latest models, billing dashboard to view usage and credits, and more - upcoming features. -

+ return ( +
+ - handleSignIn()}> - Sign up with Cline - +

+ Sign up for an account to get access to the latest models, billing dashboard to view usage and credits, and more + upcoming features. +

-

- By continuing, you agree to the Terms of Service and{" "} - Privacy Policy. -

-
-) + handleSignIn()}> + Sign up with Cline + + +

+ By continuing, you agree to the Terms of Service and{" "} + Privacy Policy. +

+
+ ) +} diff --git a/webview-ui/src/components/chat/task-header/TaskHeader.tsx b/webview-ui/src/components/chat/task-header/TaskHeader.tsx index b15c1ef0..000d7d43 100644 --- a/webview-ui/src/components/chat/task-header/TaskHeader.tsx +++ b/webview-ui/src/components/chat/task-header/TaskHeader.tsx @@ -7,6 +7,7 @@ import Thumbnails from "@/components/common/Thumbnails" import { getModeSpecificFields, normalizeApiConfiguration } from "@/components/settings/utils/providerUtils" import { useExtensionState } from "@/context/ExtensionStateContext" import { UiServiceClient } from "@/services/grpc-client" +import { getEnvironmentColor } from "@/utils/environmentColors" import CopyTaskButton from "./buttons/CopyTaskButton" import DeleteTaskButton from "./buttons/DeleteTaskButton" import NewTaskButton from "./buttons/NewTaskButton" @@ -58,6 +59,7 @@ const TaskHeader: React.FC = ({ mode, expandTaskHeader: isTaskExpanded, setExpandTaskHeader: setIsTaskExpanded, + environment, } = useExtensionState() // Simplified computed values @@ -86,6 +88,7 @@ const TaskHeader: React.FC = ({ }, [navigateToSettings]) const highlightedText = useMemo(() => highlightText(task.text, false), [task.text]) + const environmentBorderColor = getEnvironmentColor(environment, "border") return (
@@ -99,11 +102,13 @@ const TaskHeader: React.FC = ({ className={cn( "relative overflow-hidden cursor-pointer rounded-sm flex flex-col gap-1.5 z-10 pt-2 pb-2 px-2 hover:opacity-100 bg-[var(--vscode-toolbar-hoverBackground)]/65", { - "opacity-100 border-1 border-[var(--vscode-editorGroup-border)]": isTaskExpanded, // No hover effects when expanded, add border - "hover:bg-[var(--vscode-toolbar-hoverBackground)] border-1 border-[var(--vscode-editorGroup-border)]": - !isTaskExpanded, // Hover effects only when collapsed + "opacity-100 border-1": isTaskExpanded, // No hover effects when expanded, add border + "hover:bg-[var(--vscode-toolbar-hoverBackground)] border-1": !isTaskExpanded, // Hover effects only when collapsed }, - )}> + )} + style={{ + borderColor: environmentBorderColor, + }}> {/* Task Title */}
diff --git a/webview-ui/src/components/history/HistoryView.tsx b/webview-ui/src/components/history/HistoryView.tsx index 13f97cdc..e339fd5b 100644 --- a/webview-ui/src/components/history/HistoryView.tsx +++ b/webview-ui/src/components/history/HistoryView.tsx @@ -7,6 +7,7 @@ import { Virtuoso } from "react-virtuoso" import DangerButton from "@/components/common/DangerButton" import { useExtensionState } from "@/context/ExtensionStateContext" import { TaskServiceClient } from "@/services/grpc-client" +import { getEnvironmentColor } from "@/utils/environmentColors" import { formatLargeNumber, formatSize } from "@/utils/format" type HistoryViewProps = { @@ -46,7 +47,7 @@ const CustomFilterRadio = ({ checked, onChange, icon, label }: CustomFilterRadio const HistoryView = ({ onDone }: HistoryViewProps) => { const extensionStateContext = useExtensionState() - const { taskHistory, onRelinquishControl } = extensionStateContext + const { taskHistory, onRelinquishControl, environment } = extensionStateContext const [searchQuery, setSearchQuery] = useState("") const [sortOption, setSortOption] = useState("newest") const [lastNonRelevantSort, setLastNonRelevantSort] = useState("newest") @@ -317,7 +318,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => { }}>

History diff --git a/webview-ui/src/components/mcp/configuration/McpConfigurationView.tsx b/webview-ui/src/components/mcp/configuration/McpConfigurationView.tsx index b045f41c..5dbad3b6 100644 --- a/webview-ui/src/components/mcp/configuration/McpConfigurationView.tsx +++ b/webview-ui/src/components/mcp/configuration/McpConfigurationView.tsx @@ -7,6 +7,7 @@ import { useEffect, useState } from "react" import styled from "styled-components" import { useExtensionState } from "@/context/ExtensionStateContext" import { McpServiceClient } from "@/services/grpc-client" +import { getEnvironmentColor } from "@/utils/environmentColors" import AddRemoteServerForm from "./tabs/add-server/AddRemoteServerForm" import ConfigureServersView from "./tabs/installed/ConfigureServersView" import McpMarketplaceView from "./tabs/marketplace/McpMarketplaceView" @@ -17,7 +18,7 @@ type McpViewProps = { } const McpConfigurationView = ({ onDone, initialTab }: McpViewProps) => { - const { mcpMarketplaceEnabled, setMcpServers } = useExtensionState() + const { mcpMarketplaceEnabled, setMcpServers, environment } = useExtensionState() const [activeTab, setActiveTab] = useState(initialTab || (mcpMarketplaceEnabled ? "marketplace" : "configure")) const handleTabChange = (tab: McpViewTab) => { @@ -75,7 +76,13 @@ const McpConfigurationView = ({ onDone, initialTab }: McpViewProps) => { alignItems: "center", padding: "10px 17px 5px 20px", }}> -

MCP Servers

+

+ MCP Servers +

Done

diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index 35a22dea..6bc28048 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -17,6 +17,7 @@ import { useEvent } from "react-use" import HeroTooltip from "@/components/common/HeroTooltip" import { useExtensionState } from "@/context/ExtensionStateContext" import { StateServiceClient } from "@/services/grpc-client" +import { getEnvironmentColor } from "@/utils/environmentColors" import { Tab, TabContent, TabHeader, TabList, TabTrigger } from "../common/Tab" import SectionHeader from "./SectionHeader" import AboutSection from "./sections/AboutSection" @@ -139,7 +140,7 @@ const SettingsView = ({ onDone, targetSection }: SettingsViewProps) => { [], ) // Empty deps - these imports never change - const { version } = useExtensionState() + const { version, environment } = useExtensionState() // Initialize active tab with memoized calculation const initialTab = useMemo(() => targetSection || SETTINGS_TABS[0].id, [targetSection]) @@ -295,11 +296,15 @@ const SettingsView = ({ onDone, targetSection }: SettingsViewProps) => { return }, [activeTab, handleResetState, version]) + const titleColor = getEnvironmentColor(environment) + return (
-

Settings

+

+ Settings +

Done diff --git a/webview-ui/src/components/welcome/HomeHeader.tsx b/webview-ui/src/components/welcome/HomeHeader.tsx index 183b82f8..a4845b77 100644 --- a/webview-ui/src/components/welcome/HomeHeader.tsx +++ b/webview-ui/src/components/welcome/HomeHeader.tsx @@ -1,6 +1,7 @@ import { EmptyRequest } from "@shared/proto/cline/common" import ClineLogoVariable from "@/assets/ClineLogoVariable" import HeroTooltip from "@/components/common/HeroTooltip" +import { useExtensionState } from "@/context/ExtensionStateContext" import { UiServiceClient } from "@/services/grpc-client" interface HomeHeaderProps { @@ -8,6 +9,8 @@ interface HomeHeaderProps { } const HomeHeader = ({ shouldShowQuickWins = false }: HomeHeaderProps) => { + const { environment } = useExtensionState() + const handleTakeATour = async () => { try { await UiServiceClient.openWalkthrough(EmptyRequest.create()) @@ -19,7 +22,7 @@ const HomeHeader = ({ shouldShowQuickWins = false }: HomeHeaderProps) => { return (
- +

{"What can I do for you?"}

diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index 5ba4cc43..cd965bd5 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -14,6 +14,7 @@ import { convertProtoToClineMessage } from "@shared/proto-conversions/cline-mess import { convertProtoMcpServersToMcpServers } from "@shared/proto-conversions/mcp/mcp-server-conversion" import type React from "react" import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react" +import { Environment } from "../../../src/config" import { basetenDefaultModelId, basetenModels, @@ -187,6 +188,7 @@ export const ExtensionStateContextProvider: React.FC<{ openaiReasoningEffort: "medium", mode: "act", platform: DEFAULT_PLATFORM, + environment: Environment.production, telemetrySetting: "unset", distinctId: "", planActSeparateModelsSetting: true, diff --git a/webview-ui/src/utils/environmentColors.ts b/webview-ui/src/utils/environmentColors.ts new file mode 100644 index 00000000..2819437f --- /dev/null +++ b/webview-ui/src/utils/environmentColors.ts @@ -0,0 +1,29 @@ +import type { Environment } from "../../../src/config" + +/** + * Gets the appropriate color for the current environment. + * + * Environment color scheme: + * - Local: Yellow/orange (warning color) - indicates development/experimental environment + * - Staging: Blue (focus border) - indicates stable testing environment + * - Production: Default VSCode colors - standard appearance + * + * @param environment - The current environment (local, staging, or production) + * @param type - The type of color needed: "primary" for text/fills, "border" for borders + * @returns CSS variable string for the appropriate environment color + */ +export const getEnvironmentColor = (environment: Environment | undefined, type: "primary" | "border" = "primary"): string => { + if (type === "border") { + return environment === "local" + ? "var(--vscode-activityWarningBadge-background)" // Yellow/orange for local + : environment === "staging" + ? "var(--vscode-focusBorder)" // Blue for staging + : "var(--vscode-editorGroup-border)" // Default for production + } + + return environment === "local" + ? "var(--vscode-activityWarningBadge-background)" // Yellow/orange for local + : environment === "staging" + ? "var(--vscode-focusBorder)" // Blue for staging + : "var(--vscode-foreground)" // Default for production +}