From c511b91a0992d1db084c93bcc14633d3971fb6ba Mon Sep 17 00:00:00 2001 From: pashpashpash Date: Wed, 21 May 2025 23:46:24 -0700 Subject: [PATCH] New settings page, inspired by Yellow Bat and Roo <3 (#3720) * new settings view tabs * making sure things scroll * tidying up * changeset * py * bringing back mcp settings button --------- Co-authored-by: Cline Evaluation --- .changeset/brown-pugs-help.md | 5 + webview-ui/package-lock.json | 113 ++-- webview-ui/package.json | 3 + .../browser/BrowserSettingsMenu.tsx | 2 +- webview-ui/src/components/common/Tab.tsx | 93 +++ .../tabs/installed/InstalledServersView.tsx | 25 +- .../settings/BrowserSettingsSection.tsx | 6 +- .../settings/FeatureSettingsSection.tsx | 3 +- .../settings/PreferredLanguageSetting.tsx | 2 +- .../src/components/settings/Section.tsx | 10 + .../src/components/settings/SectionHeader.tsx | 25 + .../src/components/settings/SettingsView.tsx | 583 +++++++++++++----- .../settings/TerminalSettingsSection.tsx | 5 +- webview-ui/src/utils/cn.ts | 13 + 14 files changed, 668 insertions(+), 220 deletions(-) create mode 100644 .changeset/brown-pugs-help.md create mode 100644 webview-ui/src/components/common/Tab.tsx create mode 100644 webview-ui/src/components/settings/Section.tsx create mode 100644 webview-ui/src/components/settings/SectionHeader.tsx create mode 100644 webview-ui/src/utils/cn.ts diff --git a/.changeset/brown-pugs-help.md b/.changeset/brown-pugs-help.md new file mode 100644 index 00000000..16ac12f3 --- /dev/null +++ b/.changeset/brown-pugs-help.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +New settings page split into tabs diff --git a/webview-ui/package-lock.json b/webview-ui/package-lock.json index 3aa194dc..bb491134 100644 --- a/webview-ui/package-lock.json +++ b/webview-ui/package-lock.json @@ -11,6 +11,7 @@ "@floating-ui/react": "^0.27.4", "@heroui/react": "^2.8.0-beta.2", "@vscode/webview-ui-toolkit": "^1.4.0", + "clsx": "^2.1.1", "debounce": "^2.1.1", "dompurify": "^3.2.4", "fast-deep-equal": "^3.1.3", @@ -19,6 +20,7 @@ "fuse.js": "^7.0.0", "fzf": "^0.5.2", "katex": "^0.16.22", + "lucide-react": "^0.511.0", "mermaid": "^11.4.1", "package.json": "^2.0.1", "posthog-js": "^1.224.0", @@ -37,6 +39,7 @@ "remark-math": "^6.0.0", "remark-stringify": "^11.0.0", "styled-components": "^6.1.15", + "tailwind-merge": "^3.3.0", "unified": "^11.0.5", "uuid": "^9.0.1" }, @@ -2513,6 +2516,14 @@ "react": ">=18 || >=19.0.0-rc.0" } }, + "node_modules/@heroui/system-rsc/node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "engines": { + "node": ">=6" + } + }, "node_modules/@heroui/table": { "version": "2.2.17-beta.2", "resolved": "https://registry.npmjs.org/@heroui/table/-/table-2.2.17-beta.2.tgz", @@ -2590,6 +2601,23 @@ "tailwindcss": ">=4.0.0" } }, + "node_modules/@heroui/theme/node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/@heroui/theme/node_modules/tailwind-merge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.0.2.tgz", + "integrity": "sha512-l7z+OYZ7mu3DTqrL88RiKrKIqO3NcpEO8V/Od04bNpvk0kiIFndGEoqfuzvj4yuhRkHKjRkII2z+KS2HfPcSxw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, "node_modules/@heroui/toast": { "version": "2.0.8-beta.2", "resolved": "https://registry.npmjs.org/@heroui/toast/-/toast-2.0.8-beta.2.tgz", @@ -3615,15 +3643,6 @@ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, - "node_modules/@react-aria/focus/node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/@react-aria/form": { "version": "3.0.14", "resolved": "https://registry.npmjs.org/@react-aria/form/-/form-3.0.14.tgz", @@ -3839,15 +3858,6 @@ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, - "node_modules/@react-aria/grid/node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/@react-aria/i18n": { "version": "3.12.7", "resolved": "https://registry.npmjs.org/@react-aria/i18n/-/i18n-3.12.7.tgz", @@ -3970,15 +3980,6 @@ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, - "node_modules/@react-aria/landmark/node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/@react-aria/link": { "version": "3.7.10", "resolved": "https://registry.npmjs.org/@react-aria/link/-/link-3.7.10.tgz", @@ -4290,15 +4291,6 @@ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, - "node_modules/@react-aria/spinbutton/node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/@react-aria/ssr": { "version": "3.9.7", "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.7.tgz", @@ -4535,15 +4527,6 @@ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, - "node_modules/@react-aria/toggle/node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/@react-aria/toolbar": { "version": "3.0.0-beta.14", "resolved": "https://registry.npmjs.org/@react-aria/toolbar/-/toolbar-3.0.0-beta.14.tgz", @@ -4597,15 +4580,6 @@ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, - "node_modules/@react-aria/utils/node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/@react-aria/visually-hidden": { "version": "3.8.21", "resolved": "https://registry.npmjs.org/@react-aria/visually-hidden/-/visually-hidden-3.8.21.tgz", @@ -8278,10 +8252,9 @@ } }, "node_modules/clsx": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", - "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", - "license": "MIT", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", "engines": { "node": ">=6" } @@ -12487,6 +12460,14 @@ "dev": true, "license": "ISC" }, + "node_modules/lucide-react": { + "version": "0.511.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.511.0.tgz", + "integrity": "sha512-VK5a2ydJ7xm8GvBeKLS9mu1pVK6ucef9780JVUjw6bAjJL/QXnd4Y0p7SPeOUMC27YhzNCZvm5d/QX0Tp3rc0w==", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/lz-string": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", @@ -15865,10 +15846,9 @@ "license": "MIT" }, "node_modules/tailwind-merge": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.0.2.tgz", - "integrity": "sha512-l7z+OYZ7mu3DTqrL88RiKrKIqO3NcpEO8V/Od04bNpvk0kiIFndGEoqfuzvj4yuhRkHKjRkII2z+KS2HfPcSxw==", - "license": "MIT", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.3.0.tgz", + "integrity": "sha512-fyW/pEfcQSiigd5SNn0nApUOxx0zB/dm6UDU/rEwc2c3sX2smWUNbapHv+QRqLGVp9GWX3THIa7MUGPo+YkDzQ==", "funding": { "type": "github", "url": "https://github.com/sponsors/dcastil" @@ -15890,6 +15870,15 @@ "tailwindcss": "*" } }, + "node_modules/tailwind-variants/node_modules/tailwind-merge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.0.2.tgz", + "integrity": "sha512-l7z+OYZ7mu3DTqrL88RiKrKIqO3NcpEO8V/Od04bNpvk0kiIFndGEoqfuzvj4yuhRkHKjRkII2z+KS2HfPcSxw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, "node_modules/tailwindcss": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.5.tgz", diff --git a/webview-ui/package.json b/webview-ui/package.json index ed058aab..f239cd0c 100644 --- a/webview-ui/package.json +++ b/webview-ui/package.json @@ -18,6 +18,7 @@ "@floating-ui/react": "^0.27.4", "@heroui/react": "^2.8.0-beta.2", "@vscode/webview-ui-toolkit": "^1.4.0", + "clsx": "^2.1.1", "debounce": "^2.1.1", "dompurify": "^3.2.4", "fast-deep-equal": "^3.1.3", @@ -26,6 +27,7 @@ "fuse.js": "^7.0.0", "fzf": "^0.5.2", "katex": "^0.16.22", + "lucide-react": "^0.511.0", "mermaid": "^11.4.1", "package.json": "^2.0.1", "posthog-js": "^1.224.0", @@ -44,6 +46,7 @@ "remark-math": "^6.0.0", "remark-stringify": "^11.0.0", "styled-components": "^6.1.15", + "tailwind-merge": "^3.3.0", "unified": "^11.0.5", "uuid": "^9.0.1" }, diff --git a/webview-ui/src/components/browser/BrowserSettingsMenu.tsx b/webview-ui/src/components/browser/BrowserSettingsMenu.tsx index 8b69fb24..90dd372d 100644 --- a/webview-ui/src/components/browser/BrowserSettingsMenu.tsx +++ b/webview-ui/src/components/browser/BrowserSettingsMenu.tsx @@ -71,7 +71,7 @@ export const BrowserSettingsMenu = () => { // After a short delay, send a message to scroll to browser settings setTimeout(async () => { try { - await UiServiceClient.scrollToSettings({ value: "browser-settings-section" }) + await UiServiceClient.scrollToSettings({ value: "browser" }) } catch (error) { console.error("Error scrolling to browser settings:", error) } diff --git a/webview-ui/src/components/common/Tab.tsx b/webview-ui/src/components/common/Tab.tsx new file mode 100644 index 00000000..8ba8c6f6 --- /dev/null +++ b/webview-ui/src/components/common/Tab.tsx @@ -0,0 +1,93 @@ +import React, { HTMLAttributes, useCallback, forwardRef } from "react" + +import { useExtensionState } from "@/context/ExtensionStateContext" +import { cn } from "@/utils/cn" + +type TabProps = HTMLAttributes + +export const Tab = ({ className, children, ...props }: TabProps) => ( +
+ {children} +
+) + +export const TabHeader = ({ className, children, ...props }: TabProps) => ( +
+ {children} +
+) + +export const TabContent = ({ className, children, ...props }: TabProps) => { + const onWheel = useCallback((e: React.WheelEvent) => { + const target = e.target as HTMLElement + + // Prevent scrolling if the target is a listbox or option + // (e.g. selects, dropdowns, etc). + if (target.role === "listbox" || target.role === "option") { + return + } + + e.currentTarget.scrollTop += e.deltaY + }, []) + + return ( +
+ {children} +
+ ) +} + +export const TabList = forwardRef< + HTMLDivElement, + HTMLAttributes & { + value: string + onValueChange: (value: string) => void + } +>(({ children, className, value, onValueChange, ...props }, ref) => { + const handleTabSelect = useCallback( + (tabValue: string) => { + console.log("Tab selected:", tabValue) + onValueChange(tabValue) + }, + [onValueChange], + ) + + return ( +
+ {React.Children.map(children, (child) => { + if (React.isValidElement(child)) { + // Make sure we're passing the correct props to the TabTrigger + return React.cloneElement(child as React.ReactElement, { + isSelected: child.props.value === value, + onSelect: () => handleTabSelect(child.props.value), + }) + } + return child + })} +
+ ) +}) + +export const TabTrigger = forwardRef< + HTMLButtonElement, + React.ButtonHTMLAttributes & { + value: string + isSelected?: boolean + onSelect?: () => void + } +>(({ children, className, value, isSelected, onSelect, ...props }, ref) => { + // Ensure we're using the value prop correctly + return ( + + ) +}) diff --git a/webview-ui/src/components/mcp/configuration/tabs/installed/InstalledServersView.tsx b/webview-ui/src/components/mcp/configuration/tabs/installed/InstalledServersView.tsx index 52092c66..dc792743 100644 --- a/webview-ui/src/components/mcp/configuration/tabs/installed/InstalledServersView.tsx +++ b/webview-ui/src/components/mcp/configuration/tabs/installed/InstalledServersView.tsx @@ -1,9 +1,12 @@ import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react" import { vscode } from "@/utils/vscode" import { useExtensionState } from "@/context/ExtensionStateContext" + +import { UiServiceClient } from "@/services/grpc-client" + import ServersToggleList from "./ServersToggleList" const InstalledServersView = () => { - const { mcpServers: servers } = useExtensionState() + const { mcpServers: servers, navigateToSettings } = useExtensionState() return (
@@ -42,6 +45,26 @@ const InstalledServersView = () => { Configure MCP Servers + +
+ { + // First open the settings panel using direct navigation + navigateToSettings() + + // After a short delay, send a message to scroll to browser settings + setTimeout(async () => { + try { + await UiServiceClient.scrollToSettings({ value: "features" }) + } catch (error) { + console.error("Error scrolling to mcp settings:", error) + } + }, 300) + }} + style={{ fontSize: "12px" }}> + Advanced MCP Settings + +
) diff --git a/webview-ui/src/components/settings/BrowserSettingsSection.tsx b/webview-ui/src/components/settings/BrowserSettingsSection.tsx index d89be140..e37534ce 100644 --- a/webview-ui/src/components/settings/BrowserSettingsSection.tsx +++ b/webview-ui/src/components/settings/BrowserSettingsSection.tsx @@ -366,11 +366,7 @@ export const BrowserSettingsSection: React.FC = () => { const isSubSettingsOpen = !(browserSettings.disableToolUse || false) return ( -
-

Browser Settings

- +
{/* Master Toggle */}
{ } = useExtensionState() return ( -
-

Feature Settings

+
= ({ chatSettings, setChatSettings }) => { return ( -
+
diff --git a/webview-ui/src/components/settings/Section.tsx b/webview-ui/src/components/settings/Section.tsx new file mode 100644 index 00000000..cb9e859c --- /dev/null +++ b/webview-ui/src/components/settings/Section.tsx @@ -0,0 +1,10 @@ +import { HTMLAttributes } from "react" +import { cn } from "@/utils/cn" + +type SectionProps = HTMLAttributes + +export const Section = ({ className, ...props }: SectionProps) => ( +
+) + +export default Section diff --git a/webview-ui/src/components/settings/SectionHeader.tsx b/webview-ui/src/components/settings/SectionHeader.tsx new file mode 100644 index 00000000..51ccac80 --- /dev/null +++ b/webview-ui/src/components/settings/SectionHeader.tsx @@ -0,0 +1,25 @@ +import { HTMLAttributes } from "react" +import { cn } from "@/utils/cn" + +import { OPENROUTER_MODEL_PICKER_Z_INDEX } from "./OpenRouterModelPicker" + +type SectionHeaderProps = HTMLAttributes & { + children: React.ReactNode + description?: string +} + +export const SectionHeader = ({ description, children, className, ...props }: SectionHeaderProps) => { + return ( +
+

{children}

+ {description &&

{description}

} +
+ ) +} + +export default SectionHeader diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index 8f8397eb..41c9dd2c 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -6,7 +6,24 @@ import { VSCodeOption, VSCodeTextArea, } from "@vscode/webview-ui-toolkit/react" -import { memo, useCallback, useEffect, useState } from "react" +import { memo, useCallback, useEffect, useState, useRef } from "react" +import { + Settings, + Webhook, + CheckCheck, + SquareMousePointer, + GitBranch, + Bell, + Database, + SquareTerminal, + FlaskConical, + Globe, + Info, + LucideIcon, +} from "lucide-react" +import HeroTooltip from "@/components/common/HeroTooltip" +import SectionHeader from "./SectionHeader" +import Section from "./Section" import PreferredLanguageSetting from "./PreferredLanguageSetting" // Added import import { OpenAIReasoningEffort } from "@shared/ChatSettings" import { useExtensionState } from "@/context/ExtensionStateContext" @@ -22,13 +39,91 @@ import FeatureSettingsSection from "./FeatureSettingsSection" import BrowserSettingsSection from "./BrowserSettingsSection" import TerminalSettingsSection from "./TerminalSettingsSection" import { FEATURE_FLAGS } from "@shared/services/feature-flags/feature-flags" +import { Tab, TabContent, TabHeader, TabList, TabTrigger } from "../common/Tab" +import { cn } from "@/utils/cn" const { IS_DEV } = process.env +// Styles for the tab system +const settingsTabsContainer = "flex flex-1 overflow-hidden [&.narrow_.tab-label]:hidden" +const settingsTabList = + "w-48 data-[compact=true]:w-12 flex-shrink-0 flex flex-col overflow-y-auto overflow-x-hidden border-r border-[var(--vscode-sideBar-background)]" +const settingsTabTrigger = + "whitespace-nowrap overflow-hidden min-w-0 h-12 px-4 py-3 box-border flex items-center border-l-2 border-transparent text-[var(--vscode-foreground)] opacity-70 bg-transparent hover:bg-[var(--vscode-list-hoverBackground)] data-[compact=true]:w-12 data-[compact=true]:p-4 cursor-pointer" +const settingsTabTriggerActive = + "opacity-100 border-l-2 border-l-[var(--vscode-focusBorder)] border-t-0 border-r-0 border-b-0 bg-[var(--vscode-list-activeSelectionBackground)]" + +// Tab definitions +interface SettingsTab { + id: string + name: string + tooltipText: string + headerText: string + icon: LucideIcon +} + +export const SETTINGS_TABS: SettingsTab[] = [ + { + id: "api-config", + name: "API Configuration", + tooltipText: "API Configuration", + headerText: "API Configuration", + icon: Webhook, + }, + { + id: "general", + name: "General", + tooltipText: "General Settings", + headerText: "General Settings", + icon: Settings, + }, + { + id: "features", + name: "Features", + tooltipText: "Feature Settings", + headerText: "Feature Settings", + icon: CheckCheck, + }, + { + id: "browser", + name: "Browser", + tooltipText: "Browser Settings", + headerText: "Browser Settings", + icon: SquareMousePointer, + }, + { + id: "terminal", + name: "Terminal", + tooltipText: "Terminal Settings", + headerText: "Terminal Settings", + icon: SquareTerminal, + }, + // Only show in dev mode + ...(IS_DEV + ? [ + { + id: "debug", + name: "Debug", + tooltipText: "Debug Tools", + headerText: "Debug", + icon: FlaskConical, + }, + ] + : []), + { + id: "about", + name: "About", + tooltipText: "About Cline", + headerText: "About", + icon: Info, + }, +] + type SettingsViewProps = { onDone: () => void + targetSection?: string } -const SettingsView = ({ onDone }: SettingsViewProps) => { +const SettingsView = ({ onDone, targetSection }: SettingsViewProps) => { const { apiConfiguration, version, @@ -126,24 +221,35 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { setPendingTabChange(null) } break + // Handle tab navigation through targetSection prop instead case "grpc_response": if (message.grpc_response?.message?.action === "scrollToSettings") { - setTimeout(() => { - const elementId = message.grpc_response?.message?.value - if (elementId) { - const element = document.getElementById(elementId) - if (element) { - element.scrollIntoView({ behavior: "smooth" }) + const tabId = message.grpc_response?.message?.value + if (tabId) { + console.log("Opening settings tab from GRPC response:", tabId) + // Check if the value corresponds to a valid tab ID + const isValidTabId = SETTINGS_TABS.some((tab) => tab.id === tabId) - element.style.transition = "background-color 0.5s ease" - element.style.backgroundColor = "var(--vscode-textPreformat-background)" + if (isValidTabId) { + // Set the active tab directly + setActiveTab(tabId) + } else { + // Fall back to the old behavior of scrolling to an element + setTimeout(() => { + const element = document.getElementById(tabId) + if (element) { + element.scrollIntoView({ behavior: "smooth" }) - setTimeout(() => { - element.style.backgroundColor = "transparent" - }, 1200) - } + element.style.transition = "background-color 0.5s ease" + element.style.backgroundColor = "var(--vscode-textPreformat-background)" + + setTimeout(() => { + element.style.backgroundColor = "transparent" + }, 1200) + } + }, 300) } - }, 300) + } } break } @@ -161,7 +267,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { } } - const handleTabChange = (tab: "plan" | "act") => { + const handlePlanActModeChange = (tab: "plan" | "act") => { if (tab === chatSettings.mode) { return } @@ -169,136 +275,325 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { handleSubmit(true) } + // Track active tab + const [activeTab, setActiveTab] = useState(targetSection || SETTINGS_TABS[0].id) + + // Update active tab when targetSection changes + useEffect(() => { + if (targetSection) { + setActiveTab(targetSection) + } + }, [targetSection]) + + // Enhanced tab change handler with debugging + const handleTabChange = useCallback( + (tabId: string) => { + console.log("Tab change requested:", tabId, "Current:", activeTab) + setActiveTab(tabId) + }, + [activeTab], + ) + + // Debug tab changes + useEffect(() => { + console.log("Active tab changed to:", activeTab) + }, [activeTab]) + + // Track whether we're in compact mode + const [isCompactMode, setIsCompactMode] = useState(false) + const containerRef = useRef(null) + + // Setup resize observer to detect when we should switch to compact mode + useEffect(() => { + if (!containerRef.current) return + + const observer = new ResizeObserver((entries) => { + for (const entry of entries) { + // If container width is less than 500px, switch to compact mode + setIsCompactMode(entry.contentRect.width < 500) + } + }) + + observer.observe(containerRef.current) + + return () => { + observer?.disconnect() + } + }, []) + return ( -
-
-

Settings

- handleSubmit(false)}>Save + + +
+

Settings

+
+
+ handleSubmit(false)}>Save +
+
+ + {/* Vertical tabs layout */} +
+ {/* Tab sidebar */} + + {SETTINGS_TABS.map((tab) => + isCompactMode ? ( + +
{ + console.log("Compact tab clicked:", tab.id) + handleTabChange(tab.id) + }}> +
+ + {tab.name} +
+
+
+ ) : ( + +
+ + {tab.name} +
+
+ ), + )} +
+ + {/* Helper function to render section header */} + {(() => { + const renderSectionHeader = (tabId: string) => { + const tab = SETTINGS_TABS.find((t) => t.id === tabId) + if (!tab) return null + + return ( + +
+ {(() => { + const Icon = tab.icon + return + })()} +
{tab.headerText}
+
+
+ ) + } + + return ( + + {/* API Configuration Tab */} + {activeTab === "api-config" && ( +
+ {renderSectionHeader("api-config")} +
+ {/* Tabs container */} + {planActSeparateModelsSetting ? ( +
+
+ handlePlanActModeChange("plan")}> + Plan Mode + + handlePlanActModeChange("act")}> + Act Mode + +
+ + {/* Content container */} +
+ +
+
+ ) : ( + + )} + +
+ { + const checked = e.target.checked === true + setPlanActSeparateModelsSetting(checked) + }}> + Use different models for Plan and Act modes + +

+ 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. +

+
+ +
+ setCustomInstructions(e.target?.value ?? "")}> + Custom Instructions + +

+ These instructions are added to the end of the system prompt sent with every + request. +

+
+
+
+ )} + + {/* General Settings Tab */} + {activeTab === "general" && ( +
+ {renderSectionHeader("general")} +
+ {chatSettings && ( + + )} + +
+ { + const checked = e.target.checked === true + setTelemetrySetting(checked ? "enabled" : "disabled") + }}> + Allow anonymous error and usage reporting + +

+ Help improve Cline by sending anonymous usage data and error reports. No code, + prompts, or personal information are ever sent. See our{" "} + + telemetry overview + {" "} + and{" "} + + privacy policy + {" "} + for more details. +

+
+
+
+ )} + + {/* Feature Settings Tab */} + {activeTab === "features" && ( +
+ {renderSectionHeader("features")} +
+ +
+
+ )} + + {/* Browser Settings Tab */} + {activeTab === "browser" && ( +
+ {renderSectionHeader("browser")} +
+ +
+
+ )} + + {/* Terminal Settings Tab */} + {activeTab === "terminal" && ( +
+ {renderSectionHeader("terminal")} +
+ +
+
+ )} + + {/* Debug Tab (only in dev mode) */} + {IS_DEV && activeTab === "debug" && ( +
+ {renderSectionHeader("debug")} +
+ + Reset State + +

+ This will reset all global state and secret storage in the extension. +

+
+
+ )} + + {/* About Tab */} + {activeTab === "about" && ( +
+ {renderSectionHeader("about")} +
+
+

+ If you have any questions or feedback, feel free to open an issue at{" "} + + https://github.com/cline/cline + +

+

v{version}

+
+
+
+ )} +
+ ) + })()}
-
- {/* Tabs container */} - {planActSeparateModelsSetting ? ( -
-
- handleTabChange("plan")}> - Plan Mode - - handleTabChange("act")}> - Act Mode - -
- - {/* Content container */} -
- -
-
- ) : ( - - )} - -
- setCustomInstructions(e.target?.value ?? "")}> - Custom Instructions - -

- These instructions are added to the end of the system prompt sent with every request. -

-
- - {chatSettings && } - -
- { - const checked = e.target.checked === true - setPlanActSeparateModelsSetting(checked) - }}> - Use different models for Plan and Act modes - -

- 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. -

-
- -
- { - const checked = e.target.checked === true - setTelemetrySetting(checked ? "enabled" : "disabled") - }}> - Allow anonymous error and usage reporting - -

- Help improve Cline by sending anonymous usage data and error reports. No code, prompts, or personal - information are ever sent. See our{" "} - - telemetry overview - {" "} - and{" "} - - privacy policy - {" "} - for more details. -

-
- - {/* Feature Settings Section */} - - - {/* Browser Settings Section */} - - - {/* Terminal Settings Section */} - - - {IS_DEV && ( - <> -
Debug
- - Reset State - -

- This will reset all global state and secret storage in the extension. -

- - )} - -
-

- If you have any questions or feedback, feel free to open an issue at{" "} - - https://github.com/cline/cline - -

-

v{version}

-
-
-
+ ) } diff --git a/webview-ui/src/components/settings/TerminalSettingsSection.tsx b/webview-ui/src/components/settings/TerminalSettingsSection.tsx index cedd81ba..e1730189 100644 --- a/webview-ui/src/components/settings/TerminalSettingsSection.tsx +++ b/webview-ui/src/components/settings/TerminalSettingsSection.tsx @@ -49,10 +49,7 @@ export const TerminalSettingsSection: React.FC = () => { } return ( -
-

Terminal Settings

+