From 3dd8b92e3072cd0e4a9b9c0c12107c09d288c55e Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 12 Aug 2025 19:15:20 -0400 Subject: [PATCH 01/68] feat: improve settings UI --- gui/src/components/gui/NumberInput.tsx | 2 +- gui/src/components/gui/Select.tsx | 12 ++++++++---- gui/src/components/gui/Switch.tsx | 2 +- gui/src/components/index.ts | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gui/src/components/gui/NumberInput.tsx b/gui/src/components/gui/NumberInput.tsx index fa622d5e5..16e70ba6f 100644 --- a/gui/src/components/gui/NumberInput.tsx +++ b/gui/src/components/gui/NumberInput.tsx @@ -51,7 +51,7 @@ const NumberInput: React.FC = ({ }; return ( -
+
> = ( > - handleUpdate({ - useAutocompleteMultilineCompletions: e.target.value as - | "auto" - | "always" - | "never", - }) - } - > - - - - - - - -
{ - e.preventDefault(); - handleDisableAutocompleteSubmit(); - }} - > -
- - Disable autocomplete in files - - - - -
- { - setFormDisableAutocomplete(e.target.value); - }} - /> -
- {formDisableAutocomplete !== disableAutocompleteInFiles ? ( - <> -
- -
-
- -
- - ) : ( -
- -
- )} -
-
-
- - Comma-separated list of path matchers - -
-
- -
-
setShowExperimental(!showExperimental)} - > - - Experimental Settings -
-
-
- - handleUpdate({ - autoAcceptEditToolDiffs: !autoAcceptEditToolDiffs, - }) - } - text="Auto-Accept Agent Edits" - tooltip="If on, diffs generated by the edit tool are - automatically accepted and Agent proceeds with the next conversational turn." - showIfToggled={ - <> - - - - - } - /> - - - handleUpdate({ - useCurrentFileAsContext: !useCurrentFileAsContext, - }) - } - text="Add Current File by Default" - tooltip="If on, the currently open file is added as context in every new conversation." - /> - - - handleUpdate({ - enableExperimentalTools: !enableExperimentalTools, - }) - } - text="Enable experimental tools" - /> - - - handleUpdate({ - onlyUseSystemMessageTools: !onlyUseSystemMessageTools, - }) - } - tooltip="If on, Continue will not attempt to use native tool calling and will only use system message tools." - text="Only use system message tools" - /> - - - handleUpdate({ - codebaseToolCallingOnly: !codebaseToolCallingOnly, - }) - } - text="@Codebase: use tool calling only" - /> - - - handleUpdate({ - continueAfterToolRejection: !continueAfterToolRejection, - }) - } - text="Stream after tool rejection" - tooltip="If on, streaming will continue after the tool call is rejected." - /> - - {hasContinueEmail && ( - - )} -
-
-
-
- ) : null} - - ); -} diff --git a/gui/src/pages/config/ConfigItemSelect.tsx b/gui/src/pages/config/components/ConfigItemSelect.tsx similarity index 97% rename from gui/src/pages/config/ConfigItemSelect.tsx rename to gui/src/pages/config/components/ConfigItemSelect.tsx index 320ea8cf7..dfd57102f 100644 --- a/gui/src/pages/config/ConfigItemSelect.tsx +++ b/gui/src/pages/config/components/ConfigItemSelect.tsx @@ -17,8 +17,8 @@ import { PopoverButton, PopoverPanel, Transition, -} from "../../components/ui"; -import { fontSize } from "../../util"; +} from "../../../components/ui"; +import { fontSize } from "../../../util"; export function ConfigItemSelect({ items, diff --git a/gui/src/pages/config/components/ConfigRow.tsx b/gui/src/pages/config/components/ConfigRow.tsx new file mode 100644 index 000000000..2d4816663 --- /dev/null +++ b/gui/src/pages/config/components/ConfigRow.tsx @@ -0,0 +1,49 @@ +import React from "react"; + +export interface ConfigRowProps { + title: string; + description: string; + icon?: React.ComponentType>; + onClick?: () => void; + disabled?: boolean; + children?: React.ReactNode; + className?: string; +} + +export function ConfigRow({ + title, + description, + icon: Icon, + onClick, + disabled = false, + children, + className = "", +}: ConfigRowProps) { + const baseClasses = `flex items-start justify-between rounded-md transition-colors ${className}`; + const interactiveClasses = onClick + ? "hover:bg-vsc-editor-background/50 cursor-pointer" + : ""; + const disabledClasses = disabled ? "opacity-50 cursor-not-allowed" : ""; + + const handleClick = () => { + if (!disabled && onClick) { + onClick(); + } + }; + + return ( +
+
+ {title} +

{description}

+
+
+ {children} + {Icon && } +
+
+ ); +} \ No newline at end of file diff --git a/gui/src/pages/config/ModelRoleSelector.tsx b/gui/src/pages/config/components/ModelRoleSelector.tsx similarity index 60% rename from gui/src/pages/config/ModelRoleSelector.tsx rename to gui/src/pages/config/components/ModelRoleSelector.tsx index a19f7e533..2ff0267e7 100644 --- a/gui/src/pages/config/ModelRoleSelector.tsx +++ b/gui/src/pages/config/components/ModelRoleSelector.tsx @@ -1,23 +1,22 @@ import { CheckIcon, ChevronUpDownIcon, - Cog6ToothIcon, CubeIcon, } from "@heroicons/react/24/outline"; import { ModelDescription } from "core"; import { LLMConfigurationStatuses } from "core/llm/constants"; import { MouseEvent, useContext, useState } from "react"; -import { defaultBorderRadius } from "../../components"; -import InfoHover from "../../components/InfoHover"; +import { defaultBorderRadius } from "../../../components"; +import InfoHover from "../../../components/InfoHover"; import { Listbox, ListboxButton, ListboxOption, ListboxOptions, Transition, -} from "../../components/ui"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { fontSize } from "../../util"; +} from "../../../components/ui"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { fontSize } from "../../../util"; interface ModelRoleSelectorProps { models: ModelDescription[]; @@ -26,6 +25,7 @@ interface ModelRoleSelectorProps { displayName: string; description: string; setupURL: string; + hideTitle?: boolean; } const ModelRoleSelector = ({ @@ -35,9 +35,9 @@ const ModelRoleSelector = ({ displayName, description, setupURL, + hideTitle = false, }: ModelRoleSelectorProps) => { const ideMessenger = useContext(IdeMessengerContext); - const [hoveredIdx, setHoveredIdx] = useState(null); const noConfiguredModels = models.every( (model) => model.configurationStatus !== LLMConfigurationStatuses.VALID, @@ -47,14 +47,6 @@ const ModelRoleSelector = ({ onSelect(models.find((m) => m.title === title) ?? null); } - function onClickGear(e: MouseEvent, model: ModelDescription) { - e.stopPropagation(); - e.preventDefault(); - ideMessenger.post("config/openProfile", { - profileId: undefined, - element: model, - }); - } function handleOptionClick( showMissingApiKeyMsg: boolean, @@ -68,19 +60,21 @@ const ModelRoleSelector = ({ return ( <> -
- {displayName} - -
+ {!hideTitle && ( +
+ {displayName} + +
+ )}
{models.length === 0 ? ( ideMessenger.post("openUrl", setupURL)} - className="bg-vsc-editor-background hover:bg-list-active hover:text-list-active-foreground text-description w-full justify-between px-2 py-1 underline hover:underline" + className="bg-input border-input-border hover:bg-list-active hover:text-list-active-foreground text-description w-full justify-between rounded border px-3 py-2 underline hover:underline" > - + Setup {displayName} model @@ -88,7 +82,7 @@ const ModelRoleSelector = ({ <> {models.length === 0 || noConfiguredModels ? ( @@ -99,7 +93,10 @@ const ModelRoleSelector = ({ }`} ) : ( - + {selectedModel?.title ?? `Select ${displayName} model`} )} @@ -140,43 +137,31 @@ const ModelRoleSelector = ({ key={idx} value={option.title} disabled={isConfigInvalid} - onMouseEnter={() => setHoveredIdx(idx)} - onMouseLeave={() => setHoveredIdx(null)} onClick={(e: any) => handleOptionClick(isConfigInvalid, e) } className="" > -
-
-
- - - {option.title} - {isConfigInvalid && ( - - {invalidMessage} - - )} - -
+
+
+ + + {option.title} + {isConfigInvalid && ( + + {invalidMessage} + + )} + +
-
- {hoveredIdx === idx && ( - ) => - onClickGear(e, option) - } - /> - )} - {option.title === selectedModel?.title && ( - - )} -
+
+ {option.title === selectedModel?.title && ( + + )}
diff --git a/gui/src/pages/config/components/UserSetting.tsx b/gui/src/pages/config/components/UserSetting.tsx new file mode 100644 index 000000000..76dd01b9c --- /dev/null +++ b/gui/src/pages/config/components/UserSetting.tsx @@ -0,0 +1,165 @@ +import React from "react"; +import NumberInput from "../../../components/gui/NumberInput"; +import ToggleSwitch from "../../../components/gui/Switch"; +import { Input } from "../../../components"; +import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../../../components/ui/Listbox"; +import { ChevronDownIcon, CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; + +interface BaseUserSettingProps { + title: string; + description: string; + disabled?: boolean; +} + +interface ToggleUserSettingProps extends BaseUserSettingProps { + type: "toggle"; + value: boolean; + onChange: (value: boolean) => void; +} + +interface NumberUserSettingProps extends BaseUserSettingProps { + type: "number"; + value: number; + onChange: (value: number) => void; + min?: number; + max?: number; +} + +interface SelectUserSettingProps extends BaseUserSettingProps { + type: "select"; + value: string; + onChange: (value: string) => void; + options: { label: string; value: string }[]; +} + +interface InputUserSettingProps extends BaseUserSettingProps { + type: "input"; + value: string; + onChange: (value: string) => void; + className?: string; + onSubmit?: () => void; + onCancel?: () => void; + isDirty?: boolean; + isValid?: boolean; +} + +type UserSettingProps = ToggleUserSettingProps | NumberUserSettingProps | SelectUserSettingProps | InputUserSettingProps; + +export function UserSetting(props: UserSettingProps) { + const { title, description, disabled = false } = props; + + const renderControl = () => { + switch (props.type) { + case "toggle": + return ( + props.onChange(!props.value)} + text="" + /> + ); + + case "number": + return ( + + ); + + case "select": + return ( + + + {props.options.find(opt => opt.value === props.value)?.label || props.value} + + + + {props.options.map(option => ( + + {option.label} + + ))} + + + ); + + case "input": + if (props.onSubmit) { + return ( +
{ + e.preventDefault(); + props.onSubmit?.(); + }} + > +
+ props.onChange(e.target.value)} + disabled={disabled} + /> +
+ {props.isDirty ? ( + <> +
+ +
+
+ +
+ + ) : ( +
+ +
+ )} +
+
+
+ ); + } + return ( + props.onChange(e.target.value)} + className={props.className} + disabled={disabled} + /> + ); + + default: + return null; + } + }; + + return ( +
+
+ {title} +

{description}

+
+ {renderControl()} +
+ ); +} \ No newline at end of file diff --git a/gui/src/pages/config/TabButton.tsx b/gui/src/pages/config/components/ui/TabButton.tsx similarity index 53% rename from gui/src/pages/config/TabButton.tsx rename to gui/src/pages/config/components/ui/TabButton.tsx index c2df11dd4..847fa5578 100644 --- a/gui/src/pages/config/TabButton.tsx +++ b/gui/src/pages/config/components/ui/TabButton.tsx @@ -1,5 +1,4 @@ -import { ToolTip } from "../../components/gui/Tooltip"; -import { fontSize } from "../../util"; +import { ToolTip } from "../../../../components/gui/Tooltip"; interface TabButtonProps { id: string; @@ -9,18 +8,16 @@ interface TabButtonProps { onClick: () => void; } -export function TabButton({ id, label, icon, isActive, onClick }: TabButtonProps) { +export function TabButton({ + id, + label, + icon, + isActive, + onClick, +}: TabButtonProps) { return ( - +
{icon} - {label} + {label}
); -} \ No newline at end of file +} diff --git a/gui/src/pages/config/TabGroup.tsx b/gui/src/pages/config/components/ui/TabGroup.tsx similarity index 72% rename from gui/src/pages/config/TabGroup.tsx rename to gui/src/pages/config/components/ui/TabGroup.tsx index b651768cd..457102381 100644 --- a/gui/src/pages/config/TabGroup.tsx +++ b/gui/src/pages/config/components/ui/TabGroup.tsx @@ -1,3 +1,4 @@ +import { Divider } from "../../../../components/ui/Divider"; import { TabButton } from "./TabButton"; interface TabOption { @@ -28,12 +29,10 @@ export function TabGroup({ }: TabGroupProps) { return (
- {showTopDivider && ( -
- )} + {showTopDivider && } {label && ( -
+
{label}
)} @@ -49,9 +48,7 @@ export function TabGroup({ /> ))} - {showBottomDivider && ( -
- )} + {showBottomDivider && }
); } diff --git a/gui/src/pages/config/configTabs.tsx b/gui/src/pages/config/configTabs.tsx index b1dac11c1..21ab035ce 100644 --- a/gui/src/pages/config/configTabs.tsx +++ b/gui/src/pages/config/configTabs.tsx @@ -1,5 +1,6 @@ import { ArrowLeftIcon, + ChatBubbleLeftRightIcon, CircleStackIcon, Cog6ToothIcon, CubeIcon, @@ -8,15 +9,14 @@ import { Squares2X2Icon, WrenchScrewdriverIcon, } from "@heroicons/react/24/outline"; -import { UserCircleIcon } from "@heroicons/react/24/solid"; -import MCPSection from "../../components/mainInput/Lump/sections/mcp/MCPSection"; -import { ModelsSection } from "../../components/mainInput/Lump/sections/ModelsSection"; -import { RulesSection } from "../../components/mainInput/Lump/sections/RulesSection"; -import { ToolPoliciesSection } from "../../components/mainInput/Lump/sections/tool-policies/ToolPoliciesSection"; -import { AccountSection } from "./AccountSection"; -import { HelpCenterSection } from "./HelpCenterSection"; -import { IndexingSettingsSection } from "./IndexingSettingsSection"; -import { UserSettingsForm } from "./UserSettingsForm"; +import { HelpSection } from "./sections/HelpSection"; +import { IndexingSettingsSection } from "./sections/IndexingSettingsSection"; +import { McpSection } from "./sections/McpSection"; +import { ModelsSection } from "./sections/ModelsSection"; +import { PromptsSection } from "./sections/PromptsSection"; +import { RulesSection } from "./sections/RulesSection"; +import { ToolPoliciesSection } from "./sections/ToolPoliciesSection"; +import { UserSettingsSection } from "./sections/UserSettingsSection"; interface TabOption { id: string; @@ -44,14 +44,6 @@ export const topTabSections: TabSection[] = [ component:
, icon: , }, - { - id: "account", - label: "Account", - component: , - icon: ( - - ), - }, ], }, { @@ -64,7 +56,6 @@ export const topTabSections: TabSection[] = [ label: "Models", component: (
-

Models

), @@ -75,16 +66,27 @@ export const topTabSections: TabSection[] = [ label: "Rules", component: (
-

Rules

), icon: , }, + { + id: "prompts", + label: "Prompts", + component: ( +
+ +
+ ), + icon: ( + + ), + }, { id: "mcp", label: "MCP", - component: , + component: , icon: ( ), @@ -94,7 +96,6 @@ export const topTabSections: TabSection[] = [ label: "Tools", component: (
-

Tool Policies

), @@ -127,13 +128,17 @@ export const bottomTabSections: TabSection[] = [ { id: "settings", label: "Settings", - component: , + component: , icon: , }, { id: "help", label: "Help", - component: , + component: ( +
+ +
+ ), icon: ( ), diff --git a/gui/src/pages/config/features/account/AccountDropdown.tsx b/gui/src/pages/config/features/account/AccountDropdown.tsx new file mode 100644 index 000000000..020463218 --- /dev/null +++ b/gui/src/pages/config/features/account/AccountDropdown.tsx @@ -0,0 +1,159 @@ +import { + ArrowRightStartOnRectangleIcon, + Cog6ToothIcon, +} from "@heroicons/react/24/outline"; +import { UserCircleIcon } from "@heroicons/react/24/solid"; +import { isOnPremSession } from "core/control-plane/AuthTypes"; +import { useContext, useEffect, useState } from "react"; +import { + Listbox, + ListboxButton, + ListboxOption, + ListboxOptions, +} from "../../../../components/ui"; +import { Divider } from "../../../../components/ui/Divider"; +import { useAuth } from "../../../../context/Auth"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; + +interface FreeTrialStatus { + optedInToFreeTrial: boolean; + chatCount?: number; + autocompleteCount?: number; + chatLimit: number; + autocompleteLimit: number; +} + +export function AccountDropdown() { + const { session, logout } = useAuth(); + const ideMessenger = useContext(IdeMessengerContext); + const [freeTrialStatus, setFreeTrialStatus] = + useState(null); + + useEffect(() => { + const fetchFreeTrialStatus = async () => { + if (session && !isOnPremSession(session)) { + try { + const response = await ideMessenger.request( + "controlPlane/getFreeTrialStatus", + undefined, + ); + if (response.status === "success") { + setFreeTrialStatus(response.content); + } else { + console.error("Failed to fetch free trial status:", response.error); + } + } catch (error) { + console.error("Failed to fetch free trial status:", error); + } + } + }; + + void fetchFreeTrialStatus(); + }, [session, ideMessenger]); + + const getUpgradeInfo = () => { + if (!freeTrialStatus) { + return { + title: "Upgrade to Pro", + description: + "Get everything in Hobby, plus unlimited completions, MAX Mode, and more", + }; + } + + if (freeTrialStatus.optedInToFreeTrial) { + const chatUsed = freeTrialStatus.chatCount ?? 0; + const chatLimit = freeTrialStatus.chatLimit; + const isNearLimit = chatUsed / chatLimit > 0.8; + + if (isNearLimit) { + return { + title: "Upgrade to Models Add-On", + description: `You've used ${chatUsed}/${chatLimit} free trial requests. Upgrade for unlimited usage`, + }; + } else { + return { + title: "Upgrade to Models Add-On", + description: + "Get unlimited chat requests and autocomplete suggestions", + }; + } + } + + return { + title: "Upgrade to Pro", + description: + "Get everything in Hobby, plus unlimited completions, MAX Mode, and more", + }; + }; + + if (!session || isOnPremSession(session)) { + return null; + } + + return ( +
+ + {({ open }) => ( + <> + + +
+ + {session.account.label} + + + {session.account.id} + +
+
+ + {/* Account info section for small screens */} +
+
+ +
+ + {session.account.label} + + + {session.account.id} + +
+
+ +
+ + + ideMessenger.post( + "openUrl", + "https://hub.continue.dev/settings", + ) + } + value="manage-account" + > +
+ + Manage Account +
+
+ + +
+ + Logout +
+
+
+ + )} +
+
+ ); +} diff --git a/gui/src/pages/config/IndexingProgress/IndexingProgress.tsx b/gui/src/pages/config/features/indexing/IndexingProgress.tsx similarity index 91% rename from gui/src/pages/config/IndexingProgress/IndexingProgress.tsx rename to gui/src/pages/config/features/indexing/IndexingProgress.tsx index abe4de39d..6b0cb2069 100644 --- a/gui/src/pages/config/IndexingProgress/IndexingProgress.tsx +++ b/gui/src/pages/config/features/indexing/IndexingProgress.tsx @@ -3,11 +3,11 @@ import { usePostHog } from "posthog-js/react"; import { useContext, useEffect, useState } from "react"; import { useDispatch } from "react-redux"; -import ConfirmationDialog from "../../../components/dialogs/ConfirmationDialog"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { useWebviewListener } from "../../../hooks/useWebviewListener"; -import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; -import { isJetBrains } from "../../../util"; +import ConfirmationDialog from "../../../../components/dialogs/ConfirmationDialog"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; +import { useWebviewListener } from "../../../../hooks/useWebviewListener"; +import { setDialogMessage, setShowDialog } from "../../../../redux/slices/uiSlice"; +import { isJetBrains } from "../../../../util"; import IndexingProgressBar from "./IndexingProgressBar"; import IndexingProgressErrorText from "./IndexingProgressErrorText"; import IndexingProgressIndicator from "./IndexingProgressIndicator"; diff --git a/gui/src/pages/config/IndexingProgress/IndexingProgressBar.tsx b/gui/src/pages/config/features/indexing/IndexingProgressBar.tsx similarity index 100% rename from gui/src/pages/config/IndexingProgress/IndexingProgressBar.tsx rename to gui/src/pages/config/features/indexing/IndexingProgressBar.tsx diff --git a/gui/src/pages/config/IndexingProgress/IndexingProgressErrorText.tsx b/gui/src/pages/config/features/indexing/IndexingProgressErrorText.tsx similarity index 95% rename from gui/src/pages/config/IndexingProgress/IndexingProgressErrorText.tsx rename to gui/src/pages/config/features/indexing/IndexingProgressErrorText.tsx index 09b06b758..8226a01d9 100644 --- a/gui/src/pages/config/IndexingProgress/IndexingProgressErrorText.tsx +++ b/gui/src/pages/config/features/indexing/IndexingProgressErrorText.tsx @@ -6,9 +6,9 @@ import { } from "@heroicons/react/24/outline"; import { IndexingProgressUpdate } from "core"; import { useContext, useState } from "react"; -import { GhostButton } from "../../../components"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { useAppSelector } from "../../../redux/hooks"; +import { GhostButton } from "../../../../components"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; +import { useAppSelector } from "../../../../redux/hooks"; export interface IndexingProgressErrorTextProps { update: IndexingProgressUpdate; diff --git a/gui/src/pages/config/IndexingProgress/IndexingProgressIndicator.tsx b/gui/src/pages/config/features/indexing/IndexingProgressIndicator.tsx similarity index 100% rename from gui/src/pages/config/IndexingProgress/IndexingProgressIndicator.tsx rename to gui/src/pages/config/features/indexing/IndexingProgressIndicator.tsx diff --git a/gui/src/pages/config/IndexingProgress/IndexingProgressSubtext.tsx b/gui/src/pages/config/features/indexing/IndexingProgressSubtext.tsx similarity index 100% rename from gui/src/pages/config/IndexingProgress/IndexingProgressSubtext.tsx rename to gui/src/pages/config/features/indexing/IndexingProgressSubtext.tsx diff --git a/gui/src/pages/config/IndexingProgress/IndexingProgressTitleText.tsx b/gui/src/pages/config/features/indexing/IndexingProgressTitleText.tsx similarity index 91% rename from gui/src/pages/config/IndexingProgress/IndexingProgressTitleText.tsx rename to gui/src/pages/config/features/indexing/IndexingProgressTitleText.tsx index e339399af..7a7a6b288 100644 --- a/gui/src/pages/config/IndexingProgress/IndexingProgressTitleText.tsx +++ b/gui/src/pages/config/features/indexing/IndexingProgressTitleText.tsx @@ -1,5 +1,5 @@ import { IndexingProgressUpdate } from "core"; -import { AnimatedEllipsis } from "../../../components/AnimatedEllipsis"; +import { AnimatedEllipsis } from "../../../../components/AnimatedEllipsis"; export interface IndexingProgressTitleTextProps { update: IndexingProgressUpdate; diff --git a/gui/src/pages/config/IndexingProgress/index.ts b/gui/src/pages/config/features/indexing/index.ts similarity index 100% rename from gui/src/pages/config/IndexingProgress/index.ts rename to gui/src/pages/config/features/indexing/index.ts diff --git a/gui/src/pages/config/KeyboardShortcuts.tsx b/gui/src/pages/config/features/keyboard/KeyboardShortcuts.tsx similarity index 97% rename from gui/src/pages/config/KeyboardShortcuts.tsx rename to gui/src/pages/config/features/keyboard/KeyboardShortcuts.tsx index f0d263e75..8c9bdd84b 100644 --- a/gui/src/pages/config/KeyboardShortcuts.tsx +++ b/gui/src/pages/config/features/keyboard/KeyboardShortcuts.tsx @@ -1,6 +1,6 @@ import { useMemo } from "react"; -import Shortcut from "../../components/gui/Shortcut"; -import { isJetBrains } from "../../util"; +import Shortcut from "../../../../components/gui/Shortcut"; +import { isJetBrains } from "../../../../util"; interface KeyboardShortcutProps { shortcut: string; diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index 076832bd2..1eeaed6c7 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -1,15 +1,32 @@ -import { useState } from "react"; -import { useNavigate } from "react-router-dom"; +import { isOnPremSession } from "core/control-plane/AuthTypes"; +import { useEffect, useState } from "react"; +import { useNavigate, useSearchParams } from "react-router-dom"; +import { ScopeSelect } from "../../components/AssistantAndOrgListbox/ScopeSelect"; +import { Divider } from "../../components/ui/Divider"; +import { useAuth } from "../../context/Auth"; import { useNavigationListener } from "../../hooks/useNavigationListener"; import { bottomTabSections, getAllTabs, topTabSections } from "./configTabs"; -import { TabGroup } from "./TabGroup"; +import { TabGroup } from "./components/ui/TabGroup"; +import { AccountDropdown } from "./features/account/AccountDropdown"; function ConfigPage() { useNavigationListener(); const navigate = useNavigate(); + const [searchParams] = useSearchParams(); const [activeTab, setActiveTab] = useState("settings"); + const { session, organizations } = useAuth(); + + // Set initial tab from URL parameter + useEffect(() => { + const tab = searchParams.get("tab"); + if (tab) { + setActiveTab(tab); + } + }, [searchParams]); const allTabs = getAllTabs(); + const shouldRenderOrgInfo = + session && organizations.length > 1 && !isOnPremSession(session); const handleTabClick = (tabId: string) => { if (tabId === "back") { @@ -22,24 +39,31 @@ function ConfigPage() { return (
{/* Vertical Sidebar - full height */} -
+
- {topTabSections.map((section) => ( - + {topTabSections.map((section, index) => ( + <> + + {index === 0 && shouldRenderOrgInfo && ( + <> + + + + )} + ))}
-
{bottomTabSections.map((section) => ( ))} + + + +
diff --git a/gui/src/pages/config/sections/HelpSection.tsx b/gui/src/pages/config/sections/HelpSection.tsx new file mode 100644 index 000000000..494b03f89 --- /dev/null +++ b/gui/src/pages/config/sections/HelpSection.tsx @@ -0,0 +1,306 @@ +import { + DocumentArrowUpIcon, + LinkIcon, + NumberedListIcon, + PaintBrushIcon, + TableCellsIcon, +} from "@heroicons/react/24/outline"; +import { useContext, useMemo } from "react"; +import { useNavigate } from "react-router-dom"; +import Shortcut from "../../../components/gui/Shortcut"; +import { Card } from "../../../components/ui"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { setOnboardingCard } from "../../../redux/slices/uiSlice"; +import { saveCurrentSession } from "../../../redux/thunks/session"; +import { isJetBrains } from "../../../util"; +import { ROUTES } from "../../../util/navigation"; +import { ConfigHeader } from "../ConfigHeader"; +import { ConfigRow } from "../components/ConfigRow"; + +interface KeyboardShortcutProps { + shortcut: string; + description: string; + isEven: boolean; +} + +function KeyboardShortcut(props: KeyboardShortcutProps) { + return ( +
+
+ {props.description}: +
+
+ {props.shortcut} +
+
+ ); +} + + +// Shortcut strings will be rendered correctly based on the platform by the Shortcut component +const vscodeShortcuts: Omit[] = [ + { + shortcut: "cmd '", + description: "Toggle Selected Model", + }, + { + shortcut: "cmd I", + description: "Edit highlighted code", + }, + { + shortcut: "cmd L", + description: + "New Chat / New Chat With Selected Code / Close Continue Sidebar If Chat Already In Focus", + }, + { + shortcut: "cmd backspace", + description: "Cancel response", + }, + { + shortcut: "cmd shift I", + description: "Toggle inline edit focus", + }, + { + shortcut: "cmd shift L", + description: + "Focus Current Chat / Add Selected Code To Current Chat / Close Continue Sidebar If Chat Already In Focus", + }, + { + shortcut: "cmd shift R", + description: "Debug Terminal", + }, + { + shortcut: "cmd shift backspace", + description: "Reject Diff", + }, + { + shortcut: "cmd shift enter", + description: "Accept Diff", + }, + { + shortcut: "alt cmd N", + description: "Reject Top Change in Diff", + }, + { + shortcut: "alt cmd Y", + description: "Accept Top Change in Diff", + }, + { + shortcut: "cmd K cmd A", + description: "Toggle Autocomplete Enabled", + }, + { + shortcut: "cmd alt space", + description: "Force an Autocomplete Trigger", + }, + { + shortcut: "cmd K cmd M", + description: "Toggle Full Screen", + }, +]; + +const jetbrainsShortcuts: Omit[] = [ + { + shortcut: "cmd '", + description: "Toggle Selected Model", + }, + { + shortcut: "cmd I", + description: "Edit highlighted code", + }, + { + shortcut: "cmd J", + description: + "New Chat / New Chat With Selected Code / Close Continue Sidebar If Chat Already In Focus", + }, + { + shortcut: "cmd backspace", + description: "Cancel response", + }, + { + shortcut: "cmd shift I", + description: "Toggle inline edit focus", + }, + { + shortcut: "cmd shift J", + description: + "Focus Current Chat / Add Selected Code To Current Chat / Close Continue Sidebar If Chat Already In Focus", + }, + { + shortcut: "cmd shift backspace", + description: "Reject Diff", + }, + { + shortcut: "cmd shift enter", + description: "Accept Diff", + }, + { + shortcut: "alt shift J", + description: "Quick Input", + }, + { + shortcut: "alt cmd J", + description: "Toggle Sidebar", + }, +]; + +export function HelpSection() { + const ideMessenger = useContext(IdeMessengerContext); + const navigate = useNavigate(); + const dispatch = useAppDispatch(); + + const currentSession = useAppSelector((state) => state.session); + + const shortcuts = useMemo(() => { + return isJetBrains() ? jetbrainsShortcuts : vscodeShortcuts; + }, []); + + const handleViewSessionData = async () => { + const sessionData = await ideMessenger.request("history/load", { + id: currentSession.id, + }); + + if (sessionData.status === "success") { + await ideMessenger.request("showVirtualFile", { + name: `${sessionData.content.title}.json`, + content: JSON.stringify(sessionData.content, null, 2), + }); + } + }; + + return ( +
+ + +
+ {/* Resources */} +
+

Resources

+ +
+ + ideMessenger.post("openUrl", "https://hub.continue.dev/") + } + /> + + + ideMessenger.post("openUrl", "https://docs.continue.dev/") + } + /> + + + ideMessenger.post( + "openUrl", + "https://github.com/continuedev/continue/issues/new/choose", + ) + } + /> + + + ideMessenger.post("openUrl", "https://discord.gg/vapESyrFmJ") + } + /> +
+
+
+ + {/* Tools */} +
+

Tools

+ +
+ navigate("/stats")} + /> + + {currentSession.history.length > 0 && + !currentSession.isStreaming && ( + + )} + + { + navigate("/"); + // Used to clear the chat panel before showing onboarding card + await dispatch( + saveCurrentSession({ + openNewSession: true, + generateTitle: true, + }), + ); + dispatch( + setOnboardingCard({ + show: true, + activeTab: undefined, + }), + ); + ideMessenger.post("showTutorial", undefined); + }} + /> + + {process.env.NODE_ENV === "development" && ( + { + navigate(ROUTES.THEME); + }} + /> + )} +
+
+
+ + {/* Keyboard Shortcuts */} +
+

Keyboard Shortcuts

+ +
+ {shortcuts.map((shortcut, i) => { + return ( + + ); + })} +
+
+
+
+
+ ); +} diff --git a/gui/src/pages/config/sections/IndexingSettingsSection.tsx b/gui/src/pages/config/sections/IndexingSettingsSection.tsx new file mode 100644 index 000000000..67017ba59 --- /dev/null +++ b/gui/src/pages/config/sections/IndexingSettingsSection.tsx @@ -0,0 +1,49 @@ +import DocsIndexingStatuses from "../../../components/mainInput/Lump/sections/docs/DocsSection"; +import { Card } from "../../../components/ui"; +import { useAppSelector } from "../../../redux/hooks"; +import { ConfigHeader } from "../ConfigHeader"; +import IndexingProgress from "../features/indexing"; + +export function IndexingSettingsSection() { + const config = useAppSelector((state) => state.config.config); + return ( +
+ + + +
+
+

@codebase index

+ + Local embeddings of your codebase + + {config.disableIndexing ? ( +
+

+ Indexing is disabled +

+

+ Open settings and toggle Enable Indexing to + re-enable +

+
+ ) : ( + + )} +
+ +
+

@docs index

+ + Local embeddings of your documentation sources + + +
+
+
+
+ ); +} diff --git a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx b/gui/src/pages/config/sections/McpSection.tsx similarity index 86% rename from gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx rename to gui/src/pages/config/sections/McpSection.tsx index 931b83636..6914f98c1 100644 --- a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx +++ b/gui/src/pages/config/sections/McpSection.tsx @@ -11,16 +11,17 @@ import { } from "@heroicons/react/24/outline"; import { MCPServerStatus } from "core"; import { Fragment, useContext, useMemo } from "react"; -import { useAuth } from "../../../../../context/Auth"; -import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; -import { useAppDispatch, useAppSelector } from "../../../../../redux/hooks"; -import { updateConfig } from "../../../../../redux/slices/configSlice"; -import { selectCurrentOrg } from "../../../../../redux/slices/profilesSlice"; -import { fontSize } from "../../../../../util"; -import { ToolTip } from "../../../../gui/Tooltip"; -import { Button } from "../../../../ui"; -import EditBlockButton from "../../EditBlockButton"; -import { ExploreBlocksButton } from "../ExploreBlocksButton"; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { updateConfig } from "../../../redux/slices/configSlice"; +import { selectCurrentOrg } from "../../../redux/slices/profilesSlice"; +import { fontSize } from "../../../util"; +import { ToolTip } from "../../../components/gui/Tooltip"; +import { Button, Card } from "../../../components/ui"; +import EditBlockButton from "../../../components/mainInput/Lump/EditBlockButton"; +import { ExploreBlocksButton } from "../../../components/mainInput/Lump/sections/ExploreBlocksButton"; +import { ConfigHeader } from "../ConfigHeader"; interface MCPServerStatusProps { server: MCPServerStatus; @@ -226,7 +227,7 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) { ); } -function MCPSection() { +function McpSection() { const currentOrg = useAppSelector(selectCurrentOrg); const servers = useAppSelector( (store) => store.config.config.mcpServerStatuses, @@ -255,20 +256,23 @@ function MCPSection() { } return ( -
-

MCP Servers

-
- {mergedBlocks.map(({ block, blockFromYaml }, idx) => ( - - ))} -
- +
+ + + +
+ {mergedBlocks.map(({ block, blockFromYaml }, idx) => ( + + ))} +
+ +
); } -export default MCPSection; +export { McpSection }; diff --git a/gui/src/pages/config/sections/ModelsSection.tsx b/gui/src/pages/config/sections/ModelsSection.tsx new file mode 100644 index 000000000..6bea999fe --- /dev/null +++ b/gui/src/pages/config/sections/ModelsSection.tsx @@ -0,0 +1,274 @@ +import { Cog6ToothIcon } from "@heroicons/react/24/outline"; +import { ModelRole } from "@continuedev/config-yaml"; +import { ModelDescription } from "core"; +import { useContext } from "react"; +import { ToolTip } from "../../../components/gui/Tooltip"; +import { Card } from "../../../components/ui"; +import { Divider } from "../../../components/ui/Divider"; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { AddModelForm } from "../../../forms/AddModelForm"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; +import { updateSelectedModelByRole } from "../../../redux/thunks/updateSelectedModelByRole"; +import { isJetBrains } from "../../../util"; +import { ConfigHeader } from "../ConfigHeader"; +import ModelRoleSelector from "../components/ModelRoleSelector"; + +export function ModelsSection() { + const { selectedProfile } = useAuth(); + const dispatch = useAppDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + + const config = useAppSelector((state) => state.config.config); + const jetbrains = isJetBrains(); + + function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) { + if (!model) { + return; + } + + void dispatch( + updateSelectedModelByRole({ + role, + selectedProfile, + modelTitle: model.title, + }), + ); + } + + function handleConfigureModel(model: ModelDescription | null) { + if (!model) { + return; + } + + ideMessenger.post("config/openProfile", { + profileId: undefined, + element: model, + }); + } + + function handleAddModel() { + dispatch(setShowDialog(true)); + dispatch( + setDialogMessage( + { + dispatch(setShowDialog(false)); + }} + />, + ), + ); + } + + return ( +
+ + + +
+
+ Chat +

+ Used in the chat interface +

+
+
+
+ handleRoleUpdate("chat", model)} + setupURL="https://docs.continue.dev/chat/model-setup" + hideTitle={true} + /> +
+ {config.selectedModelByRole.chat && ( + + handleConfigureModel(config.selectedModelByRole.chat)} + /> + + )} +
+
+ + + +
+
+ Autocomplete +

+ Used to generate code completion suggestions +

+
+
+
+ handleRoleUpdate("autocomplete", model)} + setupURL="https://docs.continue.dev/autocomplete/model-setup" + hideTitle={true} + /> +
+ {config.selectedModelByRole.autocomplete && ( + + handleConfigureModel(config.selectedModelByRole.autocomplete)} + /> + + )} +
+
+
+ + + {/* Jetbrains has a model selector inline */} + {!jetbrains && ( + <> +
+
+ Edit +

+ Used for inline edits +

+
+
+
+ handleRoleUpdate("edit", model)} + setupURL="https://docs.continue.dev/edit/model-setup" + hideTitle={true} + /> +
+ {config.selectedModelByRole.edit && ( + + handleConfigureModel(config.selectedModelByRole.edit)} + /> + + )} +
+
+ + + + )} + +
+
+ Apply +

+ Used to apply generated codeblocks to files +

+
+
+
+ handleRoleUpdate("apply", model)} + setupURL="https://docs.continue.dev/customize/model-roles/apply" + hideTitle={true} + /> +
+ {config.selectedModelByRole.apply && ( + + handleConfigureModel(config.selectedModelByRole.apply)} + /> + + )} +
+
+ + + +
+
+ Embed +

+ Used to generate and query embeddings for the @codebase and @docs + context providers +

+
+
+
+ handleRoleUpdate("embed", model)} + setupURL="https://docs.continue.dev/customize/model-roles/embeddings" + hideTitle={true} + /> +
+ {config.selectedModelByRole.embed && ( + + handleConfigureModel(config.selectedModelByRole.embed)} + /> + + )} +
+
+ + + +
+
+ Rerank +

+ Used for reranking results from the @codebase and @docs context + providers +

+
+
+
+ handleRoleUpdate("rerank", model)} + setupURL="https://docs.continue.dev/customize/model-roles/reranking" + hideTitle={true} + /> +
+ {config.selectedModelByRole.rerank && ( + + handleConfigureModel(config.selectedModelByRole.rerank)} + /> + + )} +
+
+
+
+ ); +} diff --git a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx b/gui/src/pages/config/sections/PromptsSection.tsx similarity index 87% rename from gui/src/components/mainInput/Lump/sections/PromptsSection.tsx rename to gui/src/pages/config/sections/PromptsSection.tsx index ce7721d8c..9bee70ada 100644 --- a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx +++ b/gui/src/pages/config/sections/PromptsSection.tsx @@ -6,14 +6,15 @@ import { import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid"; import { SlashCommandDescWithSource } from "core"; import { useContext, useMemo } from "react"; -import { useAuth } from "../../../../context/Auth"; -import { IdeMessengerContext } from "../../../../context/IdeMessenger"; -import { useBookmarkedSlashCommands } from "../../../../hooks/useBookmarkedSlashCommands"; -import { useAppSelector } from "../../../../redux/hooks"; -import { fontSize } from "../../../../util"; -import { useMainEditor } from "../../TipTapEditor"; -import { useLump } from "../LumpContext"; -import { ExploreBlocksButton } from "./ExploreBlocksButton"; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { useBookmarkedSlashCommands } from "../../../hooks/useBookmarkedSlashCommands"; +import { useAppSelector } from "../../../redux/hooks"; +import { fontSize } from "../../../util"; +import { useMainEditor } from "../../../components/mainInput/TipTapEditor"; +import { useLump } from "../../../components/mainInput/Lump/LumpContext"; +import { ExploreBlocksButton } from "../../../components/mainInput/Lump/sections/ExploreBlocksButton"; +import { ConfigHeader } from "../ConfigHeader"; interface PromptCommandWithSlug extends SlashCommandDescWithSource { slug?: string; @@ -165,6 +166,10 @@ export function PromptsSection() { return (
+ {sortedCommands.map((prompt) => ( - {sortedRules.map((rule, index) => ( - - ))} - +
+ + + +
+ {sortedRules.map((rule, index) => ( + + ))} + +
+
); } diff --git a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx b/gui/src/pages/config/sections/ToolPoliciesSection.tsx similarity index 60% rename from gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx rename to gui/src/pages/config/sections/ToolPoliciesSection.tsx index 928821c33..ad25c92f0 100644 --- a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx +++ b/gui/src/pages/config/sections/ToolPoliciesSection.tsx @@ -2,18 +2,24 @@ import { ChevronRightIcon, InformationCircleIcon, } from "@heroicons/react/24/outline"; -import { Tool } from "core"; +import { MessageModes, Tool } from "core"; import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn"; import { useEffect, useMemo, useState } from "react"; import { useDispatch } from "react-redux"; import { Tooltip } from "react-tooltip"; -import { useAppSelector } from "../../../../../redux/hooks"; +import Alert from "../../../components/gui/Alert"; +import ToggleSwitch from "../../../components/gui/Switch"; +import { ToolTip } from "../../../components/gui/Tooltip"; +import { Card } from "../../../components/ui"; +import { useFontSize } from "../../../components/ui/font"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { addTool, + toggleToolGroupSetting, toggleToolSetting, -} from "../../../../../redux/slices/uiSlice"; -import { ToolTip } from "../../../../gui/Tooltip"; -import { useFontSize } from "../../../../ui/font"; +} from "../../../redux/slices/uiSlice"; +import { fontSize } from "../../../util"; +import { ConfigHeader } from "../ConfigHeader"; interface ToolDropdownItemProps { tool: Tool; @@ -180,4 +186,108 @@ function ToolPolicyItem(props: ToolDropdownItemProps) { ); } -export default ToolPolicyItem; +export const ToolPoliciesSection = () => { + const mode = useAppSelector((state) => state.session.mode); + const availableTools = useAppSelector((state) => state.config.config.tools); + const toolGroupSettings = useAppSelector( + (store) => store.ui.toolGroupSettings, + ); + const dispatch = useAppDispatch(); + + const toolsByGroup = useMemo(() => { + const byGroup: Record = {}; + for (const tool of availableTools) { + if (!byGroup[tool.group]) { + byGroup[tool.group] = []; + } + byGroup[tool.group].push(tool); + } + return Object.entries(byGroup); + }, [availableTools]); + + // Detect duplicate tool names + const duplicateDetection = useMemo(() => { + const counts: Record = {}; + availableTools.forEach((tool) => { + if (counts[tool.function.name]) { + counts[tool.function.name] = counts[tool.function.name] + 1; + } else { + counts[tool.function.name] = 1; + } + }); + return Object.fromEntries( + Object.entries(counts).map(([k, v]) => [k, v > 1]), + ); + }, [availableTools]); + + const allToolsOff = mode === "chat"; + + const getMessage = (mode: MessageModes) => { + switch (mode) { + case "chat": + return "All tools disabled in Chat, switch to Plan or Agent mode to use tools"; + case "plan": + return "Read-only/MCP tools available in Plan mode"; + default: + return ""; + } + }; + + const message = getMessage(mode); + + return ( +
+ + + + {(mode === "chat" || mode === "plan") && ( +
+ + {message} + +
+ )} + {toolsByGroup.length === 0 && ( + + No tools available + + )} + {toolsByGroup.map(([groupName, tools]) => { + const isGroupEnabled = + !allToolsOff && toolGroupSettings[groupName] !== "exclude"; + return ( +
+
+

+ {groupName} +

+ dispatch(toggleToolGroupSetting(groupName))} + text="" + size={10} + disabled={allToolsOff} + /> +
+
+ {tools.map((tool) => ( + + ))} +
+
+ ); + })} +
+
+ ); +}; diff --git a/gui/src/pages/config/sections/UserSettingsSection.tsx b/gui/src/pages/config/sections/UserSettingsSection.tsx new file mode 100644 index 000000000..b63b4dae7 --- /dev/null +++ b/gui/src/pages/config/sections/UserSettingsSection.tsx @@ -0,0 +1,399 @@ +import { ChevronRightIcon } from "@heroicons/react/24/outline"; +import { + SharedConfigSchema, + modifyAnyConfigWithSharedConfig, +} from "core/config/sharedConfig"; +import { HubSessionInfo } from "core/control-plane/AuthTypes"; +import { isContinueTeamMember } from "core/util/isContinueTeamMember"; +import { useContext, useEffect, useState } from "react"; +import { Card, useFontSize } from "../../../components/ui"; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { updateConfig } from "../../../redux/slices/configSlice"; +import { selectCurrentOrg } from "../../../redux/slices/profilesSlice"; +import { setLocalStorage } from "../../../util/localStorage"; +import { UserSetting } from "../components/UserSetting"; +import { ConfigHeader } from "../ConfigHeader"; +import { ContinueFeaturesMenu } from "../utils/ContinueFeaturesMenu"; + +export function UserSettingsSection() { + /////// User settings section ////// + const dispatch = useAppDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + const config = useAppSelector((state) => state.config.config); + const currentOrg = useAppSelector(selectCurrentOrg); + + const [showExperimental, setShowExperimental] = useState(false); + const { session } = useAuth(); + + function handleUpdate(sharedConfig: SharedConfigSchema) { + // Optimistic update + const updatedConfig = modifyAnyConfigWithSharedConfig(config, sharedConfig); + dispatch(updateConfig(updatedConfig)); + // IMPORTANT no need for model role updates (separate logic for selected model roles) + // simply because this function won't be used to update model roles + + // Actual update to core which propagates back with config update event + ideMessenger.post("config/updateSharedConfig", sharedConfig); + } + + // Disable autocomplete + const disableAutocompleteInFiles = ( + config.tabAutocompleteOptions?.disableInFiles ?? [] + ).join(", "); + const [formDisableAutocomplete, setFormDisableAutocomplete] = useState( + disableAutocompleteInFiles, + ); + + useEffect(() => { + // Necessary so that reformatted/trimmed values don't cause dirty state + setFormDisableAutocomplete(disableAutocompleteInFiles); + }, [disableAutocompleteInFiles]); + + // Workspace prompts + const promptPath = config.experimental?.promptPath || ""; + + const handleEnableStaticContextualizationToggle = (value: boolean) => { + handleUpdate({ enableStaticContextualization: value }); + }; + + // TODO defaults are in multiple places, should be consolidated and probably not explicit here + const showSessionTabs = config.ui?.showSessionTabs ?? false; + const continueAfterToolRejection = + config.ui?.continueAfterToolRejection ?? false; + const codeWrap = config.ui?.codeWrap ?? false; + const showChatScrollbar = config.ui?.showChatScrollbar ?? false; + const readResponseTTS = config.experimental?.readResponseTTS ?? false; + const autoAcceptEditToolDiffs = config.ui?.autoAcceptEditToolDiffs ?? false; + const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false; + const disableSessionTitles = config.disableSessionTitles ?? false; + const useCurrentFileAsContext = + config.experimental?.useCurrentFileAsContext ?? false; + const enableExperimentalTools = + config.experimental?.enableExperimentalTools ?? false; + const onlyUseSystemMessageTools = + config.experimental?.onlyUseSystemMessageTools ?? false; + const codebaseToolCallingOnly = + config.experimental?.codebaseToolCallingOnly ?? false; + const enableStaticContextualization = + config.experimental?.enableStaticContextualization ?? false; + + const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true; + const disableIndexing = config.disableIndexing ?? false; + + // const useAutocompleteCache = config.tabAutocompleteOptions?.useCache ?? true; + // const useChromiumForDocsCrawling = + // config.experimental?.useChromiumForDocsCrawling ?? false; + // const codeBlockToolbarPosition = config.ui?.codeBlockToolbarPosition ?? "top"; + const useAutocompleteMultilineCompletions = + config.tabAutocompleteOptions?.multilineCompletions ?? "auto"; + const modelTimeout = config.tabAutocompleteOptions?.modelTimeout ?? 150; + const debounceDelay = config.tabAutocompleteOptions?.debounceDelay ?? 250; + const fontSize = useFontSize(); + + const cancelChangeDisableAutocomplete = () => { + setFormDisableAutocomplete(disableAutocompleteInFiles); + }; + const handleDisableAutocompleteSubmit = () => { + handleUpdate({ + disableAutocompleteInFiles: formDisableAutocomplete + .split(",") + .map((val) => val.trim()) + .filter((val) => !!val), + }); + }; + + const [hubEnabled, setHubEnabled] = useState(false); + useEffect(() => { + void ideMessenger.ide + .getIdeSettings() + .then(({ continueTestEnvironment }) => { + setHubEnabled(continueTestEnvironment === "production"); + }); + }, [ideMessenger]); + + const hasContinueEmail = isContinueTeamMember( + (session as HubSessionInfo)?.account?.id, + ); + + const disableTelemetryToggle = + currentOrg?.policy?.allowAnonymousTelemetry === false; + const disableIndexingToggle = + currentOrg?.policy?.allowCodebaseIndexing === false; + + return ( +
+ {hubEnabled ? ( +
+ + +
+ {/* Chat Interface Settings */} +
+

Chat

+ +
+ + handleUpdate({ showSessionTabs: value }) + } + /> + handleUpdate({ codeWrap: value })} + /> + + handleUpdate({ showChatScrollbar: value }) + } + /> + + handleUpdate({ readResponseTTS: value }) + } + /> + + handleUpdate({ disableSessionTitles: !value }) + } + /> + + handleUpdate({ displayRawMarkdown: !value }) + } + /> + + handleUpdate({ autoAcceptEditToolDiffs: value }) + } + /> +
+
+
+ + {/* Privacy Settings */} +
+

Privacy & Data

+ +
+ + handleUpdate({ allowAnonymousTelemetry: value }) + } + /> + + handleUpdate({ disableIndexing: !value }) + } + /> +
+
+
+ + {/* Appearance Settings */} +
+

Appearance

+ +
+ { + setLocalStorage("fontSize", val); + handleUpdate({ fontSize: val }); + }} + min={7} + max={50} + /> +
+
+
+ + {/* Autocomplete Settings */} +
+

Autocomplete

+ +
+ + handleUpdate({ + useAutocompleteMultilineCompletions: value as + | "auto" + | "always" + | "never", + }) + } + options={[ + { label: "Auto", value: "auto" }, + { label: "Always", value: "always" }, + { label: "Never", value: "never" }, + ]} + /> + handleUpdate({ modelTimeout: val })} + min={100} + max={5000} + /> + handleUpdate({ debounceDelay: val })} + min={0} + max={2500} + /> + +
+
+
+ + {/* Experimental Settings */} +
+

Experimental

+ +
setShowExperimental(!showExperimental)} + > + + Show Experimental Settings +
+
+
+ + handleUpdate({ useCurrentFileAsContext: value }) + } + /> + + handleUpdate({ enableExperimentalTools: value }) + } + /> + + handleUpdate({ onlyUseSystemMessageTools: value }) + } + /> + + handleUpdate({ codebaseToolCallingOnly: value }) + } + /> + + handleUpdate({ continueAfterToolRejection: value }) + } + /> + + {hasContinueEmail && ( + + )} +
+
+
+
+
+
+ ) : null} +
+ ); +} diff --git a/gui/src/pages/config/ContinueFeaturesMenu.tsx b/gui/src/pages/config/utils/ContinueFeaturesMenu.tsx similarity index 93% rename from gui/src/pages/config/ContinueFeaturesMenu.tsx rename to gui/src/pages/config/utils/ContinueFeaturesMenu.tsx index 45b46ff23..e8d99c566 100644 --- a/gui/src/pages/config/ContinueFeaturesMenu.tsx +++ b/gui/src/pages/config/utils/ContinueFeaturesMenu.tsx @@ -1,4 +1,4 @@ -import ToggleSwitch from "../../components/gui/Switch"; +import ToggleSwitch from "../../../components/gui/Switch"; interface ContinueFeaturesMenuProps { enableStaticContextualization: boolean; handleEnableStaticContextualizationToggle: (value: boolean) => void; diff --git a/gui/src/pages/stats.tsx b/gui/src/pages/stats.tsx index b97a319de..fa1718cd7 100644 --- a/gui/src/pages/stats.tsx +++ b/gui/src/pages/stats.tsx @@ -65,11 +65,7 @@ function Stats() { backgroundColor: vscBackground, }} > - navigate(-1)} - showBorder - /> + navigate(-1)} showBorder />
From c7b3019b1c18465253b6e5fead6bd37ddd2089a4 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 5 Sep 2025 23:02:51 -0700 Subject: [PATCH 21/68] combine agent/org selection --- .../AssistantOptions.tsx | 2 +- .../OrganizationOption.tsx | 84 ++++++++++ .../OrganizationOptions.tsx | 22 +++ .../AssistantAndOrgListbox/ScopeSelect.tsx | 147 ------------------ .../SelectedAssistantButton.tsx | 69 ++++---- .../AssistantAndOrgListbox/index.tsx | 21 ++- gui/src/pages/config/index.tsx | 4 +- .../pages/config/sections/PromptsSection.tsx | 11 +- 8 files changed, 164 insertions(+), 196 deletions(-) create mode 100644 gui/src/components/AssistantAndOrgListbox/OrganizationOption.tsx create mode 100644 gui/src/components/AssistantAndOrgListbox/OrganizationOptions.tsx delete mode 100644 gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx diff --git a/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx b/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx index 0b70ce39a..a8baff971 100644 --- a/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx +++ b/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx @@ -13,7 +13,7 @@ export function AssistantOptions({ const { profiles } = useAuth(); return ( -
+
{profiles?.length === 0 ? (
No agents found diff --git a/gui/src/components/AssistantAndOrgListbox/OrganizationOption.tsx b/gui/src/components/AssistantAndOrgListbox/OrganizationOption.tsx new file mode 100644 index 000000000..a0a308093 --- /dev/null +++ b/gui/src/components/AssistantAndOrgListbox/OrganizationOption.tsx @@ -0,0 +1,84 @@ +import { CheckIcon } from "@heroicons/react/24/outline"; +import { BuildingOfficeIcon, UserCircleIcon, UserIcon } from "@heroicons/react/24/solid"; +import { useContext } from "react"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; +import { setSelectedOrgId } from "../../redux/slices/profilesSlice"; +import { ListboxOption } from "../ui"; + +interface OrganizationOptionProps { + organization: { id: string; name: string; iconUrl?: string | null }; + onClose: () => void; +} + +function getOrgIcon( + org: { name: string; iconUrl?: string | null }, + size: "sm" | "md" = "sm", +) { + const sizeClasses = size === "sm" ? "h-3.5 w-3.5" : "xs:h-4 xs:w-4 h-3 w-3"; + + if (org.iconUrl) { + return ( + + ); + } + + const IconComponent = + org.name === "Personal" + ? size === "md" + ? UserIcon + : UserCircleIcon + : BuildingOfficeIcon; + return ; +} + +export function OrganizationOption({ + organization, + onClose, +}: OrganizationOptionProps) { + const dispatch = useAppDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + const selectedOrgId = useAppSelector( + (state) => state.profiles.selectedOrganizationId, + ); + const isSelected = selectedOrgId === organization.id; + + function handleOptionClick() { + dispatch(setSelectedOrgId(organization.id)); + ideMessenger.post("didChangeSelectedOrg", { + id: organization.id, + }); + onClose(); + } + + return ( + +
+
+
+ {getOrgIcon(organization, "sm")} +
+ + {organization.name} + +
+
+ {isSelected && ( + + )} +
+
+
+ ); +} \ No newline at end of file diff --git a/gui/src/components/AssistantAndOrgListbox/OrganizationOptions.tsx b/gui/src/components/AssistantAndOrgListbox/OrganizationOptions.tsx new file mode 100644 index 000000000..c892aa706 --- /dev/null +++ b/gui/src/components/AssistantAndOrgListbox/OrganizationOptions.tsx @@ -0,0 +1,22 @@ +import { useAuth } from "../../context/Auth"; +import { OrganizationOption } from "./OrganizationOption"; + +interface OrganizationOptionsProps { + onClose: () => void; +} + +export function OrganizationOptions({ onClose }: OrganizationOptionsProps) { + const { organizations } = useAuth(); + + return ( +
+ {organizations.map((org) => ( + + ))} +
+ ); +} \ No newline at end of file diff --git a/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx b/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx deleted file mode 100644 index ff5ab7e05..000000000 --- a/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx +++ /dev/null @@ -1,147 +0,0 @@ -import { - BuildingOfficeIcon, - CheckIcon, - ChevronDownIcon, -} from "@heroicons/react/24/outline"; -import { UserCircleIcon, UserIcon } from "@heroicons/react/24/solid"; -import { useContext } from "react"; -import { useAuth } from "../../context/Auth"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { - selectCurrentOrg, - setSelectedOrgId, -} from "../../redux/slices/profilesSlice"; -import { ToolTip } from "../gui/Tooltip"; -import { - Listbox, - ListboxButton, - ListboxOption, - ListboxOptions, -} from "../ui/Listbox"; - -interface ScopeSelectProps { - onSelect?: () => void; - allowCompact?: boolean; -} - -function getOrgIcon( - org: { name: string; iconUrl?: string | null }, - size: "sm" | "md" = "sm", -) { - const sizeClasses = size === "sm" ? "h-3.5 w-3.5" : "xs:h-4 xs:w-4 h-3 w-3"; - - if (org.iconUrl) { - return ( - - ); - } - - const IconComponent = - org.name === "Personal" - ? size === "md" - ? UserIcon - : UserCircleIcon - : BuildingOfficeIcon; - return ; -} - -export function ScopeSelect({ onSelect, allowCompact }: ScopeSelectProps) { - const { organizations } = useAuth(); - const ideMessenger = useContext(IdeMessengerContext); - const selectedOrgId = useAppSelector( - (state) => state.profiles.selectedOrganizationId, - ); - const currentOrg = useAppSelector(selectCurrentOrg); - const dispatch = useAppDispatch(); - - // Always hide if single organization or none - if (organizations.length <= 1) { - return null; - } - - const handleChange = (newValue: string) => { - dispatch(setSelectedOrgId(newValue)); - ideMessenger.post("didChangeSelectedOrg", { - id: newValue, - }); - onSelect?.(); - }; - - const selectedDisplay = currentOrg ?? { - name: "Personal", - iconUrl: null, - }; - - return ( -
- - {({ open }) => ( -
- - -
- {getOrgIcon(selectedDisplay, "md")} -
-
- - {selectedDisplay?.name || "Select Organization"} - -
- -
-
- - -
- Organizations -
- {organizations.map((org) => ( - handleChange(org.id)} - className="px-3 py-2" - > -
-
- {getOrgIcon(org, "md")} - {org.name} -
-
- {selectedOrgId === org.id && ( - - )} -
-
-
- ))} -
-
- )} -
-
- ); -} diff --git a/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx b/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx index 6742717a4..66de275d4 100644 --- a/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx +++ b/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx @@ -4,56 +4,61 @@ import type { ProfileDescription } from "core/config/ConfigHandler"; import { useAppSelector } from "../../redux/hooks"; import { fontSize } from "../../util"; import { cn } from "../../util/cn"; -import { useLump } from "../mainInput/Lump/LumpContext"; import { ListboxButton } from "../ui"; import { AssistantIcon } from "./AssistantIcon"; interface SelectedAssistantButtonProps { selectedProfile: ProfileDescription | null; + variant?: "small" | "large"; } export function SelectedAssistantButton({ selectedProfile, + variant = "small", }: SelectedAssistantButtonProps) { - const { isToolbarExpanded } = useLump(); const configLoading = useAppSelector((store) => store.config.loading); + const isLarge = variant === "large"; + const iconSize = isLarge ? "h-4 w-4" : "h-3 w-3"; + const buttonPadding = isLarge ? "px-2 py-2" : "px-0 py-0"; + const buttonStyle = isLarge ? {} : { fontSize: fontSize(-3) }; + return ( -
- {selectedProfile === null ? ( - "Create your first agent" - ) : configLoading ? ( - - - Loading - - ) : ( - <> -
- -
- - {selectedProfile.title} +
+
+ {selectedProfile === null ? ( + "Create your first agent" + ) : configLoading ? ( + + + Loading - - )} + ) : ( + <> +
+ +
+ + {selectedProfile.title} + + + )} +
+
-