From 8ecff56c533072ce40bd3d09066da969cc766823 Mon Sep 17 00:00:00 2001 From: boowangoo Date: Tue, 21 Jan 2025 18:25:34 -0500 Subject: [PATCH 01/26] 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/26] 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/26] 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/26] 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/26] 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) => (