From 8ecff56c533072ce40bd3d09066da969cc766823 Mon Sep 17 00:00:00 2001 From: boowangoo Date: Tue, 21 Jan 2025 18:25:34 -0500 Subject: [PATCH 01/29] Add deepseek-reasoner (R1) --- gui/src/pages/AddNewModel/AddNewModel.tsx | 2 +- gui/src/pages/AddNewModel/configs/models.ts | 13 +++++++++++++ gui/src/pages/AddNewModel/configs/providers.ts | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gui/src/pages/AddNewModel/AddNewModel.tsx b/gui/src/pages/AddNewModel/AddNewModel.tsx index 5b9687537..d74cbf25c 100644 --- a/gui/src/pages/AddNewModel/AddNewModel.tsx +++ b/gui/src/pages/AddNewModel/AddNewModel.tsx @@ -49,7 +49,7 @@ const modelsByProvider: Record = { models.mistralLarge, ], Cohere: [models.commandR, models.commandRPlus], - DeepSeek: [models.deepseekCoderApi, models.deepseekChatApi], + DeepSeek: [models.deepseekCoderApi, models.deepseekChatApi, models.deepseekReasonerApi], Gemini: [models.geminiPro, models.gemini15Pro, models.gemini15Flash], "Open Source": [models.llama3Chat, models.mistralOs, models.deepseek], }; diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index 8116c86ba..2761a725e 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -230,6 +230,19 @@ export const models: { [key: string]: ModelPackage } = { providerOptions: ["deepseek"], isOpenSource: false, }, + deepseekReasonerApi: { + title: "DeepSeek Reasoner", + description: + "An open-source reasoning model which generates a chain of thought to enhance the accuracy of its responses.", + params: { + title: "DeepSeek Reasoner", + model: "deepseek-reasoner", + contextLength: 64_000, + }, + icon: "deepseek.png", + providerOptions: ["deepseek"], + isOpenSource: true, + }, deepseekCoder2Lite: { title: "DeepSeek Coder 2 Lite", description: diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 4890d5c2b..bf6fe735d 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -370,7 +370,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n required: true, }, ], - packages: [models.deepseekCoderApi, models.deepseekChatApi], + packages: [models.deepseekCoderApi, models.deepseekChatApi, models.deepseekReasonerApi], apiKeyUrl: "https://platform.deepseek.com/api_keys", }, together: { From 344241bcdae4ce004d0eb4405bf8273988e4f0c5 Mon Sep 17 00:00:00 2001 From: Adam Shedivy Date: Wed, 22 Jan 2025 13:21:39 -0600 Subject: [PATCH 02/29] run config reload with additional context providers --- core/config/ConfigHandler.ts | 6 +++--- core/config/ProfileLifecycleManager.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 24987528a..af454a4f0 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -286,11 +286,11 @@ export class ConfigHandler { this.updateListeners.push(listener); } - async reloadConfig() { + async reloadConfig(additionalContextProviders: IContextProvider[] = []) { // TODO: this isn't right, there are two different senses in which you want to "reload" const { config, errors, configLoadInterrupted } = - await this.currentProfile.reloadConfig(); + await this.currentProfile.reloadConfig(additionalContextProviders); if (config) { this.inactiveProfiles.forEach((profile) => profile.clearConfig()); @@ -340,6 +340,6 @@ export class ConfigHandler { registerCustomContextProvider(contextProvider: IContextProvider) { this.additionalContextProviders.push(contextProvider); - void this.reloadConfig(); + void this.reloadConfig(this.additionalContextProviders); } } diff --git a/core/config/ProfileLifecycleManager.ts b/core/config/ProfileLifecycleManager.ts index 88fc387c5..ea4e14a79 100644 --- a/core/config/ProfileLifecycleManager.ts +++ b/core/config/ProfileLifecycleManager.ts @@ -32,12 +32,12 @@ export class ProfileLifecycleManager { } // Clear saved config and reload - async reloadConfig(): Promise> { + async reloadConfig(additionalContextProviders: IContextProvider[] = []): Promise> { this.savedConfigResult = undefined; this.savedBrowserConfigResult = undefined; this.pendingConfigPromise = undefined; - return this.loadConfig([], true); + return this.loadConfig(additionalContextProviders, true); } async loadConfig( From 3b539d53c39a98c361e27db6dfb72a8e14ddae50 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 28 Jan 2025 16:06:49 -0800 Subject: [PATCH 03/29] feat: assistant select --- binary/package-lock.json | 2 +- core/config/ConfigHandler.ts | 18 +- core/config/ProfileLifecycleManager.ts | 2 + core/config/profile/PlatformProfileLoader.ts | 6 +- extensions/vscode/package-lock.json | 6 +- gui/src/components/Layout.tsx | 10 - gui/src/components/PageHeader.tsx | 32 ++- gui/src/components/mainInput/InputToolbar.tsx | 7 +- .../platform/AssistantAndModelSelect.tsx | 194 ------------------ .../modelSelection/platform/AssistantIcon.tsx | 17 ++ .../platform/AssistantSelect.tsx | 178 ++++++++-------- .../platform/AssistantSelectOptions.tsx | 120 +++++++++++ .../modelSelection/platform/ModelSelect.tsx | 121 ----------- .../modelSelection/platform/shared.tsx | 1 - .../modelSelection/platform/utils.ts | 6 + gui/src/index.css | 2 - gui/src/pages/More/More.tsx | 2 +- gui/src/pages/gui/Chat.tsx | 21 +- gui/src/pages/history/index.tsx | 2 +- gui/src/util/index.ts | 5 + 20 files changed, 289 insertions(+), 463 deletions(-) delete mode 100644 gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx create mode 100644 gui/src/components/modelSelection/platform/AssistantIcon.tsx create mode 100644 gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx delete mode 100644 gui/src/components/modelSelection/platform/ModelSelect.tsx create mode 100644 gui/src/components/modelSelection/platform/utils.ts diff --git a/binary/package-lock.json b/binary/package-lock.json index 316fddcd2..84b831ecf 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -48,7 +48,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.16", + "@continuedev/config-yaml": "^1.0.23", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index edcf62071..0badc4700 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -1,9 +1,17 @@ import * as fs from "node:fs"; +import { + AssistantUnrolled, + ConfigResult, + FullSlug, +} from "@continuedev/config-yaml"; +import * as YAML from "yaml"; + import { ControlPlaneClient, ControlPlaneSessionInfo, } from "../control-plane/client.js"; +import { getControlPlaneEnv, useHub } from "../control-plane/env.js"; import { BrowserSerializedContinueConfig, ContinueConfig, @@ -15,15 +23,8 @@ import { import Ollama from "../llm/llms/Ollama.js"; import { GlobalContext } from "../util/GlobalContext.js"; import { getConfigJsonPath, getConfigYamlPath } from "../util/paths.js"; - -import { - AssistantUnrolled, - ConfigResult, - FullSlug, -} from "@continuedev/config-yaml"; -import * as YAML from "yaml"; -import { getControlPlaneEnv, useHub } from "../control-plane/env.js"; import { localPathToUri } from "../util/pathToUri.js"; + import { LOCAL_ONBOARDING_CHAT_MODEL, ONBOARDING_LOCAL_MODEL_TITLE, @@ -135,6 +136,7 @@ export class ConfigHandler { { ...assistant.configResult, config: renderedConfig }, assistant.ownerSlug, assistant.packageSlug, + assistant.iconUrl, assistant.configResult.config?.version ?? "latest", this.controlPlaneClient, this.ide, diff --git a/core/config/ProfileLifecycleManager.ts b/core/config/ProfileLifecycleManager.ts index fa76c6b55..8216153ae 100644 --- a/core/config/ProfileLifecycleManager.ts +++ b/core/config/ProfileLifecycleManager.ts @@ -3,6 +3,7 @@ import { ConfigValidationError, FullSlug, } from "@continuedev/config-yaml"; + import { BrowserSerializedContinueConfig, ContinueConfig, @@ -18,6 +19,7 @@ export interface ProfileDescription { profileType: "control-plane" | "local" | "platform"; title: string; id: string; + iconUrl: string; errors: ConfigValidationError[] | undefined; } diff --git a/core/config/profile/PlatformProfileLoader.ts b/core/config/profile/PlatformProfileLoader.ts index 12e166c2d..7650cb0e3 100644 --- a/core/config/profile/PlatformProfileLoader.ts +++ b/core/config/profile/PlatformProfileLoader.ts @@ -1,10 +1,10 @@ +import { ConfigResult } from "@continuedev/config-yaml"; import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas/index.js"; import { ControlPlaneClient } from "../../control-plane/client.js"; import { ContinueConfig, IDE, IdeSettings } from "../../index.js"; - -import { ConfigResult } from "@continuedev/config-yaml"; import { ProfileDescription } from "../ProfileLifecycleManager.js"; + import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; @@ -27,6 +27,7 @@ export default class PlatformProfileLoader implements IProfileLoader { private configResult: ConfigResult, private readonly ownerSlug: string, private readonly packageSlug: string, + private readonly iconUrl: string, versionSlug: string, private readonly controlPlaneClient: ControlPlaneClient, private readonly ide: IDE, @@ -44,6 +45,7 @@ export default class PlatformProfileLoader implements IProfileLoader { }, title: `${ownerSlug}/${packageSlug}@${versionSlug}`, errors: configResult.errors, + iconUrl: this.iconUrl, }; } diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index cbc67ea38..4ca866899 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.255", + "version": "0.9.256", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.255", + "version": "0.9.256", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.20", + "@continuedev/config-yaml": "^1.0.23", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index cadaa5830..747c2ddab 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -29,16 +29,6 @@ const LayoutTopDiv = styled(CustomScrollbarDiv)` border-radius: ${defaultBorderRadius}; position: relative; overflow-x: hidden; - - &::after { - position: absolute; - content: ""; - width: 100%; - height: 1px; - background-color: rgba(136, 136, 136, 0.3); - top: 0; - left: 0; - } `; const GridDiv = styled.div` diff --git a/gui/src/components/PageHeader.tsx b/gui/src/components/PageHeader.tsx index 23e108c38..04317c947 100644 --- a/gui/src/components/PageHeader.tsx +++ b/gui/src/components/PageHeader.tsx @@ -1,20 +1,32 @@ import { ArrowLeftIcon } from "@heroicons/react/24/outline"; export interface PageHeaderProps { - onClick: () => void; - title: string; + onTitleClick?: () => void; + title?: string; + rightContent?: React.ReactNode; } -export default function PageHeader({ onClick, title }: PageHeaderProps) { +export default function PageHeader({ + onTitleClick, + title, + rightContent, +}: PageHeaderProps) { return ( -
-
- - {title} +
+
+ {title && ( +
+ + + {title} + +
+ )}
+
{rightContent}
); } diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index 7ce52bec4..93b437fdc 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -10,7 +10,7 @@ import { vscInputBackground, } from ".."; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { selectUseActiveFile, selectUsePlatform } from "../../redux/selectors"; +import { selectUseActiveFile } from "../../redux/selectors"; import { selectDefaultModel } from "../../redux/slices/configSlice"; import { selectHasCodeToEdit, @@ -26,7 +26,6 @@ import { } from "../../util"; import { ToolTip } from "../gui/Tooltip"; import ModelSelect from "../modelSelection/ModelSelect"; -import AssistantAndModelSelect from "../modelSelection/platform/AssistantAndModelSelect"; import HoverItem from "./InputToolbar/HoverItem"; import ToggleToolsButton from "./InputToolbar/ToggleToolsButton"; @@ -97,8 +96,6 @@ function InputToolbar(props: InputToolbarProps) { modelSupportsTools(defaultModel.model, defaultModel.provider) && !props.toolbarOptions?.hideTools; - const usePlatform = useAppSelector(selectUsePlatform); - const supportsImages = defaultModel && modelSupportsImages( @@ -117,7 +114,7 @@ function InputToolbar(props: InputToolbarProps) { className="find-widget-skip flex" >
- {usePlatform ? : } +
{props.toolbarOptions?.hideImageUpload || (supportsImages && ( diff --git a/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx b/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx deleted file mode 100644 index c33c3a586..000000000 --- a/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx +++ /dev/null @@ -1,194 +0,0 @@ -import { Popover } from "@headlessui/react"; -import { - ChevronDownIcon, - DocumentIcon, - SparklesIcon, -} from "@heroicons/react/24/outline"; -import { useEffect, useRef, useState } from "react"; -import styled from "styled-components"; -import { defaultBorderRadius, lightGray, vscInputBackground } from "../.."; -import { useAuth } from "../../../context/Auth"; -import AddModelForm from "../../../forms/AddModelForm"; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; -import { - cycleDefaultModel, - selectDefaultModel, -} from "../../../redux/slices/configSlice"; -import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; -import { cycleProfile } from "../../../redux/thunks/cycleProfile"; -import { getFontSize, isMetaEquivalentKeyPressed } from "../../../util"; -import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition"; -import { AssistantSelect } from "./AssistantSelect"; -import { ModelSelect, modelSelectTitle } from "./ModelSelect"; -import { MAX_HEIGHT_PX } from "./shared"; - -const StyledPopoverButton = styled(Popover.Button)` - font-family: inherit; - display: flex; - align-items: center; - gap: 2px; - border: none; - cursor: pointer; - font-size: ${getFontSize() - 2}px; - background: transparent; - color: ${lightGray}; - &:focus { - outline: none; - } -`; - -const StyledPopoverPanel = styled(Popover.Panel)<{ $showabove: boolean }>` - margin-top: 4px; - position: absolute; - padding: 0px; - cursor: default; - - display: flex; - flex-direction: row; - - border-radius: ${defaultBorderRadius}; - border: 0.5px solid ${lightGray}; - background-color: ${vscInputBackground}; - - ${(props) => (props.$showabove ? "bottom: 100%;" : "top: 100%;")} -`; - -function AssistantAndModelSelect() { - const dispatch = useAppDispatch(); - const defaultModel = useAppSelector(selectDefaultModel); - const [showAbove, setShowAbove] = useState(false); - const buttonRef = useRef(null); - const selectedProfileId = useAppSelector( - (store) => store.session.selectedProfileId, - ); - - const { profiles, selectedProfile } = useAuth(); - - useEffect(() => { - const handleResize = () => calculatePosition(); - window.addEventListener("resize", handleResize); - return () => window.removeEventListener("resize", handleResize); - }, []); - - function calculatePosition() { - if (!buttonRef.current) { - return; - } - const rect = buttonRef.current.getBoundingClientRect(); - const spaceBelow = window.innerHeight - rect.bottom; - const spaceAbove = rect.top; - const dropdownHeight = MAX_HEIGHT_PX; - - setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow); - } - - function onClickAddModel(e: any) { - e.stopPropagation(); - e.preventDefault(); - - // Close the dropdown - if (buttonRef.current) { - buttonRef.current.click(); - } - dispatch(setShowDialog(true)); - dispatch( - setDialogMessage( - { - dispatch(setShowDialog(false)); - }} - />, - ), - ); - } - - useEffect(() => { - let lastToggleTime = 0; - const DEBOUNCE_MS = 500; - - const handleKeyDown = (event: KeyboardEvent) => { - if (event.key === "'" && isMetaEquivalentKeyPressed(event as any)) { - const now = Date.now(); - - if (event.shiftKey) { - dispatch(cycleDefaultModel("next")); - } else { - if (now - lastToggleTime >= DEBOUNCE_MS) { - dispatch(cycleProfile()); - lastToggleTime = now; - } - } - } - }; - - window.addEventListener("keydown", handleKeyDown); - return () => { - window.removeEventListener("keydown", handleKeyDown); - }; - }, []); - - return ( - -
- -
- {selectedProfile?.id === "local" ? ( - <> -
-
- - - { - if (buttonRef.current) { - buttonRef.current.click(); - } - }} - /> - - - -
-
- ); -} - -export default AssistantAndModelSelect; diff --git a/gui/src/components/modelSelection/platform/AssistantIcon.tsx b/gui/src/components/modelSelection/platform/AssistantIcon.tsx new file mode 100644 index 000000000..fb9346bbf --- /dev/null +++ b/gui/src/components/modelSelection/platform/AssistantIcon.tsx @@ -0,0 +1,17 @@ +import { ProfileDescription } from "core/config/ProfileLifecycleManager"; +import { isLocalProfile } from "../../../util"; +import { ComputerDesktopIcon, SparklesIcon } from "@heroicons/react/24/outline"; + +export interface AssistantIconProps { + assistant: ProfileDescription; +} + +export default function AssistantIcon({ assistant }: AssistantIconProps) { + if (isLocalProfile(assistant)) { + return ; + } else if (!assistant.iconUrl) { + return ; + } else { + return ; + } +} diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 972dd2782..248beee42 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -1,113 +1,95 @@ +import { Popover } from "@headlessui/react"; import { - DocumentIcon, - PlusIcon, + ChevronDownIcon, + ComputerDesktopIcon, SparklesIcon, } from "@heroicons/react/24/outline"; -import { useContext } from "react"; -import { lightGray } from "../.."; +import { cloneElement, useEffect, useRef } from "react"; import { useAuth } from "../../../context/Auth"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useAppDispatch } from "../../../redux/hooks"; -import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; -import { setProfileId } from "../../../redux/thunks/setProfileId"; -import { getFontSize, getMetaKeyLabel } from "../../../util"; -import AboutAssistantDialog from "../../dialogs/AboutAssistantDialog"; -import { Divider, Option, OptionDiv } from "./shared"; - -interface AssistantSelectProps { - onClose: () => void; -} - -export function AssistantSelect(props: AssistantSelectProps) { - const ideMessenger = useContext(IdeMessengerContext); - const { profiles, selectedProfile } = useAuth(); +import { cycleProfile } from "../../../redux/thunks/cycleProfile"; +import { + getFontSize, + isLocalProfile, + isMetaEquivalentKeyPressed, +} from "../../../util"; +import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition"; +import { AssistantSelectOptions } from "./AssistantSelectOptions"; +import AssistantIcon from "./AssistantIcon"; +import { getProfileDisplayText } from "./utils"; +export default function AssistantSelect() { const dispatch = useAppDispatch(); + const buttonRef = useRef(null); + const { selectedProfile } = useAuth(); - function onNewAssistant() { - ideMessenger.post("controlPlane/openUrl", { - path: "new", - }); + const isLocalProfileSelected = + selectedProfile && isLocalProfile(selectedProfile); + + useEffect(() => { + let lastToggleTime = 0; + const DEBOUNCE_MS = 500; + + const handleKeyDown = (event: KeyboardEvent) => { + if ( + event.key === "'" && + isMetaEquivalentKeyPressed(event as any) && + event.shiftKey + ) { + const now = Date.now(); + + if (now - lastToggleTime >= DEBOUNCE_MS) { + dispatch(cycleProfile()); + lastToggleTime = now; + } + } + }; + + window.addEventListener("keydown", handleKeyDown); + return () => { + window.removeEventListener("keydown", handleKeyDown); + }; + }, []); + + if (!selectedProfile) { + return null; } return ( -
-
- {profiles.map((option, idx) => ( - - ))} -
- -
- -
- - New Assistant -
-
- - - - +
+ - {getMetaKeyLabel()}' toggle assistant - +
+
+ +
+ + {getProfileDisplayText(selectedProfile)} + +
+
+ + + + { + if (buttonRef.current) { + buttonRef.current.click(); + } + }} + /> + +
-
+ ); } diff --git a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx new file mode 100644 index 000000000..3ff7a755a --- /dev/null +++ b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx @@ -0,0 +1,120 @@ +import { PlusIcon } from "@heroicons/react/24/outline"; +import { useContext } from "react"; +import { lightGray } from "../.."; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { useAppDispatch } from "../../../redux/hooks"; +import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; +import { setProfileId } from "../../../redux/thunks/setProfileId"; +import { getFontSize, getMetaKeyLabel, isLocalProfile } from "../../../util"; +import AboutAssistantDialog from "../../dialogs/AboutAssistantDialog"; +import { Divider, Option, OptionDiv } from "./shared"; +import { getProfileDisplayText } from "./utils"; +import AssistantIcon from "./AssistantIcon"; + +interface AssistantSelectOptionsProps { + onClose: () => void; +} + +export function AssistantSelectOptions(props: AssistantSelectOptionsProps) { + const ideMessenger = useContext(IdeMessengerContext); + const { profiles, selectedProfile } = useAuth(); + const dispatch = useAppDispatch(); + + function onNewAssistant() { + ideMessenger.post("controlPlane/openUrl", { + path: "platform/new", + }); + } + + function handleOptionLink(e: React.MouseEvent, profileId: string) { + e.stopPropagation(); + e.preventDefault(); + ideMessenger.post("config/openProfile", { profileId }); + } + + function handleConfigure(e: React.MouseEvent, option: any) { + e.stopPropagation(); + e.preventDefault(); + + if (option.id === "local") { + ideMessenger.post("config/openProfile", { profileId: option.id }); + } else { + props.onClose(); + dispatch(setDialogMessage()); + dispatch(setShowDialog(true)); + } + } + + function handleClickError(profileId: string) { + ideMessenger.post("config/openProfile", { profileId }); + } + + return ( +
+
+ {profiles.map((profile, idx) => ( + + ))} +
+ +
+ +
+ + New Assistant +
+
+ + + + + {getMetaKeyLabel()} ⇧ ' to toggle + +
+
+ ); +} diff --git a/gui/src/components/modelSelection/platform/ModelSelect.tsx b/gui/src/components/modelSelection/platform/ModelSelect.tsx deleted file mode 100644 index 80ad7179a..000000000 --- a/gui/src/components/modelSelection/platform/ModelSelect.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import { CubeIcon, PlusIcon } from "@heroicons/react/24/outline"; -import { useContext, useEffect, useState } from "react"; -import { lightGray } from "../.."; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; -import { - selectDefaultModel, - setDefaultModel, -} from "../../../redux/slices/configSlice"; -import { getFontSize, getMetaKeyLabel } from "../../../util"; -import { Divider, Option, OptionDiv } from "./shared"; - -export interface ModelOption { - value: string; - title: string; - apiKey?: string; -} - -export function modelSelectTitle(model: any): string { - if (model?.title) return model?.title; - if (model?.model !== undefined && model?.model.trim() !== "") { - if (model?.class_name) { - return `${model?.class_name} - ${model?.model}`; - } - return model?.model; - } - return model?.class_name; -} - -interface ModelSelectProps { - selectedProfileId: string; - onClickAddModel: (e: any) => void; -} - -export function ModelSelect(props: ModelSelectProps) { - const dispatch = useAppDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - const defaultModel = useAppSelector(selectDefaultModel); - const allModels = useAppSelector((state) => state.config.config.models); - const [options, setOptions] = useState([]); - const [sortedOptions, setSortedOptions] = useState([]); - - // Sort so that options without an API key are at the end - useEffect(() => { - const enabledOptions = options.filter((option) => option.apiKey !== ""); - const disabledOptions = options.filter((option) => option.apiKey === ""); - - const sorted = [...enabledOptions, ...disabledOptions]; - - setSortedOptions(sorted); - }, [options]); - - useEffect(() => { - setOptions( - allModels.map((model) => { - return { - value: model.title, - title: modelSelectTitle(model), - apiKey: model.apiKey, - }; - }), - ); - }, [allModels]); - - function onModelChange(modelTitle: string) { - if (modelTitle === defaultModel?.title) return; - dispatch(setDefaultModel({ title: modelTitle })); - } - - return ( -
-
- {sortedOptions.map((option, idx) => ( - - ))} -
- -
- {props.selectedProfileId === "local" && ( - <> - -
- - Add Chat model -
-
- - )} - - - - - {getMetaKeyLabel()}⇧' toggle model - -
-
- ); -} diff --git a/gui/src/components/modelSelection/platform/shared.tsx b/gui/src/components/modelSelection/platform/shared.tsx index d860cab49..bb94188a9 100644 --- a/gui/src/components/modelSelection/platform/shared.tsx +++ b/gui/src/components/modelSelection/platform/shared.tsx @@ -13,7 +13,6 @@ export const OptionDiv = styled.div<{ isDisabled?: boolean; isSelected?: boolean; }>` - border-radius: ${defaultBorderRadius}; padding: 6px 12px; min-width: 0px; diff --git a/gui/src/components/modelSelection/platform/utils.ts b/gui/src/components/modelSelection/platform/utils.ts new file mode 100644 index 000000000..4a8ac8bd0 --- /dev/null +++ b/gui/src/components/modelSelection/platform/utils.ts @@ -0,0 +1,6 @@ +import { ProfileDescription } from "core/config/ProfileLifecycleManager"; +import { isLocalProfile } from "../../../util"; + +export function getProfileDisplayText(profile: ProfileDescription): string { + return isLocalProfile(profile) ? profile.title : profile.fullSlug.packageSlug; +} diff --git a/gui/src/index.css b/gui/src/index.css index 93ccd384f..4a2270c95 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -7,8 +7,6 @@ --vsc-background: rgb(30, 30, 30); --button-color: rgb(113, 28, 59); --button-color-hover: rgba(113, 28, 59, 0.667); - --def-border-radius: 5px; - --vscode-editor-background: rgb(30, 30, 30); --vscode-editor-foreground: rgb(197, 200, 198); --vscode-textBlockQuote-background: rgba(255, 255, 255, 1); diff --git a/gui/src/pages/More/More.tsx b/gui/src/pages/More/More.tsx index b543353b7..360a5951f 100644 --- a/gui/src/pages/More/More.tsx +++ b/gui/src/pages/More/More.tsx @@ -27,7 +27,7 @@ function MorePage() { return (
- navigate("/")} title="Chat" /> + navigate("/")} title="Chat" />
diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 1bb5f5714..b5568931e 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -77,6 +77,7 @@ import { ToolCallDiv } from "./ToolCallDiv"; import { ToolCallButtons } from "./ToolCallDiv/ToolCallButtonsDiv"; import ToolOutput from "./ToolCallDiv/ToolOutput"; import FreeTrialOverDialog from "../../components/dialogs/FreeTrialOverDialog"; +import AssistantSelect from "../../components/modelSelection/platform/AssistantSelect"; const StopButton = styled.div` background-color: ${vscBackground}; @@ -366,17 +367,25 @@ export function Chat() { return ( <> - {isInEditMode && ( + {(isInEditMode || usePlatform) && ( { - await dispatch(loadLastSession({ saveCurrentSession: false })); - dispatch(exitEditMode()); - }} + title={isInEditMode ? "Edit Mode" : ""} + onTitleClick={ + isInEditMode + ? async () => { + await dispatch( + loadLastSession({ saveCurrentSession: false }), + ); + dispatch(exitEditMode()); + } + : undefined + } + rightContent={usePlatform && } /> )} {widget} + 0 ? "flex-1" : ""}`} diff --git a/gui/src/pages/history/index.tsx b/gui/src/pages/history/index.tsx index 54b6cea0a..0d3c3429e 100644 --- a/gui/src/pages/history/index.tsx +++ b/gui/src/pages/history/index.tsx @@ -8,7 +8,7 @@ export default function HistoryPage() { return (
- navigate("/")} title="Chat" /> + navigate("/")} title="Chat" />
); diff --git a/gui/src/util/index.ts b/gui/src/util/index.ts index 233589f34..cb00d2680 100644 --- a/gui/src/util/index.ts +++ b/gui/src/util/index.ts @@ -1,6 +1,7 @@ import _ from "lodash"; import { getLocalStorage } from "./localStorage"; import { KeyboardEvent } from "react"; +import { ProfileDescription } from "core/config/ProfileLifecycleManager"; type Platform = "mac" | "linux" | "windows" | "unknown"; @@ -105,3 +106,7 @@ export function updatedObj(old: any, pathToValue: { [key: string]: any }) { return newObject; } + +export function isLocalProfile(profile: ProfileDescription): boolean { + return profile.id === "local"; +} From 249a35430819e9650d130eef828aa359c2a5febb Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 28 Jan 2025 16:07:38 -0800 Subject: [PATCH 04/29] Update AssistantIcon.tsx --- gui/src/components/modelSelection/platform/AssistantIcon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/modelSelection/platform/AssistantIcon.tsx b/gui/src/components/modelSelection/platform/AssistantIcon.tsx index fb9346bbf..64adb7e46 100644 --- a/gui/src/components/modelSelection/platform/AssistantIcon.tsx +++ b/gui/src/components/modelSelection/platform/AssistantIcon.tsx @@ -9,7 +9,7 @@ export interface AssistantIconProps { export default function AssistantIcon({ assistant }: AssistantIconProps) { if (isLocalProfile(assistant)) { return ; - } else if (!assistant.iconUrl) { + } else if (assistant.iconUrl) { return ; } else { return ; From e41a76435b5c4345c0839106a5931f8bbe8bea12 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 28 Jan 2025 16:30:33 -0800 Subject: [PATCH 05/29] Update AssistantSelectOptions.tsx --- .../modelSelection/platform/AssistantSelectOptions.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx index 3ff7a755a..781d60437 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx @@ -51,7 +51,11 @@ export function AssistantSelectOptions(props: AssistantSelectOptionsProps) { } return ( -
+
+
+ Available Assistants +
+
{profiles.map((profile, idx) => (
diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 232dafae3..f78b58720 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -50,6 +50,7 @@ import { selectHasCodeToEdit, selectIsInEditMode, setMainEditorContentTrigger, + setNewestCodeblocksForInput, } from "../../redux/slices/sessionSlice"; import { exitEditMode } from "../../redux/thunks"; import { @@ -108,11 +109,6 @@ const InputBoxDiv = styled.div<{ border?: string }>` flex-direction: column; `; -const PaddingDiv = styled.div` - padding: 8px 12px; - padding-bottom: 4px; -`; - const HoverDiv = styled.div` position: absolute; width: 100%; @@ -180,6 +176,7 @@ interface TipTapEditorProps { border?: string; placeholder?: string; historyKey: string; + inputId: string; } export const TIPPY_DIV_ID = "tippy-js-div"; @@ -782,22 +779,6 @@ function TipTapEditor(props: TipTapEditorProps) { return; } - // const rif: RangeInFile & { contents: string } = - // data.rangeInFileWithContents; - // const basename = getBasename(rif.filepath); - // const relativePath = getRelativePath( - // rif.filepath, - // await ideMessenger.ide.getWorkspaceDirs(), - // const rangeStr = `(${rif.range.start.line + 1}-${ - // rif.range.end.line + 1 - // })`; - - // const itemName = `${basename} ${rangeStr}`; - // const item: ContextItemWithId = { - // content: rif.contents, - // name: itemName - // } - const contextItem = rifWithContentsToContextItem( data.rangeInFileWithContents, ); @@ -819,10 +800,16 @@ function TipTapEditor(props: TipTapEditorProps) { type: "codeBlock", attrs: { item: contextItem, + inputId: props.inputId, }, }) .run(); - + dispatch( + setNewestCodeblocksForInput({ + inputId: props.inputId, + contextItemId: contextItem.id.itemId, + }), + ); if (data.prompt) { editor.commands.focus("end"); editor.commands.insertContent(data.prompt); @@ -990,8 +977,9 @@ function TipTapEditor(props: TipTapEditorProps) { event.preventDefault(); }} > - +
{ @@ -1023,7 +1011,7 @@ function TipTapEditor(props: TipTapEditorProps) { }} disabled={isStreaming} /> - +
{showDragOverMsg && modelSupportsImages( diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx index 62565e5ea..3584a5d47 100644 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ b/gui/src/components/markdown/CodeSnippetPreview.tsx @@ -1,11 +1,11 @@ import { ChevronDownIcon, - ChevronUpIcon, + EyeSlashIcon, XMarkIcon, } from "@heroicons/react/24/outline"; import { ContextItemWithId } from "core"; import { dedent, getMarkdownLanguageTagForFile } from "core/util"; -import React, { useContext, useMemo } from "react"; +import { useContext, useEffect, useMemo, useRef, useState } from "react"; import styled from "styled-components"; import { defaultBorderRadius, lightGray, vscEditorBackground } from ".."; import { IdeMessengerContext } from "../../context/IdeMessenger"; @@ -14,6 +14,8 @@ import FileIcon from "../FileIcon"; import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; import StyledMarkdownPreview from "./StyledMarkdownPreview"; import { ctxItemToRifWithContents } from "core/commands/util"; +import { EyeIcon } from "@heroicons/react/24/solid"; +import { useAppSelector } from "../../redux/hooks"; const PreviewMarkdownDiv = styled.div<{ borderColor?: string; @@ -31,32 +33,30 @@ const PreviewMarkdownDiv = styled.div<{ } `; -const PreviewMarkdownHeader = styled.div` - margin: 0; - padding: 2px 6px; - border-bottom: 0.5px solid ${lightGray}; - word-break: break-all; - font-size: ${getFontSize() - 3}px; - display: flex; - align-items: center; -`; - interface CodeSnippetPreviewProps { item: ContextItemWithId; onDelete?: () => void; borderColor?: string; - hideHeader?: boolean; + inputId: string; } -const MAX_PREVIEW_HEIGHT = 300; +const MAX_PREVIEW_HEIGHT = 100; const backticksRegex = /`{3,}/gm; function CodeSnippetPreview(props: CodeSnippetPreviewProps) { const ideMessenger = useContext(IdeMessengerContext); - const [collapsed, setCollapsed] = React.useState(true); - const [hovered, setHovered] = React.useState(false); + const [localHidden, setLocalHidden] = useState(); + const [isSizeLimited, setIsSizeLimited] = useState(true); + + const newestCodeblockForInputId = useAppSelector( + (store) => store.session.newestCodeblockForInput[props.inputId], + ); + console.log(newestCodeblockForInputId); + const hidden = useMemo(() => { + return localHidden ?? newestCodeblockForInputId !== props.item.id.itemId; + }, [localHidden, newestCodeblockForInputId, props.item]); const content = useMemo(() => { return dedent`${props.item.content}`; @@ -67,65 +67,100 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { return backticks ? backticks.sort().at(-1) + "`" : "```"; }, [content]); - const codeBlockRef = React.useRef(null); + const codeBlockRef = useRef(null); + + // Track codeblock dimensions + const [codeblockDims, setCodeblockDims] = useState({ width: 0, height: 0 }); + useEffect(() => { + const resizeObserver = new ResizeObserver(() => { + setCodeblockDims({ + width: codeBlockRef.current?.scrollWidth ?? 0, + height: codeBlockRef.current?.scrollHeight ?? 0, + }); + }); + + if (codeBlockRef.current) { + resizeObserver.observe(codeBlockRef.current); + } + + return () => { + resizeObserver.disconnect(); + }; + }, [codeBlockRef]); // Empty dependency array to run once return ( setHovered(true)} - onMouseLeave={() => setHovered(false)} borderColor={props.borderColor} className="find-widget-skip" > - {!props.hideHeader && ( - { - if ( - props.item.id.providerTitle === "file" && - props.item.uri?.value - ) { - ideMessenger.post("showFile", { - filepath: props.item.uri.value, - }); - } else if (props.item.id.providerTitle === "code") { - const rif = ctxItemToRifWithContents(props.item, true); - ideMessenger.ide.showLines( - rif.filepath, - rif.range.start.line, - rif.range.end.line, - ); - } else { - ideMessenger.post("showVirtualFile", { - content, - name: props.item.name, - }); - } - }} - > -
- - {props.item.name} -
-
- { - e.stopPropagation(); - props.onDelete?.(); - }} - > - - -
-
- )} +
{ + if (props.item.id.providerTitle === "file" && props.item.uri?.value) { + ideMessenger.post("showFile", { + filepath: props.item.uri.value, + }); + } else if (props.item.id.providerTitle === "code") { + const rif = ctxItemToRifWithContents(props.item, true); + ideMessenger.ide.showLines( + rif.filepath, + rif.range.start.line, + rif.range.end.line, + ); + } else { + ideMessenger.post("showVirtualFile", { + content, + name: props.item.name, + }); + } + }} + > +
+ + {props.item.name} +
+
+ { + e.stopPropagation(); + }} + > + {hidden ? ( + setLocalHidden(false)} + width="1em" + height="1em" + /> + ) : ( + setLocalHidden(true)} + width="1em" + height="1em" + /> + )} + + { + e.stopPropagation(); + props.onDelete?.(); + }} + > + + +
+
- {(codeBlockRef.current?.scrollHeight ?? 0) > MAX_PREVIEW_HEIGHT && ( + {codeblockDims.height > MAX_PREVIEW_HEIGHT && ( - {collapsed ? ( - setCollapsed(false)} - /> - ) : ( - setCollapsed(true)} - /> - )} + setIsSizeLimited((v) => !v)} + /> )}
diff --git a/gui/src/editorInset/EditorInset.tsx b/gui/src/editorInset/EditorInset.tsx index 43942ea0c..3e90926b1 100644 --- a/gui/src/editorInset/EditorInset.tsx +++ b/gui/src/editorInset/EditorInset.tsx @@ -36,6 +36,7 @@ function EditorInset() { console.log("Enter: ", e, modifiers); }} historyKey="chat" + inputId="editor-inset" /> ); diff --git a/gui/src/index.css b/gui/src/index.css index 93ccd384f..4aa5f0a2f 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -102,3 +102,32 @@ body { direction: rtl; width: 100%; } + +.scroll-container { + overflow-y: auto; /* Enable vertical scrolling only if needed */ + scrollbar-width: thin; /* Firefox */ + padding-right: 4px; +} + +.scroll-container::-webkit-scrollbar { + width: 8px; +} + +.scroll-container::-webkit-scrollbar-track { + background: #f1f1f1; + border-radius: 4px; +} + +.scroll-container::-webkit-scrollbar-thumb { + background-color: #888; + border-radius: 4px; + transition: background-color 0.3s ease; +} + +.scroll-container::-webkit-scrollbar-thumb:hover { + background-color: #555; +} + +.scroll-container:is(:hover, :focus)::-webkit-scrollbar { + display: block; /* Show scrollbar only on hover or focus */ +} diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 1bb5f5714..7184a3be7 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -407,6 +407,7 @@ export function Chat() { isMainInput={false} editorState={item.editorState} contextItems={item.contextItems} + inputId={item.message.id} /> ) : item.message.role === "tool" ? ( @@ -503,6 +504,7 @@ export function Chat() { onEnter={(editorState, modifiers, editor) => sendInput(editorState, modifiers, undefined, editor) } + inputId={"main-editor"} /> )} diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 33ba33f59..1443247c4 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -57,6 +57,7 @@ type SessionState = { states: ApplyState[]; curIndex: number; }; + newestCodeblockForInput: Record; }; function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) { @@ -108,6 +109,7 @@ const initialState: SessionState = { curIndex: 0, }, lastSessionId: undefined, + newestCodeblockForInput: {}, }; export const sessionSlice = createSlice({ @@ -626,6 +628,17 @@ export const sessionSlice = createSlice({ setMode: (state, action: PayloadAction) => { state.mode = action.payload; }, + setNewestCodeblocksForInput: ( + state, + { + payload, + }: PayloadAction<{ + inputId: string; + contextItemId: string; + }>, + ) => { + state.newestCodeblockForInput[payload.inputId] = payload.contextItemId; + }, }, selectors: { selectIsGatheringContext: (state) => { @@ -724,6 +737,7 @@ export const { addSessionMetadata, updateSessionMetadata, deleteSessionMetadata, + setNewestCodeblocksForInput, } = sessionSlice.actions; export const { From 8fefd587e9054805cfea5c7c0fdc4a21818240bd Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 29 Jan 2025 19:28:13 -0800 Subject: [PATCH 08/29] cleanup --- gui/src/components/mainInput/CodeBlockComponent.tsx | 1 - gui/src/components/markdown/CodeSnippetPreview.tsx | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gui/src/components/mainInput/CodeBlockComponent.tsx b/gui/src/components/mainInput/CodeBlockComponent.tsx index 1e7e8f72c..61403a261 100644 --- a/gui/src/components/mainInput/CodeBlockComponent.tsx +++ b/gui/src/components/mainInput/CodeBlockComponent.tsx @@ -7,7 +7,6 @@ export const CodeBlockComponent = (props: any) => { const { node, deleteNode, selected, editor, updateAttributes } = props; const item: ContextItemWithId = node.attrs.item; const inputId = node.attrs.inputId; - // const newestCodeblockId = // const contextItems = useSelector( // (store: RootState) => // store.session.messages[store.session.messages.length - 1].contextItems, diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx index 3584a5d47..f03b1a5ba 100644 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ b/gui/src/components/markdown/CodeSnippetPreview.tsx @@ -53,7 +53,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { const newestCodeblockForInputId = useAppSelector( (store) => store.session.newestCodeblockForInput[props.inputId], ); - console.log(newestCodeblockForInputId); + const hidden = useMemo(() => { return localHidden ?? newestCodeblockForInputId !== props.item.id.itemId; }, [localHidden, newestCodeblockForInputId, props.item]); @@ -69,7 +69,6 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { const codeBlockRef = useRef(null); - // Track codeblock dimensions const [codeblockDims, setCodeblockDims] = useState({ width: 0, height: 0 }); useEffect(() => { const resizeObserver = new ResizeObserver(() => { @@ -86,7 +85,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { return () => { resizeObserver.disconnect(); }; - }, [codeBlockRef]); // Empty dependency array to run once + }, [codeBlockRef]); return ( Date: Thu, 30 Jan 2025 10:18:27 -0800 Subject: [PATCH 09/29] clicking on header collapses, file click more specifici --- .../markdown/CodeSnippetPreview.tsx | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx index f03b1a5ba..06717c5ee 100644 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ b/gui/src/components/markdown/CodeSnippetPreview.tsx @@ -99,48 +99,44 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { fontSize: getFontSize() - 3, }} onClick={() => { - if (props.item.id.providerTitle === "file" && props.item.uri?.value) { - ideMessenger.post("showFile", { - filepath: props.item.uri.value, - }); - } else if (props.item.id.providerTitle === "code") { - const rif = ctxItemToRifWithContents(props.item, true); - ideMessenger.ide.showLines( - rif.filepath, - rif.range.start.line, - rif.range.end.line, - ); - } else { - ideMessenger.post("showVirtualFile", { - content, - name: props.item.name, - }); - } + setLocalHidden(!hidden); }} > -
+
{ + e.stopPropagation(); + if ( + props.item.id.providerTitle === "file" && + props.item.uri?.value + ) { + ideMessenger.post("showFile", { + filepath: props.item.uri.value, + }); + } else if (props.item.id.providerTitle === "code") { + const rif = ctxItemToRifWithContents(props.item, true); + ideMessenger.ide.showLines( + rif.filepath, + rif.range.start.line, + rif.range.end.line, + ); + } else { + ideMessenger.post("showVirtualFile", { + content, + name: props.item.name, + }); + } + }} + > {props.item.name}
- { - e.stopPropagation(); - }} - > + {hidden ? ( - setLocalHidden(false)} - width="1em" - height="1em" - /> + ) : ( - setLocalHidden(true)} - width="1em" - height="1em" - /> + )} Date: Fri, 31 Jan 2025 11:28:31 -0800 Subject: [PATCH 10/29] feat: org select --- core/core.ts | 2 +- gui/src/components/gui/Switch.tsx | 33 +++ gui/src/pages/config/ScopeSelect.tsx | 58 +++++ gui/src/pages/config/index.tsx | 371 +++++++++++++++++++++++++++ 4 files changed, 463 insertions(+), 1 deletion(-) create mode 100644 gui/src/components/gui/Switch.tsx create mode 100644 gui/src/pages/config/ScopeSelect.tsx create mode 100644 gui/src/pages/config/index.tsx diff --git a/core/core.ts b/core/core.ts index 3aa8f0393..5cedac188 100644 --- a/core/core.ts +++ b/core/core.ts @@ -19,6 +19,7 @@ import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFile import { ContinueServerClient } from "./continueServer/stubs/client"; import { getAuthUrlForTokenPage } from "./control-plane/auth/index"; import { ControlPlaneClient } from "./control-plane/client"; +import { getControlPlaneEnv } from "./control-plane/env"; import { streamDiffLines } from "./edit/streamDiffLines"; import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer"; import DocsService from "./indexing/docs/DocsService"; @@ -52,7 +53,6 @@ import { type IndexingProgressUpdate, } from "."; -import { getControlPlaneEnv } from "./control-plane/env"; import type { FromCoreProtocol, ToCoreProtocol } from "./protocol"; import type { IMessenger, Message } from "./protocol/messenger"; diff --git a/gui/src/components/gui/Switch.tsx b/gui/src/components/gui/Switch.tsx new file mode 100644 index 000000000..7d6105e6d --- /dev/null +++ b/gui/src/components/gui/Switch.tsx @@ -0,0 +1,33 @@ +import React from "react"; + +type ToggleSwitchProps = { + isToggled: boolean; + onToggle: () => void; + text: string; +}; + +const ToggleSwitch: React.FC = ({ + isToggled, + onToggle, + text, +}) => { + return ( +
+ {text} +
+
+
+
+
+
+
+
+ ); +}; + +export default ToggleSwitch; diff --git a/gui/src/pages/config/ScopeSelect.tsx b/gui/src/pages/config/ScopeSelect.tsx new file mode 100644 index 000000000..b6798b012 --- /dev/null +++ b/gui/src/pages/config/ScopeSelect.tsx @@ -0,0 +1,58 @@ +import { Listbox } from "@headlessui/react"; +import { + ChevronDownIcon, + UserCircleIcon, + CubeIcon, +} from "@heroicons/react/24/outline"; +import { useState } from "react"; + +export function ScopeSelect() { + const [value, setValue] = useState(""); + const [showAbove, setShowAbove] = useState(false); + + return ( + +
+ +
+
+ + Continue +
+
+
+ + +
+ Organizations +
+ + +
+ + Continue +
+
+ +
+ + +
+ + Personal +
+
+ +
+ + ); +} diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx new file mode 100644 index 000000000..374ee1b42 --- /dev/null +++ b/gui/src/pages/config/index.tsx @@ -0,0 +1,371 @@ +import { useContext, useEffect, useState } from "react"; +import { useNavigate } from "react-router-dom"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useNavigationListener } from "../../hooks/useNavigationListener"; +import PageHeader from "../../components/PageHeader"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; + +import { updateConfig } from "../../redux/slices/configSlice"; +import ToggleSwitch from "../../components/gui/Switch"; +import { useAuth } from "../../context/Auth"; +import { Input, SecondaryButton, Select } from "../../components"; +import { getFontSize } from "../../util"; +import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; +import { ScopeSelect } from "./ScopeSelect"; + +function ConfigPage() { + useNavigationListener(); + const dispatch = useAppDispatch(); + const navigate = useNavigate(); + const ideMessenger = useContext(IdeMessengerContext); + + const { selectedProfile } = useAuth(); + const config = useAppSelector((state) => state.config.config); + + function handleUpdate(sharedConfig: Partial) { + dispatch( + updateConfig(modifyContinueConfigWithSharedConfig(config, sharedConfig)), + ); + ideMessenger.post("config/updateSharedConfig", sharedConfig); + } + + 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 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; + } + ideMessenger.post("config/openProfile", { + profileId: selectedProfile.id, + }); + } + + if (!selectedProfile) { + return ( +
+ navigate("/")} title="Chat" /> +
+
+

Continue Config

+
+

No config profile selected

+
+
+ ); + } + + return ( +
+ navigate("/")} title="Chat" /> + +
+
+
+

Account

+ + You are currently signed in to{" "} + ORG_NAME + +
+ + +
+ +
+

Configuration

+ + + Open configuration file + +
+ +
+
+

User settings

+
+ +
+ + 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(); + handleSubmitPromptPath(); + }} + > + +
+ +
{ + e.preventDefault(); + handleDisableAutocompleteSubmit(); + }} + > + + + Comma-separated list of path matchers + +
+
+
+
+
+ ); +} + +export default ConfigPage; From b78fdc4147e1ccb388b900a65099a2c61ba6ca26 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 31 Jan 2025 13:19:59 -0800 Subject: [PATCH 11/29] feat: add scope selector --- core/config/ProfileLifecycleManager.ts | 6 + .../profile/ControlPlaneProfileLoader.ts | 5 +- core/config/profile/LocalProfileLoader.ts | 4 +- core/control-plane/client.ts | 46 +++-- core/core.ts | 4 + core/protocol/core.ts | 10 +- core/protocol/passThrough.ts | 1 + .../constants/MessageTypes.kt | 4 +- extensions/vscode/package-lock.json | 4 +- .../platform/AssistantSelect.tsx | 8 +- gui/src/context/Auth.tsx | 41 ++++- gui/src/pages/config/ScopeSelect.tsx | 69 +++++--- gui/src/pages/config/index.tsx | 166 ++++++++++-------- gui/src/redux/slices/sessionSlice.ts | 45 ++++- gui/src/redux/store.ts | 7 +- 15 files changed, 294 insertions(+), 126 deletions(-) diff --git a/core/config/ProfileLifecycleManager.ts b/core/config/ProfileLifecycleManager.ts index 8216153ae..07c6a2c7d 100644 --- a/core/config/ProfileLifecycleManager.ts +++ b/core/config/ProfileLifecycleManager.ts @@ -23,6 +23,12 @@ export interface ProfileDescription { errors: ConfigValidationError[] | undefined; } +export interface OrganizationDescription { + id: string; + iconUrl: string; + name: string; +} + export class ProfileLifecycleManager { private savedConfigResult: ConfigResult | undefined; private savedBrowserConfigResult?: ConfigResult; diff --git a/core/config/profile/ControlPlaneProfileLoader.ts b/core/config/profile/ControlPlaneProfileLoader.ts index dfb111e1f..6df837cf4 100644 --- a/core/config/profile/ControlPlaneProfileLoader.ts +++ b/core/config/profile/ControlPlaneProfileLoader.ts @@ -1,4 +1,5 @@ import { ConfigJson } from "@continuedev/config-types"; +import { ConfigResult } from "@continuedev/config-yaml"; import { ControlPlaneClient } from "../../control-plane/client.js"; import { @@ -7,9 +8,8 @@ import { IdeSettings, SerializedContinueConfig, } from "../../index.js"; - -import { ConfigResult } from "@continuedev/config-yaml"; import { ProfileDescription } from "../ProfileLifecycleManager.js"; + import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; @@ -32,6 +32,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader { this.description = { id: workspaceId, profileType: "control-plane", + iconUrl: "", fullSlug: { ownerSlug: "", packageSlug: "", diff --git a/core/config/profile/LocalProfileLoader.ts b/core/config/profile/LocalProfileLoader.ts index cb8694bbc..3196faff4 100644 --- a/core/config/profile/LocalProfileLoader.ts +++ b/core/config/profile/LocalProfileLoader.ts @@ -1,8 +1,9 @@ import { ConfigResult } from "@continuedev/config-yaml"; + import { ControlPlaneClient } from "../../control-plane/client.js"; import { ContinueConfig, IDE, IdeSettings } from "../../index.js"; - import { ProfileDescription } from "../ProfileLifecycleManager.js"; + import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; @@ -16,6 +17,7 @@ export default class LocalProfileLoader implements IProfileLoader { packageSlug: "", versionSlug: "", }, + iconUrl: "", title: "Local Config", errors: undefined, }; diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 6200bc8de..7c15c8910 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -1,8 +1,4 @@ import { ConfigJson } from "@continuedev/config-types"; -import fetch, { RequestInit, Response } from "node-fetch"; - -import { IdeSettings, ModelDescription } from "../index.js"; - import { AssistantUnrolled, ConfigResult, @@ -10,6 +6,11 @@ import { FullSlug, SecretResult, } from "@continuedev/config-yaml"; +import fetch, { RequestInit, Response } from "node-fetch"; + +import { OrganizationDescription } from "../config/ProfileLifecycleManager.js"; +import { IdeSettings, ModelDescription } from "../index.js"; + import { getControlPlaneEnv } from "./env.js"; export interface ControlPlaneSessionInfo { @@ -32,10 +33,6 @@ export const TRIAL_PROXY_URL = "https://proxy-server-blue-l6vsfbzhba-uw.a.run.app"; export class ControlPlaneClient { - private static ACCESS_TOKEN_VALID_FOR_MS = 1000 * 60 * 5; // 5 minutes - - private lastAccessTokenRefresh = 0; - constructor( private readonly sessionInfoPromise: Promise< ControlPlaneSessionInfo | undefined @@ -107,7 +104,7 @@ export class ControlPlaneClient { } } - public async listAssistants(): Promise< + public async listAssistants(organizationId?: string): Promise< { configResult: ConfigResult; ownerSlug: string; @@ -121,7 +118,11 @@ export class ControlPlaneClient { } try { - const resp = await this.request("ide/list-assistants", { + const url = organizationId + ? `ide/list-assistants?organizationId=${organizationId}` + : "ide/list-assistants"; + + const resp = await this.request(url, { method: "GET", }); return (await resp.json()) as any; @@ -130,6 +131,31 @@ export class ControlPlaneClient { } } + public async listOrganizations(): Promise> { + return [ + { + id: "1", + iconUrl: + "https://cdn.prod.website-files.com/663e06c56841363663ffbbcf/663e1b9fb023f0b622ad3608_log-text.svg", + name: "Continue", + }, + ]; + // const userId = await this.userId; + // if (!userId) { + // return []; + // } + + // try { + // const resp = await this.request("ide/list-organizations", { + // method: "GET", + // }); + // const { organizations } = (await resp.json()) as any; + // return organizations; + // } catch (e) { + // return []; + // } + } + public async listAssistantFullSlugs(): Promise { const userId = await this.userId; if (!userId) { diff --git a/core/core.ts b/core/core.ts index e5bff1f31..b55feafb2 100644 --- a/core/core.ts +++ b/core/core.ts @@ -307,6 +307,10 @@ export class Core { await this.messenger.request("openUrl", `${env.APP_URL}${msg.data.path}`); }); + on("controlPlane/listOrganizations", async (msg) => { + return await this.controlPlaneClient.listOrganizations(); + }); + // Context providers on("context/addDocs", async (msg) => { void this.docsService.indexAndAdd(msg.data); diff --git a/core/protocol/core.ts b/core/protocol/core.ts index ce24dfcbb..64bc5f5d4 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -1,4 +1,10 @@ import { ConfigResult } from "@continuedev/config-yaml"; + +import { AutocompleteInput } from "../autocomplete/util/types"; +import { ProfileDescription } from "../config/ConfigHandler"; +import { OrganizationDescription } from "../config/ProfileLifecycleManager"; +import { SharedConfigSchema } from "../config/sharedConfig"; + import type { BrowserSerializedContinueConfig, ChatMessage, @@ -21,9 +27,6 @@ import type { SiteIndexingConfig, ToolCall, } from "../"; -import { AutocompleteInput } from "../autocomplete/util/types"; -import { ProfileDescription } from "../config/ConfigHandler"; -import { SharedConfigSchema } from "../config/sharedConfig"; export type OnboardingModes = | "Local" @@ -195,4 +198,5 @@ export type ToCoreFromIdeOrWebviewProtocol = { ]; "clipboardCache/add": [{ content: string }, void]; "controlPlane/openUrl": [{ path: string }, void]; + "controlPlane/listOrganizations": [undefined, OrganizationDescription[]]; }; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 0ce81bfe8..edf079157 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -61,6 +61,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "didChangeSelectedProfile", "tools/call", "controlPlane/openUrl", + "controlPlane/listOrganizations", ]; // Message types to pass through from core to webview diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 2388ce8ab..873add597 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -117,7 +117,9 @@ class MessageTypes { "profiles/switch", "didChangeSelectedProfile", "tools/call", - "controlPlane/openUrl" + "controlPlane/openUrl", + "controlPlane/listOrganizations" + ) } } \ No newline at end of file diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 4ca866899..19a191f06 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.256", + "version": "0.9.258", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.256", + "version": "0.9.258", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 248beee42..f1216ac3f 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -1,10 +1,6 @@ import { Popover } from "@headlessui/react"; -import { - ChevronDownIcon, - ComputerDesktopIcon, - SparklesIcon, -} from "@heroicons/react/24/outline"; -import { cloneElement, useEffect, useRef } from "react"; +import { ChevronDownIcon } from "@heroicons/react/24/outline"; +import { useEffect, useRef } from "react"; import { useAuth } from "../../../context/Auth"; import { useAppDispatch } from "../../../redux/hooks"; import { cycleProfile } from "../../../redux/thunks/cycleProfile"; diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx index c81aa1bc1..23fc76c85 100644 --- a/gui/src/context/Auth.tsx +++ b/gui/src/context/Auth.tsx @@ -1,4 +1,7 @@ -import { ProfileDescription } from "core/config/ProfileLifecycleManager"; +import { + OrganizationDescription, + ProfileDescription, +} from "core/config/ProfileLifecycleManager"; import { ControlPlaneSessionInfo } from "core/control-plane/client"; import React, { createContext, @@ -28,6 +31,8 @@ interface AuthContextType { selectedProfile: ProfileDescription | undefined; profiles: ProfileDescription[]; controlServerBetaEnabled: boolean; + organizations: OrganizationDescription[]; + selectedOrganization: OrganizationDescription | undefined; } const AuthContext = createContext(undefined); @@ -39,6 +44,18 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ undefined, ); + const [organizations, setOrganizations] = useState( + [], + ); + + const selectedOrganizationId = useAppSelector( + (store) => store.session.selectedOrganizationId, + ); + + const selectedOrganization = useMemo(() => { + return organizations.find((p) => p.id === selectedOrganizationId); + }, [organizations, selectedOrganizationId]); + const profiles = useAppSelector(selectAvailableProfiles); const selectedProfileId = useAppSelector( @@ -51,10 +68,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ const ideMessenger = useContext(IdeMessengerContext); const dispatch = useDispatch(); - const lastControlServerBetaEnabledStatus = useAppSelector( - (state) => state.misc.lastControlServerBetaEnabledStatus, - ); - const login: AuthContextType["login"] = (useOnboarding: boolean) => { return new Promise((resolve) => { ideMessenger @@ -142,11 +155,23 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ enableControlServerBeta || continueTestEnvironment !== "none"; setControlServerBetaEnabled(enabled); dispatch(setLastControlServerBetaEnabledStatus(enabled)); - - const shouldShowPopup = !lastControlServerBetaEnabledStatus && enabled; }); }, []); + useEffect(() => { + if (session) { + ideMessenger + .request("controlPlane/listOrganizations", undefined) + .then((result) => { + if (result.status === "success") { + setOrganizations(result.content); + } + }); + } else { + setOrganizations([]); + } + }, [session]); + useWebviewListener( "didChangeIdeSettings", async (msg) => { @@ -185,6 +210,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ login, selectedProfile, profiles, + selectedOrganization, + organizations, controlServerBetaEnabled, }} > diff --git a/gui/src/pages/config/ScopeSelect.tsx b/gui/src/pages/config/ScopeSelect.tsx index b6798b012..773ad180f 100644 --- a/gui/src/pages/config/ScopeSelect.tsx +++ b/gui/src/pages/config/ScopeSelect.tsx @@ -1,3 +1,5 @@ +// gui/src/pages/config/ScopeSelect.tsx + import { Listbox } from "@headlessui/react"; import { ChevronDownIcon, @@ -5,46 +7,73 @@ import { CubeIcon, } from "@heroicons/react/24/outline"; import { useState } from "react"; +import { useAuth } from "../../context/Auth"; +import { useDispatch } from "react-redux"; +import { setSelectedOrganizationId } from "../../redux/slices/sessionSlice"; export function ScopeSelect() { - const [value, setValue] = useState(""); - const [showAbove, setShowAbove] = useState(false); + const { organizations, selectedOrganization } = useAuth(); + const [value, setValue] = useState( + selectedOrganization?.id || "personal", + ); + const dispatch = useDispatch(); + + const handleChange = (newValue: string) => { + setValue(newValue); + dispatch( + setSelectedOrganizationId(newValue === "personal" ? null : newValue), + ); + }; + const selectedDisplay = + value === "personal" + ? { name: "Personal", iconUrl: null } + : organizations.find((org) => org.id === value); return ( - +
- - Continue + {selectedDisplay?.iconUrl ? ( + + ) : ( + + )} + + {selectedDisplay?.name || "Select Organization"} +
- -
+ +
Organizations
- - -
- - Continue -
-
+ {organizations.map((org) => ( + +
+ {org.iconUrl ? ( + + ) : ( + + )} + {org.name} +
+
+ ))}
diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index 374ee1b42..761bd6e3a 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -8,10 +8,16 @@ import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { updateConfig } from "../../redux/slices/configSlice"; import ToggleSwitch from "../../components/gui/Switch"; import { useAuth } from "../../context/Auth"; -import { Input, SecondaryButton, Select } from "../../components"; +import { Input, SecondaryButton } from "../../components"; import { getFontSize } from "../../util"; import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; import { ScopeSelect } from "./ScopeSelect"; +import { + SharedConfigSchema, + modifyContinueConfigWithSharedConfig, +} from "core/config/sharedConfig"; +import NumberInput from "../../components/gui/NumberInput"; +import { Select } from "../../components/gui/Select"; function ConfigPage() { useNavigationListener(); @@ -19,7 +25,7 @@ function ConfigPage() { const navigate = useNavigate(); const ideMessenger = useContext(IdeMessengerContext); - const { selectedProfile } = useAuth(); + const { selectedProfile, selectedOrganization } = useAuth(); const config = useAppSelector((state) => state.config.config); function handleUpdate(sharedConfig: Partial) { @@ -99,7 +105,7 @@ function ConfigPage() { if (!selectedProfile) { return (
- navigate("/")} title="Chat" /> + navigate("/")} title="Chat" />

Continue Config

@@ -112,16 +118,20 @@ function ConfigPage() { return (
- navigate("/")} title="Chat" /> + navigate("/")} title="Chat" />

Account

- - You are currently signed in to{" "} - ORG_NAME - + {selectedOrganization?.name && ( + + You are currently signed in to{" "} + + {selectedOrganization?.name} + + + )}
@@ -277,87 +287,103 @@ function ConfigPage() { /> +
{ e.preventDefault(); handleSubmitPromptPath(); }} > -