From 62274cd1a093299e592e4e0db8cb97d6d1dea533 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 24 Jan 2025 13:34:55 -0800 Subject: [PATCH] config page --- gui/src/pages/config/index.tsx | 151 ++++++++++++++++++++++++++++----- 1 file changed, 132 insertions(+), 19 deletions(-) diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index 62d5df8d2..20c7143df 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -1,4 +1,4 @@ -import { useContext, useState } from "react"; +import { useContext, useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useNavigationListener } from "../../hooks/useNavigationListener"; @@ -11,10 +11,11 @@ import { import { updateConfig } from "../../redux/slices/configSlice"; import ToggleSwitch from "../../components/gui/Switch"; import { useAuth } from "../../context/Auth"; -import { Button } from "../../components"; +import { Button, Input } from "../../components"; import { getFontSize } from "../../util"; import NumberInput from "../../components/gui/NumberInput"; import { Select } from "../../components/gui/Select"; +import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; function ConfigPage() { useNavigationListener(); @@ -22,7 +23,7 @@ function ConfigPage() { const navigate = useNavigate(); const ideMessenger = useContext(IdeMessengerContext); - const { profiles, selectedProfile, controlServerBetaEnabled } = useAuth(); + const { selectedProfile } = useAuth(); const config = useAppSelector((state) => state.config.config); function handleUpdate(sharedConfig: Partial) { @@ -30,17 +31,8 @@ function ConfigPage() { updateConfig(modifyContinueConfigWithSharedConfig(config, sharedConfig)), ); ideMessenger.post("config/updateSharedConfig", sharedConfig); - - // TODO: Optimistic update in redux - // dispatch(updateConfig({ - // ...config, - // ...(sharedConfig.) - // })) } - // Account for default values - // TODO - duplicate defaults here, should consolidate defaults to one place - // And write defaults earlier in the config process const codeWrap = config.ui?.codeWrap ?? false; const showChatScrollbar = config.ui?.showChatScrollbar ?? false; const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false; @@ -56,9 +48,49 @@ function ConfigPage() { const codeBlockToolbarPosition = config.ui?.codeBlockToolbarPosition ?? "top"; const useAutocompleteMultilineCompletions = config.tabAutocompleteOptions?.multilineCompletions ?? "auto"; - 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]); + function handleOpenConfig() { if (!selectedProfile) { return; @@ -150,11 +182,6 @@ function ConfigPage() { text="Show Chat Scrollbar" /> - {/* disableAutocompleteInFiles: z.array(z.string()), */} - - {/* promptPath: z.string(), */} - - {/* Other */} @@ -165,7 +192,6 @@ function ConfigPage() { text="Use Autocomplete Cache" /> - {/* Other */} @@ -225,6 +251,93 @@ function ConfigPage() { max={50} /> + +
{ + e.preventDefault(); + handleSubmitPromptPath(); + }} + > + +
+ +
{ + e.preventDefault(); + handleDisableAutocompleteSubmit(); + }} + > + + + Comma-separated list of path matchers + +
)}