From a895092979cf8cb2f131d2a6199ae41708be596d Mon Sep 17 00:00:00 2001 From: Ben J Date: Mon, 24 Mar 2025 11:53:39 +0000 Subject: [PATCH] Update index.tsx --- gui/src/pages/config/index.tsx | 644 ++++----------------------------- 1 file changed, 72 insertions(+), 572 deletions(-) diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index e2a75724f..a336cb69c 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -1,592 +1,92 @@ -import { ModelRole } from "@continuedev/config-yaml"; -import { Listbox, Transition } from "@headlessui/react"; import { - ArrowTopRightOnSquareIcon, - CheckIcon, - ChevronUpDownIcon, - PlusCircleIcon, - XMarkIcon, + AcademicCapIcon, + CircleStackIcon, + Cog6ToothIcon, + QuestionMarkCircleIcon, } from "@heroicons/react/24/outline"; -import { ModelDescription } from "core"; -import { - SharedConfigSchema, - modifyAnyConfigWithSharedConfig, -} from "core/config/sharedConfig"; -import { Fragment, useContext, useEffect, useState } from "react"; +import { useState } from "react"; import { useNavigate } from "react-router-dom"; -import { Input } from "../../components"; -import NumberInput from "../../components/gui/NumberInput"; -import { Select } from "../../components/gui/Select"; -import ToggleSwitch from "../../components/gui/Switch"; -import AssistantIcon from "../../components/modelSelection/platform/AssistantIcon"; import PageHeader from "../../components/PageHeader"; -import { useAuth } from "../../context/Auth"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useNavigationListener } from "../../hooks/useNavigationListener"; -import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { - selectDefaultModel, - setDefaultModel, - updateConfig, -} from "../../redux/slices/configSlice"; -import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; -import { getFontSize, isJetBrains } from "../../util"; +import { fontSize } from "../../util"; import { AccountButton } from "./AccountButton"; -import ModelRoleSelector from "./ModelRoleSelector"; -import { ScopeSelect } from "./ScopeSelect"; +import { HelpCenterSection } from "./HelpCenterSection"; +import { IndexingSettingsSection } from "./IndexingSettingsSection"; +import KeyboardShortcuts from "./KeyboardShortcuts"; +import { UserSettingsForm } from "./UserSettingsForm"; + +type TabOption = { + id: string; + label: string; + component: React.ReactNode; + icon: React.ReactNode; +}; function ConfigPage() { useNavigationListener(); - const dispatch = useAppDispatch(); const navigate = useNavigate(); - const ideMessenger = useContext(IdeMessengerContext); + const [activeTab, setActiveTab] = useState("settings"); - const { - session, - logout, - login, - profiles, - selectedProfile, - controlServerBetaEnabled, - selectedOrganization, - } = useAuth(); - - const changeProfileId = (id: string) => { - dispatch(selectProfileThunk(id)); - }; - - const [hubEnabled, setHubEnabled] = useState(false); - useEffect(() => { - ideMessenger.ide.getIdeSettings().then(({ continueTestEnvironment }) => { - setHubEnabled(continueTestEnvironment === "production"); - }); - }, [ideMessenger]); - - function handleOpenConfig() { - if (!selectedProfile) { - return; - } - ideMessenger.post("config/openProfile", { - profileId: selectedProfile.id, - }); - } - - // NOTE Hub takes priority over Continue for Teams - // Since teams will be moving to hub, not vice versa - - /////// User settings section ////// - const config = useAppSelector((state) => state.config.config); - const selectedChatModel = useAppSelector(selectDefaultModel); - - 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); - } - - function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) { - if (!selectedProfile) { - return; - } - // Optimistic update - dispatch( - updateConfig({ - ...config, - selectedModelByRole: { - ...config.selectedModelByRole, - [role]: model, - }, - }), - ); - ideMessenger.post("config/updateSelectedModel", { - profileId: selectedProfile.id, - role, - title: model?.title ?? null, - }); - } - - // TODO use handleRoleUpdate for chat - function handleChatModelSelection(model: ModelDescription | null) { - if (!model) { - return; - } - dispatch(setDefaultModel({ title: model.title })); - } - - // TODO defaults are in multiple places, should be consolidated and probably not explicit here - const showSessionTabs = config.ui?.showSessionTabs ?? false; - const codeWrap = config.ui?.codeWrap ?? false; - const showChatScrollbar = config.ui?.showChatScrollbar ?? false; - const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false; - const disableSessionTitles = config.disableSessionTitles ?? false; - const readResponseTTS = config.experimental?.readResponseTTS ?? false; - - const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true; - const disableIndexing = config.disableIndexing ?? false; - - const useAutocompleteCache = config.tabAutocompleteOptions?.useCache ?? false; - 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 = getFontSize(); - - // Disable autocomplete - const disableAutocompleteInFiles = ( - config.tabAutocompleteOptions?.disableInFiles ?? [] - ).join(", "); - const [formDisableAutocomplete, setFormDisableAutocomplete] = useState( - disableAutocompleteInFiles, - ); - const cancelChangeDisableAutocomplete = () => { - setFormDisableAutocomplete(disableAutocompleteInFiles); - }; - const handleDisableAutocompleteSubmit = () => { - handleUpdate({ - disableAutocompleteInFiles: formDisableAutocomplete - .split(",") - .map((val) => val.trim()) - .filter((val) => !!val), - }); - }; - - useEffect(() => { - // Necessary so that reformatted/trimmed values don't cause dirty state - setFormDisableAutocomplete(disableAutocompleteInFiles); - }, [disableAutocompleteInFiles]); - - // Workspace prompts - const promptPath = config.experimental?.promptPath || ""; - const [formPromptPath, setFormPromptPath] = useState(promptPath); - const cancelChangePromptPath = () => { - setFormPromptPath(promptPath); - }; - const handleSubmitPromptPath = () => { - handleUpdate({ - promptPath: formPromptPath || "", - }); - }; - - useEffect(() => { - // Necessary so that reformatted/trimmed values don't cause dirty state - setFormPromptPath(promptPath); - }, [promptPath]); - - const jetbrains = isJetBrains(); + const tabs: TabOption[] = [ + { + id: "settings", + label: "Settings", + component: , + icon: , + }, + { + id: "indexing", + label: "Indexing", + component: , + icon: , + }, + { + id: "help", + label: "Help", + component: , + icon: , + }, + { + id: "shortcuts", + label: "Shortcuts", + component: , + icon: , + }, + ]; return ( -
- navigate("/")} - title="Chat" - rightContent={} - /> +
+
+ navigate("/")} + title="Chat" + rightContent={} + /> -
-
-
-

Configuration

- {hubEnabled ? ( - // Hub: show org selector - session && ( -
- {`Organization`} - -
- ) - ) : ( - // Continue for teams: show org text -
You are using Continue for Teams
- )} - - {profiles ? ( - <> -
-
- {`${hubEnabled ? "Assistant" : "Profile"}`} -
- - {({ open }) => ( -
- -
- {selectedProfile && ( - - )} - - {selectedProfile?.title ?? - "No Assistant Selected"} - -
-
-
-
- - - - {profiles.map((option, idx) => ( - - - - {option.title} - - - ))} - {hubEnabled && ( - { - if (session) { - ideMessenger.post("controlPlane/openUrl", { - path: "new", - orgSlug: selectedOrganization?.slug, - }); - } else { - login(false); - } - }} - > - - - Create new Assistant - - - )} - - - - {selectedProfile && ( -
- - - {hubEnabled - ? "Open Assistant configuration" - : "View Workspace"} - -
- )} -
- )} -
-
- - ) : ( -
Loading...
- )} -
-
- - {/* Model Roles as a separate section */} -
-
-

Model Roles

-
- handleChatModelSelection(model)} - /> - handleRoleUpdate("autocomplete", model)} - /> - {/* Jetbrains has a model selector inline */} - {!jetbrains && ( - handleRoleUpdate("edit", model)} - /> - )} - handleRoleUpdate("apply", model)} - /> - handleRoleUpdate("embed", model)} - /> - handleRoleUpdate("rerank", model)} - /> + {/* Tab Headers */} +
+ {tabs.map((tab) => ( +
setActiveTab(tab.id)} + > + {tab.icon} + {tab.label}
-
+ ))}
+
- {!controlServerBetaEnabled || hubEnabled ? ( -
-
-
-
-

User settings

-
- -
- - handleUpdate({ - showSessionTabs: !showSessionTabs, - }) - } - text="Show Session Tabs" - /> - - handleUpdate({ - codeWrap: !codeWrap, - }) - } - text="Wrap Codeblocks" - /> - - handleUpdate({ - displayRawMarkdown: !displayRawMarkdown, - }) - } - text="Display Raw Markdown" - /> - - handleUpdate({ - allowAnonymousTelemetry: !allowAnonymousTelemetry, - }) - } - text="Allow Anonymous Telemetry" - /> - - handleUpdate({ - disableIndexing: !disableIndexing, - }) - } - text="Disable Indexing" - /> - - - handleUpdate({ - disableSessionTitles: !disableSessionTitles, - }) - } - text="Disable Session Titles" - /> - - handleUpdate({ - readResponseTTS: !readResponseTTS, - }) - } - text="Response Text to Speech" - /> - - - handleUpdate({ - showChatScrollbar: !showChatScrollbar, - }) - } - text="Show Chat Scrollbar" - /> - - - handleUpdate({ - useAutocompleteCache: !useAutocompleteCache, - }) - } - text="Use Autocomplete Cache" - /> - - - handleUpdate({ - useChromiumForDocsCrawling: !useChromiumForDocsCrawling, - }) - } - text="Use Chromium for Docs Crawling" - /> - - - - - - -
{ - e.preventDefault(); - handleDisableAutocompleteSubmit(); - }} - > -
- Disable autocomplete in files -
- { - setFormDisableAutocomplete(e.target.value); - }} - /> -
- {formDisableAutocomplete !== - disableAutocompleteInFiles ? ( - <> -
- -
-
- -
- - ) : ( -
- -
- )} -
-
-
- - Comma-separated list of path matchers - -
-
-
-
-
- ) : null} + {/* Tab Content */} +
+ {tabs.find((tab) => tab.id === activeTab)?.component}
);