From 8ecff56c533072ce40bd3d09066da969cc766823 Mon Sep 17 00:00:00 2001 From: boowangoo Date: Tue, 21 Jan 2025 18:25:34 -0500 Subject: [PATCH 01/42] 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/42] 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 9ca4ad4afe04fbfc3a6e0e6d447dd81ff22b4369 Mon Sep 17 00:00:00 2001 From: Tom X Nguyen Date: Mon, 27 Jan 2025 02:55:44 +0700 Subject: [PATCH 03/42] fix: gemini tool calls with MCP --- core/llm/llms/Gemini.ts | 111 +++++++++++++++++++++++++++++++--------- 1 file changed, 87 insertions(+), 24 deletions(-) diff --git a/core/llm/llms/Gemini.ts b/core/llm/llms/Gemini.ts index c0940dbfd..cbecfdcdc 100644 --- a/core/llm/llms/Gemini.ts +++ b/core/llm/llms/Gemini.ts @@ -251,9 +251,45 @@ class Gemini extends BaseLLM { return; } } + // Helper function to recursively clean JSON Schema objects + const cleanJsonSchema = (schema: any): any => { + if (!schema || typeof schema !== 'object') return schema; + + if (Array.isArray(schema)) { + return schema.map(cleanJsonSchema); + } + + const { + $schema, + additionalProperties, + default: defaultValue, + ...rest + } = schema; + + // Recursively clean nested properties + if (rest.properties) { + rest.properties = Object.entries(rest.properties).reduce( + (acc, [key, value]) => ({ + ...acc, + [key]: cleanJsonSchema(value), + }), + {} + ); + } + + // Clean items in arrays + if (rest.items) { + rest.items = cleanJsonSchema(rest.items); + } + + return rest; + }; + + // Clean the parameters and convert type to uppercase + const cleanedParams = cleanJsonSchema(tool.function.parameters); fn.parameters = { + ...cleanedParams, type: tool.function.parameters.type.toUpperCase(), - ...tool.function.parameters, }; } functions.push(fn); @@ -311,11 +347,16 @@ class Gemini extends BaseLLM { const supportedParts: MessagePart[] = []; const toolCalls: ToolCallDelta[] = []; + // Process all parts first to maintain order + const processedParts: Array<{ + type: 'content' | 'tool' | 'toolCall', + data: any + }> = []; + for (const part of content.parts) { if ("text" in part) { supportedParts.push({ type: "text", text: part.text }); } else if ("inlineData" in part) { - // TODO does this image url conversion actually work? supportedParts.push({ type: "imageUrl", imageUrl: { @@ -323,38 +364,60 @@ class Gemini extends BaseLLM { }, }); } else if ("functionCall" in part) { - // Handle function call - toolCalls.push({ - type: "function", - id: "", // Not supported by gemini - function: { - name: part.functionCall.name, - arguments: - typeof part.functionCall.args === "string" - ? part.functionCall.args - : JSON.stringify(part.functionCall.args), - }, + // Queue function call + processedParts.push({ + type: 'toolCall', + data: { + type: "function", + id: "", // Not supported by gemini + function: { + name: part.functionCall.name, + arguments: + typeof part.functionCall.args === "string" + ? part.functionCall.args + : JSON.stringify(part.functionCall.args), + }, + } }); } else if ("functionResponse" in part) { - // TODO hypothetically order could be off here - // Where function response is in the middle of something - yield { - role: "tool", - content: part.functionResponse.response.output as string, - toolCallId: part.functionResponse.name, - }; + // Queue function response + processedParts.push({ + type: 'tool', + data: { + role: "tool", + content: part.functionResponse.response.output as string, + toolCallId: part.functionResponse.name, + } + }); } else { console.warn("Unsupported gemini part type received", part); } } - if (supportedParts.length || toolCalls.length) { - // Incrementally stream the content to make it smoother + + // If we have supported content parts, yield them first + if (supportedParts.length) { yield { role: "assistant", - content: supportedParts.length ? supportedParts : "", - ...(toolCalls.length ? { toolCalls } : {}), + content: supportedParts, }; } + + // Then process tool calls and responses in order + for (const part of processedParts) { + if (part.type === 'toolCall') { + yield { + role: "assistant", + content: "", + toolCalls: [part.data], + }; + // Add delay to ensure tool call is processed + await new Promise(resolve => setTimeout(resolve, 100)); + } else if (part.type === 'tool') { + // Add delay before tool response to ensure tool call was processed + await new Promise(resolve => setTimeout(resolve, 100)); + yield part.data; + } + } } else { // Handle the case where the expected data structure is not found console.warn("Unexpected response format:", data); From 92895eae5c88dae4f73e1dfd34f5dd0aae84d9af Mon Sep 17 00:00:00 2001 From: Sherman Boyd Date: Mon, 27 Jan 2025 13:52:55 -0700 Subject: [PATCH 04/42] Fancy keycaps for Tutorial Card --- gui/src/components/mainInput/TutorialCard.tsx | 4 +-- gui/src/index.css | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/gui/src/components/mainInput/TutorialCard.tsx b/gui/src/components/mainInput/TutorialCard.tsx index c94f63598..3eb0da2ef 100644 --- a/gui/src/components/mainInput/TutorialCard.tsx +++ b/gui/src/components/mainInput/TutorialCard.tsx @@ -69,14 +69,14 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
  • - Highlight code and press {getMetaKeyLabel() + "I"} to + Highlight code and press {getMetaKeyLabel()} + I to quickly make natural language edits
  • - Highlight code and press {getMetaKeyLabel() + "L"} to + Highlight code and press {getMetaKeyLabel()} + L to add it to the chat window
  • diff --git a/gui/src/index.css b/gui/src/index.css index ba8454b7b..f31f96f91 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -12,6 +12,18 @@ --vscode-editor-background: rgb(30, 30, 30); --vscode-editor-foreground: rgb(197, 200, 198); --vscode-textBlockQuote-background: rgba(255, 255, 255, 1); + + /* These vars control the colors of the kbd tag 3d keycap */ + --kbd-keycap-bg-color: #414859; + --kbd-keycap-border-color: #495265; + --kbd-text-color: #88b4b4; + --kbd-shadow-color: #2e3341; + --kbd-shadow-color-outer: #373e4b; + --kbd-shadow-tint: rgba(173, 212, 247, 0.4); + + /* Monospaced font for keycaps */ + --ifm-font-family-monospace: ui-monospace, SFMono-Regular, Menlo, Monaco, + Consolas, "Liberation Mono", "Courier New", monospace; } html, @@ -92,3 +104,27 @@ body { -webkit-line-clamp: 1; -webkit-box-orient: vertical; } + +kbd { + display: inline-block; + padding: 0.3em 0.4em; + margin: 0.1em 0.4em; + font-family: var( + --ifm-font-family-monospace + ); /* You might need to define this variable */ + font-size: 0.8rem; + font-weight: 500; + line-height: 0.8; + color: var(--kbd-text-color); + text-align: center; + white-space: nowrap; + background-color: var(--kbd-keycap-bg-color); + border: 1px solid var(--kbd-keycap-border-color); + border-radius: 0.3em; + box-shadow: + 0 2px 0 1px var(--kbd-shadow-color), + 0 3px 0 2px var(--kbd-shadow-color-outer), + 0 4px 6px var(--kbd-shadow-tint); + position: relative; + top: 0; +} From d02c6035aa4192e26fb9130d6dae066be2a380a8 Mon Sep 17 00:00:00 2001 From: Sherman Boyd Date: Tue, 28 Jan 2025 10:27:47 -0700 Subject: [PATCH 05/42] Remove CSS styling for --- gui/src/index.css | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/gui/src/index.css b/gui/src/index.css index f31f96f91..bef155dbd 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -8,22 +8,9 @@ --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); - - /* These vars control the colors of the kbd tag 3d keycap */ - --kbd-keycap-bg-color: #414859; - --kbd-keycap-border-color: #495265; - --kbd-text-color: #88b4b4; - --kbd-shadow-color: #2e3341; - --kbd-shadow-color-outer: #373e4b; - --kbd-shadow-tint: rgba(173, 212, 247, 0.4); - - /* Monospaced font for keycaps */ - --ifm-font-family-monospace: ui-monospace, SFMono-Regular, Menlo, Monaco, - Consolas, "Liberation Mono", "Courier New", monospace; } html, @@ -104,27 +91,3 @@ body { -webkit-line-clamp: 1; -webkit-box-orient: vertical; } - -kbd { - display: inline-block; - padding: 0.3em 0.4em; - margin: 0.1em 0.4em; - font-family: var( - --ifm-font-family-monospace - ); /* You might need to define this variable */ - font-size: 0.8rem; - font-weight: 500; - line-height: 0.8; - color: var(--kbd-text-color); - text-align: center; - white-space: nowrap; - background-color: var(--kbd-keycap-bg-color); - border: 1px solid var(--kbd-keycap-border-color); - border-radius: 0.3em; - box-shadow: - 0 2px 0 1px var(--kbd-shadow-color), - 0 3px 0 2px var(--kbd-shadow-color-outer), - 0 4px 6px var(--kbd-shadow-tint); - position: relative; - top: 0; -} From 46e75551b41c1b9649e7069650dd05ed196ea01e Mon Sep 17 00:00:00 2001 From: Zhaohan Dong <65422392+zhaohan-dong@users.noreply.github.com> Date: Tue, 28 Jan 2025 18:32:12 +0000 Subject: [PATCH 06/42] Update xAI.md --- docs/docs/customize/model-providers/top-level/xAI.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/customize/model-providers/top-level/xAI.md b/docs/docs/customize/model-providers/top-level/xAI.md index fbdfa83ad..550cc0641 100644 --- a/docs/docs/customize/model-providers/top-level/xAI.md +++ b/docs/docs/customize/model-providers/top-level/xAI.md @@ -11,15 +11,15 @@ You can get an API key from the [xAI console](https://console.x.ai/) ## Chat model -We recommend configuring **grok-beta** as your chat model. +We recommend configuring **grok-2-latest** as your chat model. For information on other available models, visit [xAI Documentation](https://docs.x.ai/docs/models). ```json title="config.json" { "models": [ { - "title": "Grok Beta", + "title": "Grok 2", "provider": "xAI", - "model": "grok-beta", + "model": "grok-2-latest", "apiKey": "[API_KEY]" } ] From 034094b20c07605b4dd9b0923c8387a95ca233da Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 28 Jan 2025 10:41:58 -0800 Subject: [PATCH 07/42] fix searchweb tool args --- core/tools/definitions/searchWeb.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tools/definitions/searchWeb.ts b/core/tools/definitions/searchWeb.ts index e5f2844cd..c5868f3e0 100644 --- a/core/tools/definitions/searchWeb.ts +++ b/core/tools/definitions/searchWeb.ts @@ -13,9 +13,9 @@ export const searchWebTool: Tool = { "Performs a web search, returning top results. This tool should only be called for questions that require external knowledge. Common programming questions do not require web search.", parameters: { type: "object", - required: ["repo_url"], + required: ["query"], properties: { - repo_url: { + query: { type: "string", description: "The natural language search query", }, From 3b539d53c39a98c361e27db6dfb72a8e14ddae50 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 28 Jan 2025 16:06:49 -0800 Subject: [PATCH 08/42] 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 09/42] 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 10/42] 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 14/42] 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: Wed, 29 Jan 2025 22:49:31 -0800 Subject: [PATCH 15/42] try again --- .github/workflows/pr_checks.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 81fb93701..77156499a 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -70,8 +70,8 @@ jobs: core-checks: needs: install-core runs-on: ubuntu-latest - # Tests requiring secrets need approval from maintainers - environment: ${{ github.event.pull_request.head.repo.fork && 'tests-requiring-secrets' || '' }} + # Tests requiring secrets need approval from maintainers. + environment: ${{ github.event.pull_request.head.repo.fork == true && 'tests-requiring-secrets' || '' }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 8b3b3e00da401466041960ff3018aad4b8b951e1 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 29 Jan 2025 23:00:04 -0800 Subject: [PATCH 16/42] use pr target --- .github/workflows/pr_checks.yaml | 82 +++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 77156499a..1d7170957 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -1,7 +1,7 @@ name: PR checks on: - pull_request: + pull_request_target: branches: - main paths: @@ -9,7 +9,6 @@ on: - "extensions/vscode/**" - "core/**" - "gui/**" - - ".github/workflows/**" push: branches: @@ -22,10 +21,21 @@ on: - ".github/workflows/**" jobs: + validate-pr: + runs-on: ubuntu-latest + environment: ${{ github.event.pull_request.head.repo.fork && 'tests-requiring-secrets' || '' }} + steps: + - uses: actions/checkout@v4 + install-root: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -45,6 +55,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -74,6 +89,11 @@ jobs: environment: ${{ github.event.pull_request.head.repo.fork == true && 'tests-requiring-secrets' || '' }} steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -103,6 +123,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -134,6 +159,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -164,6 +194,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -200,6 +235,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -233,6 +273,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -264,6 +309,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -290,6 +340,10 @@ jobs: test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }} steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Cache node modules uses: actions/cache@v3 @@ -317,6 +371,11 @@ jobs: needs: [install-vscode, install-core] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -349,6 +408,11 @@ jobs: needs: [install-vscode, install-core] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -397,6 +461,11 @@ jobs: command: ["e2e:ci:run", "e2e:ci:run-yaml"] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -459,6 +528,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -490,6 +564,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/cache@v4 with: From 6fd8ea7eb82c8768c57a2a7ad1b5561d7761c0fd Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 29 Jan 2025 23:02:11 -0800 Subject: [PATCH 17/42] improve spacing --- core/core.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/core.ts b/core/core.ts index 3aa8f0393..c52d4b076 100644 --- a/core/core.ts +++ b/core/core.ts @@ -289,6 +289,7 @@ export class Core { on("config/ideSettingsUpdate", (msg) => { this.configHandler.updateIdeSettings(msg.data); }); + on("config/listProfiles", (msg) => { return this.configHandler.listProfiles(); }); From 94d8769a2d07bdfc602876cb0e965b01143400c0 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 29 Jan 2025 23:06:50 -0800 Subject: [PATCH 18/42] update --- .github/workflows/pr_checks.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 1d7170957..f0e87df93 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -9,6 +9,7 @@ on: - "extensions/vscode/**" - "core/**" - "gui/**" + - ".github/workflows/**" push: branches: From aeb13882ef3ebdd3daf07985df89a949da04fa89 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 30 Jan 2025 10:18:27 -0800 Subject: [PATCH 19/42] 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 20/42] 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 e7be8781cddb165d60354f231bbbce3d7c0ad562 Mon Sep 17 00:00:00 2001 From: Tyler Merritt Date: Fri, 31 Jan 2025 15:18:57 -0600 Subject: [PATCH 21/42] add support for o3-mini --- core/llm/llms/Asksage.ts | 1 + core/llm/llms/OpenAI.ts | 13 +++++++------ .../customize/model-providers/more/asksage.md | 1 + gui/src/pages/AddNewModel/configs/models.ts | 15 +++++++++++++++ packages/llm-info/src/providers/openai.ts | 7 +++++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/core/llm/llms/Asksage.ts b/core/llm/llms/Asksage.ts index f3b445df4..59554efe5 100644 --- a/core/llm/llms/Asksage.ts +++ b/core/llm/llms/Asksage.ts @@ -24,6 +24,7 @@ class Asksage extends BaseLLM { "gpt4-32k": "gpt4-32k", "gpt-o1": "gpt-o1", // Works "gpt-o1-mini": "gpt-o1-mini", // Works + "gpt-o3-mini": "gpt-o3-mini", // Stub "gpt-3.5-turbo": "gpt35-16k", // Works "aws-bedrock-claude-35-sonnet-gov": "aws-bedrock-claude-35-sonnet-gov", // Works "claude-3-5-sonnet-latest": "claude-35-sonnet", // Works diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index 41b3c755b..e0acc961e 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -49,6 +49,7 @@ const CHAT_ONLY_MODELS = [ "gpt-4o-mini", "o1-preview", "o1-mini", + "o3-mini" ]; const formatMessageForO1 = (messages: ChatCompletionMessageParam[]) => { @@ -92,8 +93,8 @@ class OpenAI extends BaseLLM { return model; } - private isO1Model(model?: string): boolean { - return !!model && model.startsWith("o1"); + private isO3orO1Model(model?: string): boolean { + return !!model && (model.startsWith("o1") || model.startsWith("o3")); } protected supportsPrediction(model: string): boolean { @@ -144,8 +145,8 @@ class OpenAI extends BaseLLM { finalOptions.stop = options.stop?.slice(0, this.getMaxStopWords()); - // OpenAI o1-preview and o1-mini: - if (this.isO1Model(options.model)) { + // OpenAI o1-preview and o1-mini or o3-mini: + if (this.isO3orO1Model(options.model)) { // a) use max_completion_tokens instead of max_tokens finalOptions.max_completion_tokens = options.maxTokens; finalOptions.max_tokens = undefined; @@ -239,8 +240,8 @@ class OpenAI extends BaseLLM { ): ChatCompletionCreateParams { body.stop = body.stop?.slice(0, this.getMaxStopWords()); - // OpenAI o1-preview and o1-mini: - if (this.isO1Model(body.model)) { + // OpenAI o1-preview and o1-mini or o3-mini: + if (this.isO3orO1Model(body.model)) { // a) use max_completion_tokens instead of max_tokens body.max_completion_tokens = body.max_tokens; body.max_tokens = undefined; diff --git a/docs/docs/customize/model-providers/more/asksage.md b/docs/docs/customize/model-providers/more/asksage.md index e21133cb8..204d29421 100644 --- a/docs/docs/customize/model-providers/more/asksage.md +++ b/docs/docs/customize/model-providers/more/asksage.md @@ -60,6 +60,7 @@ The current Models available provided by Ask Sage are: | 8 | GPT-4-32K | Yes | ✅ | | 9 | GPT-o1 | Yes | ✅ | | 10 | GPT-o1-mini | Yes | ✅ | +| 10 | GPT-o3-mini | Yes | ✅ | | 11 | GPT-3.5-turbo | Yes | ✅ | | 12 | Calude 3.5 Sonnet Gov | Yes | ✅ | | 13 | Calude 3 Opus | Yes | ✅ | diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index 8116c86ba..a00705d8a 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -1228,6 +1228,21 @@ export const models: { [key: string]: ModelPackage } = { icon: "openai.png", isOpenSource: false, }, + asksagegpto3mini: { + title: "GPT-o3-mini", + description: + "o3-mini can outperform o1 in coding and other reasoning tasks, and is 93% cheaper and has lower latency. It supports function calling, Structured Outputs, streaming, and developer messages. o3-mini comes with a larger context window of 200,000 tokens and a max output of 100,000 tokens", + params: { + model: "gpt-o3-mini", + contextLength: 200_000, + title: "GPT-o3-mini", + systemMessage: + "You are an expert software developer. You give helpful and concise responses.", + }, + providerOptions: ["askSage"], + icon: "openai.png", + isOpenSource: false, + }, asksageclaude35gov: { title: "Claude 3.5 Sonnet gov", description: diff --git a/packages/llm-info/src/providers/openai.ts b/packages/llm-info/src/providers/openai.ts index 5fd100a8b..b96461e4b 100644 --- a/packages/llm-info/src/providers/openai.ts +++ b/packages/llm-info/src/providers/openai.ts @@ -97,6 +97,13 @@ export const OpenAi: ModelProvider = { maxCompletionTokens: 65536, recommendedFor: ["chat"], }, + { + model: "o3-mini", + displayName: "o3 Mini", + contextLength: 128000, + maxCompletionTokens: 65536, + recommendedFor: ["chat"], + }, // embed { model: "text-embedding-3-large", From b78fdc4147e1ccb388b900a65099a2c61ba6ca26 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 31 Jan 2025 13:19:59 -0800 Subject: [PATCH 22/42] 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(); }} > -