diff --git a/.changeset/shiny-cities-doubt.md b/.changeset/shiny-cities-doubt.md new file mode 100644 index 00000000..eded5a7c --- /dev/null +++ b/.changeset/shiny-cities-doubt.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Bug fix for the isMacOSOrLinux() function in the webview-ui/ code for the extension. diff --git a/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx b/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx index 4323444f..030e9bdf 100644 --- a/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx +++ b/webview-ui/src/components/chat/chat-view/components/layout/WelcomeSection.tsx @@ -15,7 +15,7 @@ import { PLATFORM_CONFIG, PlatformType } from "@/config/platform.config" import { useClineAuth } from "@/context/ClineAuthContext" import { useExtensionState } from "@/context/ExtensionStateContext" import { AccountServiceClient, StateServiceClient } from "@/services/grpc-client" -import { isMacOSOrLinux } from "@/utils/platformUtils" +import { useIsMacOSOrLinux } from "@/utils/platformUtils" import { WelcomeSectionProps } from "../../types/chatTypes" /** @@ -39,9 +39,11 @@ export const WelcomeSection: React.FC = ({ const shouldShowInfoBanner = lastDismissedInfoBannerVersion < CURRENT_INFO_BANNER_VERSION const shouldShowNewModelBanner = lastDismissedModelBannerVersion < CURRENT_MODEL_BANNER_VERSION + const isMacOSOrLinux = useIsMacOSOrLinux() + // Show CLI banner if not dismissed and platform is VSCode (not JetBrains/standalone) const shouldShowCliBanner = - isMacOSOrLinux() && + isMacOSOrLinux && PLATFORM_CONFIG.type === PlatformType.VSCODE && lastDismissedCliBannerVersion < CURRENT_CLI_BANNER_VERSION @@ -149,8 +151,8 @@ export const WelcomeSection: React.FC = ({ banners.push({ id: "cli-install", icon: , - title: isMacOSOrLinux() ? "CLI & Subagents Available" : "Cline CLI Info", - description: isMacOSOrLinux() ? ( + title: isMacOSOrLinux ? "CLI & Subagents Available" : "Cline CLI Info", + description: isMacOSOrLinux ? ( <> Use Cline in your terminal and enable subagent capabilities.{" "} @@ -165,7 +167,7 @@ export const WelcomeSection: React.FC = ({ ), - actions: isMacOSOrLinux() + actions: isMacOSOrLinux ? [ { label: "Install", onClick: handleInstallCli, variant: "primary" }, { diff --git a/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx b/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx index 1ba5c2b8..985a03f2 100644 --- a/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx +++ b/webview-ui/src/components/cline-rules/ClineRulesToggleModal.tsx @@ -17,7 +17,7 @@ import PopupModalContainer from "@/components/common/PopupModalContainer" import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" import { useExtensionState } from "@/context/ExtensionStateContext" import { FileServiceClient } from "@/services/grpc-client" -import { isMacOSOrLinux } from "@/utils/platformUtils" +import { useIsMacOSOrLinux } from "@/utils/platformUtils" import HookRow from "./HookRow" import NewRuleRow from "./NewRuleRow" import RuleRow from "./RuleRow" @@ -51,7 +51,8 @@ const ClineRulesToggleModal: React.FC = () => { Array<{ workspaceName: string; hooks: Array<{ name: string; enabled: boolean; absolutePath: string }> }> >([]) - const isWindows = !isMacOSOrLinux() + const isMacOSOrLinux = useIsMacOSOrLinux() + const isWindows = !isMacOSOrLinux const [isVisible, setIsVisible] = useState(false) const buttonRef = useRef(null) const modalRef = useRef(null) diff --git a/webview-ui/src/components/common/CliInstallBanner.tsx b/webview-ui/src/components/common/CliInstallBanner.tsx index aca07878..7aa10688 100644 --- a/webview-ui/src/components/common/CliInstallBanner.tsx +++ b/webview-ui/src/components/common/CliInstallBanner.tsx @@ -5,13 +5,14 @@ import { useCallback, useEffect, useState } from "react" import { Button } from "@/components/ui/button" import { useExtensionState } from "@/context/ExtensionStateContext" import { StateServiceClient } from "@/services/grpc-client" -import { isMacOSOrLinux } from "@/utils/platformUtils" +import { useIsMacOSOrLinux } from "@/utils/platformUtils" import { getAsVar, VSC_INACTIVE_SELECTION_BACKGROUND } from "@/utils/vscStyles" export const CURRENT_CLI_BANNER_VERSION = 1 export const CliInstallBanner: React.FC = () => { const { navigateToSettings, subagentsEnabled } = useExtensionState() + const isMacOSOrLinux = useIsMacOSOrLinux() const [isCopied, setIsCopied] = useState(false) const [isClineCliInstalled, setIsClineCliInstalled] = useState(false) @@ -92,10 +93,10 @@ export const CliInstallBanner: React.FC = () => { }}>

- {isMacOSOrLinux() ? "Cline for CLI is here!" : "Cline CLI Information"} + {isMacOSOrLinux ? "Cline for CLI is here!" : "Cline CLI Information"}

- {isMacOSOrLinux() ? ( + {isMacOSOrLinux ? ( <> Install to use Cline directly in your terminal and enable subagent capabilities. Cline can spawn{" "} cline commands to handle focused tasks like exploring large codebases for information. This @@ -138,7 +139,7 @@ export const CliInstallBanner: React.FC = () => { - {isMacOSOrLinux() ? ( + {isMacOSOrLinux ? (

{ @@ -70,7 +71,7 @@ const FeatureSettingsSection = ({ renderSectionHeader }: FeatureSettingsSectionP
{/* Subagents - Only show on macOS and Linux */} - {isMacOSOrLinux() && PLATFORM_CONFIG.type === PlatformType.VSCODE && ( + {isMacOSOrLinux && PLATFORM_CONFIG.type === PlatformType.VSCODE && (
{ const checked = e.target.checked === true updateSetting("hooksEnabled", checked) }}> Enable Hooks - {!isMacOSOrLinux() ? ( + {!isMacOSOrLinux ? (

Hooks are not yet supported on Windows. This feature is currently available on macOS and Linux only. diff --git a/webview-ui/src/utils/platformUtils.ts b/webview-ui/src/utils/platformUtils.ts index 6bb67a74..7d39ec58 100644 --- a/webview-ui/src/utils/platformUtils.ts +++ b/webview-ui/src/utils/platformUtils.ts @@ -1,3 +1,5 @@ +import { useExtensionState } from "@/context/ExtensionStateContext" + export interface NavigatorUAData { platform: string brands: { brand: string; version: string }[] @@ -42,10 +44,10 @@ export const isChrome = userAgent.indexOf("Chrome") >= 0 export const isSafari = !isChrome && userAgent.indexOf("Safari") >= 0 /** - * Checks if the platform is macOS or Linux - * @returns true if platform is darwin (macOS) or linux + * React hook to check whether the platform is macOS or Linux + * @returns true if platform is darwin (macOS) or linux, false for Windows or unknown */ -export const isMacOSOrLinux = (): boolean => { - const platform = process?.platform - return !platform?.startsWith("win") // Non-Windows +export const useIsMacOSOrLinux = (): boolean => { + const { platform } = useExtensionState() + return platform !== "win32" && platform !== "unknown" }