diff --git a/.continue/rules/gui-link-opening.md b/.continue/rules/gui-link-opening.md new file mode 100644 index 000000000..db791e67a --- /dev/null +++ b/.continue/rules/gui-link-opening.md @@ -0,0 +1,10 @@ +--- +globs: gui/**/* +description: Ensures consistent URL opening behavior in GUI components using the + IDE messenger pattern +alwaysApply: false +--- + +# GUI Link Opening + +When adding functionality to open external links in GUI components, use `ideMessenger.post("openUrl", url)` where `ideMessenger` is obtained from `useContext(IdeMessengerContext)` diff --git a/core/config/onboarding.ts b/core/config/onboarding.ts index 9b3826ff8..dde0fefe7 100644 --- a/core/config/onboarding.ts +++ b/core/config/onboarding.ts @@ -8,6 +8,21 @@ export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B"; export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest"; export const LOCAL_ONBOARDING_EMBEDDINGS_TITLE = "Nomic Embed"; +const ANTHROPIC_MODEL_CONFIG = { + slugs: ["anthropic/claude-3-7-sonnet", "anthropic/claude-4-sonnet"], + apiKeyInputName: "ANTHROPIC_API_KEY", +}; +const OPENAI_MODEL_CONFIG = { + slugs: ["openai/gpt-4.1", "openai/o3", "openai/gpt-4.1-mini"], + apiKeyInputName: "OPENAI_API_KEY", +}; + +// TODO: These need updating on the hub +const GEMINI_MODEL_CONFIG = { + slugs: ["google/gemini-2.5-pro", "google/gemini-2.0-flash"], + apiKeyInputName: "GEMINI_API_KEY", +}; + /** * We set the "best" chat + autocopmlete models by default * whenever a user doesn't have a config.json @@ -49,3 +64,45 @@ export function setupLocalConfig(config: ConfigYaml): ConfigYaml { export function setupQuickstartConfig(config: ConfigYaml): ConfigYaml { return config; } + +export function setupProviderConfig( + config: ConfigYaml, + provider: string, + apiKey: string, +): ConfigYaml { + let newModels; + + switch (provider) { + case "openai": + newModels = OPENAI_MODEL_CONFIG.slugs.map((slug) => ({ + uses: slug, + with: { + [OPENAI_MODEL_CONFIG.apiKeyInputName]: apiKey, + }, + })); + break; + case "anthropic": + newModels = ANTHROPIC_MODEL_CONFIG.slugs.map((slug) => ({ + uses: slug, + with: { + [ANTHROPIC_MODEL_CONFIG.apiKeyInputName]: apiKey, + }, + })); + break; + case "gemini": + newModels = GEMINI_MODEL_CONFIG.slugs.map((slug) => ({ + uses: slug, + with: { + [GEMINI_MODEL_CONFIG.apiKeyInputName]: apiKey, + }, + })); + break; + default: + throw new Error(`Unknown provider: ${provider}`); + } + + return { + ...config, + models: [...(config.models ?? []), ...newModels], + }; +} diff --git a/core/core.ts b/core/core.ts index 4fabefed3..822d430ee 100644 --- a/core/core.ts +++ b/core/core.ts @@ -34,6 +34,7 @@ import { getSymbolsForManyFiles } from "./util/treeSitter"; import { TTS } from "./util/tts"; import { + CompleteOnboardingPayload, ContextItemWithId, IdeSettings, ModelDescription, @@ -47,8 +48,8 @@ import { ConfigYaml } from "@continuedev/config-yaml"; import { getDiffFn, GitDiffCache } from "./autocomplete/snippets/gitDiffCache"; import { isLocalAssistantFile } from "./config/loadLocalAssistants"; import { - setupBestConfig, setupLocalConfig, + setupProviderConfig, setupQuickstartConfig, } from "./config/onboarding"; import { createNewWorkspaceBlockFile } from "./config/workspace/workspaceBlocks"; @@ -60,6 +61,7 @@ import { walkDirCache } from "./indexing/walkDir"; import { LLMLogger } from "./llm/logger"; import { llmStreamChat } from "./llm/streamChat"; import type { FromCoreProtocol, ToCoreProtocol } from "./protocol"; +import { OnboardingModes } from "./protocol/core"; import type { IMessenger, Message } from "./protocol/messenger"; import { StreamAbortManager } from "./util/abortManager"; @@ -509,7 +511,7 @@ export class Core { abortManager.clear(); }); - on("completeOnboarding", this.handleCompleteOnboarding.bind(this)); + on("onboarding/complete", this.handleCompleteOnboarding.bind(this)); on("addAutocompleteModel", this.handleAddAutocompleteModel.bind(this)); @@ -876,26 +878,25 @@ export class Core { } } - private async handleCompleteOnboarding(msg: Message<{ mode: string }>) { - const mode = msg.data.mode; - - if (mode === "Custom") { - return; - } + private async handleCompleteOnboarding( + msg: Message, + ) { + const { mode, provider, apiKey } = msg.data; let editConfigYamlCallback: (config: ConfigYaml) => ConfigYaml; switch (mode) { - case "Local": + case OnboardingModes.LOCAL: editConfigYamlCallback = setupLocalConfig; break; - case "Quickstart": - editConfigYamlCallback = setupQuickstartConfig; - break; - - case "Best": - editConfigYamlCallback = setupBestConfig; + case OnboardingModes.API_KEY: + if (provider && apiKey) { + editConfigYamlCallback = (config: ConfigYaml) => + setupProviderConfig(config, provider, apiKey); + } else { + editConfigYamlCallback = setupQuickstartConfig; + } break; default: diff --git a/core/core_temp.ts b/core/core_temp.ts new file mode 100644 index 000000000..e69de29bb diff --git a/core/index.d.ts b/core/index.d.ts index d3487fe30..da9d6fc10 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1578,3 +1578,9 @@ export interface RuleWithSource { ruleFile?: string; alwaysApply?: boolean; } + +export interface CompleteOnboardingPayload { + mode: OnboardingModes; + provider?: string; + apiKey?: string; +} diff --git a/core/protocol/core.ts b/core/protocol/core.ts index ba3736daa..e34a332bd 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -12,6 +12,7 @@ import { GlobalContextModelSelections } from "../util/GlobalContext"; import { BrowserSerializedContinueConfig, ChatMessage, + CompleteOnboardingPayload, ContextItem, ContextItemWithId, ContextSubmenuItem, @@ -36,7 +37,10 @@ import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager"; import { ControlPlaneSessionInfo } from "../control-plane/AuthTypes"; import { FreeTrialStatus } from "../control-plane/client"; -export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart"; +export enum OnboardingModes { + API_KEY = "API Key", + LOCAL = "Local", +} export interface ListHistoryOptions { offset?: number; @@ -169,12 +173,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { void, ]; "index/indexingProgressBarInitialized": [undefined, void]; - completeOnboarding: [ - { - mode: OnboardingModes; - }, - void, - ]; + "onboarding/complete": [CompleteOnboardingPayload, void]; // File changes "files/changed": [{ uris?: string[] }, void]; @@ -198,7 +197,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { { contextItems: ContextItem[]; errorMessage?: string }, ]; "clipboardCache/add": [{ content: string }, void]; - "controlPlane/openUrl": [{ path: string; orgSlug: string | undefined }, void]; + "controlPlane/openUrl": [{ path: string; orgSlug?: string }, void]; "controlPlane/getFreeTrialStatus": [undefined, FreeTrialStatus | null]; isItemTooBig: [{ item: ContextItemWithId }, boolean]; didChangeControlPlaneSessionInfo: [ diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 36cb9b485..014c1a968 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -55,7 +55,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "docs/initStatuses", "docs/getDetails", // - "completeOnboarding", + "onboarding/complete", "addAutocompleteModel", "didChangeSelectedProfile", "didChangeSelectedOrg", diff --git a/docs/docs/customize/model-roles/apply.mdx b/docs/docs/customize/model-roles/apply.mdx index 6cce4acbc..f4e35ce05 100644 --- a/docs/docs/customize/model-roles/apply.mdx +++ b/docs/docs/customize/model-roles/apply.mdx @@ -1,3 +1,9 @@ +--- +title: Apply Role +description: Apply model role +keywords: [apply, model, role] +--- + When editing code, Chat and Edit model output often doesn't clearly align with existing code. A model with the `apply` role is used to generate a more precise diff to apply changes to a file. ## Recommended Apply models 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 89ca73cd7..66ebac070 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 @@ -121,7 +121,7 @@ class MessageTypes { "docs/initStatuses", "docs/getDetails", // - "completeOnboarding", + "onboarding/complete", "addAutocompleteModel", "didChangeSelectedProfile", "didChangeSelectedOrg", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 54f93c509..6027f17bc 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.45", + "version": "1.1.46", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts index e0c5210d8..0d4827087 100644 --- a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts +++ b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts @@ -393,6 +393,9 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable { code_challenge: codeChallenge, code_challenge_method: "S256", provider: "authkit", + screen_hint: WorkOsAuthProvider.useOnboardingUri + ? "sign-up" + : "sign-in", }; Object.keys(params).forEach((key) => diff --git a/gui/package-lock.json b/gui/package-lock.json index a56200472..d6996309b 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -232,6 +232,16 @@ "zod-to-json-schema": "^3.24.5" } }, + "../packages/llm-info": { + "name": "@continuedev/llm-info", + "version": "1.0.9", + "extraneous": true, + "license": "Apache-2.0", + "devDependencies": { + "@types/node": "^22.15.29", + "typescript": "^5.5.2" + } + }, "node_modules/@adobe/css-tools": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.0.tgz", @@ -9800,9 +9810,10 @@ } }, "node_modules/react-hook-form": { - "version": "7.53.0", - "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.53.0.tgz", - "integrity": "sha512-M1n3HhqCww6S2hxLxciEXy2oISPnAzxY7gvwVPrtlczTM/1dDadXgUxDpHMrMTblDOcm/AXtXxHwZ3jpg1mqKQ==", + "version": "7.57.0", + "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.57.0.tgz", + "integrity": "sha512-RbEks3+cbvTP84l/VXGUZ+JMrKOS8ykQCRYdm5aYsxnDquL0vspsyNhGRO7pcH6hsZqWlPOjLye7rJqdtdAmlg==", + "license": "MIT", "engines": { "node": ">=18.0.0" }, diff --git a/gui/src/components/AddModelButtonSubtext.tsx b/gui/src/components/AddModelButtonSubtext.tsx deleted file mode 100644 index aa7ef99b5..000000000 --- a/gui/src/components/AddModelButtonSubtext.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { useContext } from "react"; -import { ButtonSubtext } from "."; -import { IdeMessengerContext } from "../context/IdeMessenger"; - -function AddModelButtonSubtext() { - const ideMessenger = useContext(IdeMessengerContext); - - return ( - - This will update your{" "} - - ideMessenger.post("config/openProfile", { - profileId: undefined, - }) - } - > - config file - - - ); -} - -export default AddModelButtonSubtext; diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index b5e4ebda6..0d9f66072 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -1,3 +1,4 @@ +import { OnboardingModes } from "core/protocol/core"; import { useContext, useEffect } from "react"; import { Outlet, useLocation, useNavigate } from "react-router-dom"; import styled from "styled-components"; @@ -131,7 +132,7 @@ const Layout = () => { useWebviewListener( "openOnboardingCard", async () => { - onboardingCard.open("Best"); + onboardingCard.open(OnboardingModes.API_KEY); }, [], ); @@ -139,7 +140,7 @@ const Layout = () => { useWebviewListener( "setupLocalConfig", async () => { - onboardingCard.open("Local"); + onboardingCard.open(OnboardingModes.LOCAL); }, [], ); @@ -179,7 +180,6 @@ const Layout = () => { if (isMetaEquivalentKeyPressed(event) && event.code === "KeyC") { const selection = window.getSelection()?.toString(); if (selection) { - // Copy to clipboard setTimeout(() => { void navigator.clipboard.writeText(selection); }, 100); @@ -199,7 +199,7 @@ const Layout = () => { isNewUserOnboarding() && (location.pathname === "/" || location.pathname === "/index.html") ) { - onboardingCard.open("Quickstart"); + onboardingCard.open(); } }, [location]); diff --git a/gui/src/components/OnboardingCard/OnboardingCard.tsx b/gui/src/components/OnboardingCard/OnboardingCard.tsx index aa8be2a29..eff33936e 100644 --- a/gui/src/components/OnboardingCard/OnboardingCard.tsx +++ b/gui/src/components/OnboardingCard/OnboardingCard.tsx @@ -1,13 +1,18 @@ +import { OnboardingModes } from "core/protocol/core"; import { useAppSelector } from "../../redux/hooks"; import { getLocalStorage, setLocalStorage } from "../../util/localStorage"; import { ReusableCard } from "../ReusableCard"; -import { OnboardingCardTabs, TabTitle } from "./components/OnboardingCardTabs"; -import { useOnboardingCard } from "./hooks/useOnboardingCard"; -import * as Tabs from "./tabs"; +import { + OnboardingCardLanding, + OnboardingCardTabs, + OnboardingLocalTab, + OnboardingProvidersTab, +} from "./components"; +import { useOnboardingCard } from "./hooks"; export interface OnboardingCardState { show?: boolean; - activeTab?: TabTitle; + activeTab?: OnboardingModes; } interface OnboardingCardProps { @@ -15,37 +20,48 @@ interface OnboardingCardProps { } export function OnboardingCard({ isDialog }: OnboardingCardProps) { - const onboardingCard = useOnboardingCard(); + const { activeTab, close, setActiveTab } = useOnboardingCard(); const config = useAppSelector((store) => store.config.config); - function renderTabContent() { - switch (onboardingCard.activeTab) { - case "Quickstart": - return ; - case "Best": - return ; - case "Local": - return ; - default: - return ; - } - } - if (getLocalStorage("onboardingStatus") === undefined) { setLocalStorage("onboardingStatus", "Started"); } + function renderTabContent() { + switch (activeTab) { + case OnboardingModes.API_KEY: + return ; + case OnboardingModes.LOCAL: + return ; + default: + return ; + } + } + + if (activeTab) { + return ( + + + {renderTabContent()} + + ); + } + return ( onboardingCard.close()} - testId="onboarding-card" + onClose={close} > - - {renderTabContent()} +
+ setActiveTab(OnboardingModes.API_KEY)} + isDialog={isDialog} + /> +
); } diff --git a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx deleted file mode 100644 index 0929aad8b..000000000 --- a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx +++ /dev/null @@ -1,171 +0,0 @@ -import { CubeIcon } from "@heroicons/react/24/outline"; -import { FormEventHandler, useContext, useState } from "react"; -import { Button, Input, InputSubtext, lightGray } from "../.."; -import { useAuth } from "../../../context/Auth"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { models } from "../../../pages/AddNewModel/configs/models"; -import { providers } from "../../../pages/AddNewModel/configs/providers"; -import { useAppDispatch } from "../../../redux/hooks"; -import { updateSelectedModelByRole } from "../../../redux/thunks"; -import AddModelButtonSubtext from "../../AddModelButtonSubtext"; - -const { anthropic, mistral } = providers; -const chatProvider = anthropic!; -const autocompleteProvider = mistral!; - -const { - claude35Sonnet: chatModel, - claude35Haiku: repoMapModel, - codestral: autocompleteModel, -} = models; - -interface BestExperienceConfigFormProps { - onComplete: () => void; -} - -function BestExperienceConfigForm({ - onComplete, -}: BestExperienceConfigFormProps) { - const dispatch = useAppDispatch(); - const { selectedProfile } = useAuth(); - - const ideMessenger = useContext(IdeMessengerContext); - - const [autocompleteApiKey, setAutocompleteApiKey] = useState(""); - const [chatApiKey, setChatApiKey] = useState(""); - - const handleSubmit: FormEventHandler = async (e) => { - e.preventDefault(); - - const chatModelConfig = { - model: chatModel.params.model, - provider: chatProvider.provider, - underlyingProviderName: chatProvider.provider, - apiKey: chatApiKey, - title: chatModel.params.title, - }; - - const repoMapConfig = { - model: repoMapModel.params.model, - provider: chatProvider.provider, - underlyingProviderName: chatProvider.provider, - apiKey: chatApiKey, - title: repoMapModel.params.title, - }; - - const autocompleteModelConfig = { - title: autocompleteModel.params.title, - provider: autocompleteProvider.provider, - underlyingProviderName: autocompleteProvider.provider, - model: autocompleteModel.params.model, - apiKey: autocompleteApiKey, - }; - - ideMessenger.post("config/addModel", { model: chatModelConfig }); - ideMessenger.post("config/addModel", { - model: repoMapConfig, - role: "repoMapFileSelection", - }); - - dispatch( - updateSelectedModelByRole({ - selectedProfile, - role: "chat", - modelTitle: chatModelConfig.title, - }), - ); - - if (!!autocompleteApiKey) { - await ideMessenger.request("addAutocompleteModel", { - model: autocompleteModelConfig, - }); - } - - onComplete(); - }; - - return ( -
-
-
-
- -
- - - {chatModel.title}{" "} - by Anthropic - -
-
- -
- setChatApiKey(e.target.value)} - data-testid="best-chat-api-key-input" - /> - - - Click here - {" "} - to create an Anthropic API key - -
-
- -
-
- -
- - - {autocompleteModel.title}{" "} - by Mistral - -
-
- -
- setAutocompleteApiKey(e.target.value)} - data-testid="best-autocomplete-api-key-input" - /> - - - Click here - {" "} - to create a Mistral API key - -
-
- -
- - -
-
-
- ); -} - -export default BestExperienceConfigForm; diff --git a/gui/src/components/OnboardingCard/components/OllamaModelDownload.tsx b/gui/src/components/OnboardingCard/components/OllamaModelDownload.tsx index c98ca6794..abce87d86 100644 --- a/gui/src/components/OnboardingCard/components/OllamaModelDownload.tsx +++ b/gui/src/components/OnboardingCard/components/OllamaModelDownload.tsx @@ -27,7 +27,7 @@ function OllamaModelDownload({ return (
-

{title}

+

{title}

{hasDownloaded ? ( ) : ( diff --git a/gui/src/components/OnboardingCard/components/OnboardingCardLanding.tsx b/gui/src/components/OnboardingCard/components/OnboardingCardLanding.tsx new file mode 100644 index 000000000..b4448d612 --- /dev/null +++ b/gui/src/components/OnboardingCard/components/OnboardingCardLanding.tsx @@ -0,0 +1,103 @@ +import { useContext } from "react"; +import { Button, SecondaryButton } from "../.."; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { selectCurrentOrg } from "../../../redux"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { selectFirstHubProfile } from "../../../redux/thunks"; +import { hasPassedFTL } from "../../../util/freeTrial"; +import ContinueLogo from "../../gui/ContinueLogo"; +import { ToolTip } from "../../gui/Tooltip"; +import { useOnboardingCard } from "../hooks"; + +export function OnboardingCardLanding({ + onSelectConfigure, + isDialog, +}: { + onSelectConfigure: () => void; + isDialog?: boolean; +}) { + const ideMessenger = useContext(IdeMessengerContext); + const onboardingCard = useOnboardingCard(); + const auth = useAuth(); + const currentOrg = useAppSelector(selectCurrentOrg); + const dispatch = useAppDispatch(); + + function onGetStarted() { + void auth.login(true).then((success) => { + if (success) { + onboardingCard.close(isDialog); + + // A new assistant is created when the account is created + // We want to switch to this immediately + void dispatch(selectFirstHubProfile()); + } + }); + } + + function openPastFreeTrialOnboarding() { + ideMessenger.post("controlPlane/openUrl", { + path: "setup-models", + orgSlug: currentOrg?.slug, + }); + onboardingCard.close(isDialog); + } + + const pastFreeTrialLimit = hasPassedFTL(); + + return ( +
+
+ +
+ + {pastFreeTrialLimit ? ( + <> +

+ You've reached the free trial limit. Visit the Continue Platform to + select a Coding Assistant. +

+ + + ) : ( + <> +

+ Log in to access a free trial of the +
+ + ideMessenger.post("controlPlane/openUrl", { + path: "pricing", + }) + } + > + Models Add-On + + + Free trial includes 50 Chat requests and 2,000 autocomplete + requests + +

+ + + + )} + + + Or, configure your own models + +
+ ); +} diff --git a/gui/src/components/OnboardingCard/components/OnboardingCardTabs.tsx b/gui/src/components/OnboardingCard/components/OnboardingCardTabs.tsx index b1543ea58..de881edf4 100644 --- a/gui/src/components/OnboardingCard/components/OnboardingCardTabs.tsx +++ b/gui/src/components/OnboardingCard/components/OnboardingCardTabs.tsx @@ -1,74 +1,32 @@ -import styled from "styled-components"; -import { vscForeground } from "../.."; -import { hasPassedFTL } from "../../../util/freeTrial"; +import { KeyIcon } from "@heroicons/react/24/outline"; +import { OnboardingModes } from "core/protocol/core"; interface OnboardingCardTabsProps { - activeTab: TabTitle; - onTabClick: (tabName: TabTitle) => void; + /** The currently active tab */ + activeTab: OnboardingModes; + /** Callback function called when a tab is clicked */ + onTabClick: (tabName: OnboardingModes) => void; } -export type TabTitle = "Quickstart" | "Best" | "Local" | "ExistingUserHubIntro"; - -export const TabTitles: { [k in TabTitle]: { md: string; default: string } } = { - Quickstart: { - md: "Quickstart", - default: "Quickstart", - }, - Best: { - md: "Best", - default: "Best experience", - }, - Local: { - md: "Local", - default: "Local with Ollama", - }, - ExistingUserHubIntro: { - md: "Try out hub.continue.dev", - default: "Try out hub.continue.dev", - }, +const getTabIcon = (tabTitle: OnboardingModes) => { + if (tabTitle === OnboardingModes.API_KEY) { + return ; + } + if (tabTitle === OnboardingModes.LOCAL) { + return ( + Ollama + ); + } + return null; }; -const StyledSelect = styled.select` - width: 100%; - padding: 0.5rem; - background-color: transparent; - color: ${vscForeground}; - border: none; - border-bottom: 1px solid ${vscForeground}; - border-radius: 0; - font-size: 1rem; - cursor: pointer; - display: block; - - &:focus { - outline: none; - } -`; - -const TabButton = styled.button<{ isActive: boolean }>` - margin-bottom: -1px; - focus: outline-none; - background: transparent; - cursor: pointer; - color: ${vscForeground}; - border: none; - - ${({ isActive }) => - isActive && - ` - border-style: solid; - border-width: 0 0 2.5px 0; - border-color: ${vscForeground}; - font-weight: bold; - `} -`; - -const TabList = styled.div` - border-style: solid; - border-width: 0 0 0.5px 0; - border-color: ${vscForeground}; -`; - +/** + * Tab navigation component for onboarding modes with responsive design + */ export function OnboardingCardTabs({ activeTab, onTabClick, @@ -76,46 +34,41 @@ export function OnboardingCardTabs({ return (
- - {Object.entries(TabTitles).map(([tabType, titles]) => { - if (hasPassedFTL() && tabType === "Quickstart") { - return undefined; - } +
+ {Object.values(OnboardingModes).map((tabTitle) => { + const isActive = activeTab === tabTitle; return ( - onTabClick(tabType as TabTitle)} - data-testid={`onboarding-tab-${tabType}`} + ); })} - +
-
- onTabClick(e.target.value as TabTitle)} - > - {Object.entries(TabTitles).map(([tabType, titles]) => { - if (hasPassedFTL() && tabType === "Quickstart") { - return null; - } +
+
); diff --git a/gui/src/components/OnboardingCard/components/OnboardingLocalTab.tsx b/gui/src/components/OnboardingCard/components/OnboardingLocalTab.tsx index b0cc6f179..797fcbff0 100644 --- a/gui/src/components/OnboardingCard/components/OnboardingLocalTab.tsx +++ b/gui/src/components/OnboardingCard/components/OnboardingLocalTab.tsx @@ -5,8 +5,9 @@ import { LOCAL_ONBOARDING_FIM_MODEL, LOCAL_ONBOARDING_PROVIDER_TITLE, } from "core/config/onboarding"; +import { OnboardingModes } from "core/protocol/core"; import { useContext, useEffect, useState } from "react"; -import { Button, ButtonSubtext } from "../.."; +import { Button } from "../.."; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useAppDispatch } from "../../../redux/hooks"; @@ -22,10 +23,13 @@ interface OnboardingLocalTabProps { isDialog?: boolean; } -function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) { +export function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) { const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); - const { submitOnboarding } = useSubmitOnboarding("Local", isDialog); + const { submitOnboarding } = useSubmitOnboarding( + OnboardingModes.LOCAL, + isDialog, + ); const [hasLoadedChatModel, setHasLoadedChatModel] = useState(false); const [downloadedOllamaModels, setDownloadedOllamaModels] = useState< string[] @@ -109,7 +113,7 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) { dispatch(setShowDialog(false)); } - dispatch( + void dispatch( updateSelectedModelByRole({ selectedProfile, role: "chat", @@ -132,48 +136,53 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) { }; return ( -
-
-

- Install Ollama -

- -
+
+
+
+
+

+ Install Ollama +

+ +
- + - + - + -
- - - - Skip and configure manually - - +
+ +
+ + Skip and configure manually + +
+
+
); } - -export default OnboardingLocalTab; diff --git a/gui/src/components/OnboardingCard/components/OnboardingProvidersTab.tsx b/gui/src/components/OnboardingCard/components/OnboardingProvidersTab.tsx new file mode 100644 index 000000000..afbffb854 --- /dev/null +++ b/gui/src/components/OnboardingCard/components/OnboardingProvidersTab.tsx @@ -0,0 +1,128 @@ +import { OnboardingModes } from "core/protocol/core"; +import { FormProvider, useForm } from "react-hook-form"; +import { AddModelForm } from "../../../forms"; +import { providers } from "../../../pages/AddNewModel/configs/providers"; +import { useAppDispatch } from "../../../redux/hooks"; +import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; +import { Button, Input } from "../../index"; +import { useSubmitOnboarding } from "../hooks/useSubmitOnboarding"; + +interface OnboardingProvidersTabProps { + /** Whether this is being shown in a dialog context */ + isDialog?: boolean; +} + +export function OnboardingProvidersTab({ + isDialog, +}: OnboardingProvidersTabProps) { + const formMethods = useForm(); + const dispatch = useAppDispatch(); + const { submitOnboarding } = useSubmitOnboarding( + OnboardingModes.API_KEY, + isDialog, + ); + + const providerConfigs = [ + providers["openai"], + providers["anthropic"], + providers["gemini"], + ]; + + const handleFormSubmit = () => { + // Find the first provider with an API key entered + for (const config of providerConfigs) { + const apiKey = formMethods.watch(`${config?.provider}_apiKey`); + if (apiKey?.trim()) { + submitOnboarding(config?.provider, apiKey); + return; + } + } + }; + + const handleClickMoreProviders = () => { + dispatch(setShowDialog(true)); + dispatch( + setDialogMessage( + { + dispatch(setShowDialog(false)); + submitOnboarding(); + }} + />, + ), + ); + }; + + const hasAnyApiKey = providerConfigs.some((config) => { + const apiKey = formMethods.watch(`${config?.provider}_apiKey`); + return apiKey?.trim(); + }); + + return ( +
+
+ +
+
+ {providerConfigs.map((config) => ( +
+ + + + + Click here + {" "} + to create a {config?.title} API key + +
+ ))} +
+ +
+ + +
+ + + Click here + {" "} + to view more providers + +
+
+
+
+
+
+ ); +} diff --git a/gui/src/components/OnboardingCard/components/ProviderAlert.tsx b/gui/src/components/OnboardingCard/components/ProviderAlert.tsx deleted file mode 100644 index 13e2eae11..000000000 --- a/gui/src/components/OnboardingCard/components/ProviderAlert.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { useDispatch } from "react-redux"; -import AddModelForm from "../../../forms/AddModelForm"; -import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; -import Alert from "../../gui/Alert"; -import { useSubmitOnboarding } from "../hooks"; - -function ProviderAlert() { - const dispatch = useDispatch(); - const { submitOnboarding } = useSubmitOnboarding("Custom"); - - function onClick() { - dispatch(setShowDialog(true)); - dispatch(setDialogMessage()); - } - - return ( -
- -

- Prefer to use a different provider like OpenAI? -

-

- - Click here - {" "} - to add a Chat model from OpenAI, Gemini, and more -

-
-
- ); -} - -export default ProviderAlert; diff --git a/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx b/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx deleted file mode 100644 index 3dca0b391..000000000 --- a/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { useContext } from "react"; -import { useDispatch } from "react-redux"; -import { Button, ButtonSubtext } from "../.."; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { useSubmitOnboarding } from "../hooks"; - -interface QuickstartSubmitButtonProps { - isDialog?: boolean; -} - -function QuickstartSubmitButton({ isDialog }: QuickstartSubmitButtonProps) { - const ideMessenger = useContext(IdeMessengerContext); - const dispatch = useDispatch(); - - const { submitOnboarding } = useSubmitOnboarding("Quickstart", isDialog); - - function onComplete() { - submitOnboarding(); - } - - async function onClick() { - // REMOVED THIS LOGIC TO GET GITHUB TOKEN - // SINCE NOW USES THE HUB FOR FREE TRIAL - // AND COMPONENT IS CURRENTLY UNUSED - } - - return ( -
- - Try 50 chat and 2k autocomplete requests -
- ); -} - -export default QuickstartSubmitButton; diff --git a/gui/src/components/OnboardingCard/components/index.ts b/gui/src/components/OnboardingCard/components/index.ts new file mode 100644 index 000000000..7dcf5e7f6 --- /dev/null +++ b/gui/src/components/OnboardingCard/components/index.ts @@ -0,0 +1,7 @@ +export * from "./OllamaCompletedStep"; +export * from "./OllamaModelDownload"; +export * from "./OllamaStatus"; +export * from "./OnboardingCardLanding"; +export * from "./OnboardingCardTabs"; +export * from "./OnboardingLocalTab"; +export * from "./OnboardingProvidersTab"; diff --git a/gui/src/components/OnboardingCard/hooks/useOnboardingCard.ts b/gui/src/components/OnboardingCard/hooks/useOnboardingCard.ts index 9622754c4..94a7fb7a8 100644 --- a/gui/src/components/OnboardingCard/hooks/useOnboardingCard.ts +++ b/gui/src/components/OnboardingCard/hooks/useOnboardingCard.ts @@ -1,21 +1,19 @@ -import { useDispatch } from "react-redux"; +import { OnboardingModes } from "core/protocol/core"; import { useNavigate } from "react-router-dom"; -import { TabTitle } from "../components/OnboardingCardTabs"; +import { OnboardingCardState } from ".."; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { setDialogMessage, setOnboardingCard, setShowDialog, } from "../../../redux/slices/uiSlice"; -import { OnboardingCardState } from ".."; import { getLocalStorage, setLocalStorage } from "../../../util/localStorage"; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; -import { saveCurrentSession } from "../../../redux/thunks/session"; export interface UseOnboardingCard { show: OnboardingCardState["show"]; activeTab: OnboardingCardState["activeTab"]; - setActiveTab: (tab: TabTitle) => void; - open: (tab: TabTitle) => void; + setActiveTab: (tab: OnboardingModes) => void; + open: (tab?: OnboardingModes) => void; close: (isDialog?: boolean) => void; } @@ -40,9 +38,14 @@ export function useOnboardingCard(): UseOnboardingCard { show = onboardingStatus !== "Completed" && !hasDismissedOnboardingCard; } - async function open(tab: TabTitle) { + async function open(tab?: OnboardingModes) { navigate("/"); - dispatch(setOnboardingCard({ show: true, activeTab: tab })); + dispatch( + setOnboardingCard({ + show: true, + activeTab: tab ?? OnboardingModes.API_KEY, + }), + ); } function close(isDialog = false) { @@ -54,7 +57,7 @@ export function useOnboardingCard(): UseOnboardingCard { } } - function setActiveTab(tab: TabTitle) { + function setActiveTab(tab: OnboardingModes) { dispatch(setOnboardingCard({ show: true, activeTab: tab })); } diff --git a/gui/src/components/OnboardingCard/hooks/useSubmitOnboarding.ts b/gui/src/components/OnboardingCard/hooks/useSubmitOnboarding.ts index 9e1bd8a9b..259dd6392 100644 --- a/gui/src/components/OnboardingCard/hooks/useSubmitOnboarding.ts +++ b/gui/src/components/OnboardingCard/hooks/useSubmitOnboarding.ts @@ -3,20 +3,25 @@ import { usePostHog } from "posthog-js/react"; import { useContext } from "react"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { getLocalStorage, setLocalStorage } from "../../../util/localStorage"; +import { useLump } from "../../mainInput/Lump/LumpContext"; import { useOnboardingCard } from "./useOnboardingCard"; export function useSubmitOnboarding(mode: OnboardingModes, isDialog = false) { const posthog = usePostHog(); const ideMessenger = useContext(IdeMessengerContext); const { close: closeOnboardingCard } = useOnboardingCard(); + const { setSelectedSection } = useLump(); - function submitOnboarding() { + function submitOnboarding(provider?: string, apiKey?: string) { const onboardingStatus = getLocalStorage("onboardingStatus"); - // Always close the onboarding card and update config.json + // Always close the onboarding card and update config.yaml closeOnboardingCard(isDialog); - ideMessenger.post("completeOnboarding", { + + ideMessenger.post("onboarding/complete", { mode, + provider, + apiKey, }); if (onboardingStatus === "Started") { @@ -32,6 +37,9 @@ export function useSubmitOnboarding(mode: OnboardingModes, isDialog = false) { // Move to next step in onboarding ideMessenger.post("showTutorial", undefined); } + + ideMessenger.post("config/openProfile", { profileId: undefined }); + setSelectedSection("models"); } return { diff --git a/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx b/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx deleted file mode 100644 index 883ea66d1..000000000 --- a/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { useState } from "react"; -import { useAuth } from "../../../context/Auth"; -import { useAppSelector } from "../../../redux/hooks"; -import { getLocalStorage, setLocalStorage } from "../../../util/localStorage"; -import Alert from "../../gui/Alert"; -import { ReusableCard } from "../../ReusableCard"; -import { TabTitle } from "../components/OnboardingCardTabs"; -import OnboardingLocalTab from "../components/OnboardingLocalTab"; -import { useOnboardingCard } from "../hooks"; -import MainTab from "./tabs/main"; - -export interface OnboardingCardState { - show?: boolean; - activeTab?: TabTitle; -} - -interface OnboardingCardProps { - isDialog: boolean; -} - -export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) { - const onboardingCard = useOnboardingCard(); - const config = useAppSelector((store) => store.config.config); - const auth = useAuth(); - const [currentTab, setCurrentTab] = useState<"main" | "local">("main"); - - if (getLocalStorage("onboardingStatus") === undefined) { - setLocalStorage("onboardingStatus", "Started"); - } - - function onGetStarted() { - auth.login(true).then((success) => { - if (success) { - onboardingCard.close(isDialog); - } - }); - } - - return ( - onboardingCard.close()} - > -
- {currentTab === "main" ? ( - setCurrentTab("local")} - isDialog={isDialog} - /> - ) : ( -
- - By choosing this option, Continue will be configured by a local - config.yaml file. If you're just looking to use Ollama and still - want to manage your configuration through Continue, click{" "} - - here - - - -
- )} -
-
- ); -} diff --git a/gui/src/components/OnboardingCard/platform/tabs/main.tsx b/gui/src/components/OnboardingCard/platform/tabs/main.tsx deleted file mode 100644 index 31fad1c4e..000000000 --- a/gui/src/components/OnboardingCard/platform/tabs/main.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import { ChevronRightIcon } from "@heroicons/react/24/outline"; -import { useContext } from "react"; -import { ButtonSubtext } from "../../.."; -import { useAuth } from "../../../../context/Auth"; -import { IdeMessengerContext } from "../../../../context/IdeMessenger"; -import { selectCurrentOrg } from "../../../../redux"; -import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; -import { selectFirstHubProfile } from "../../../../redux/thunks"; -import { hasPassedFTL } from "../../../../util/freeTrial"; -import ContinueLogo from "../../../gui/ContinueLogo"; -import { Button } from "../../../ui/Button"; -import { useOnboardingCard } from "../../hooks"; - -export default function MainTab({ - onRemainLocal, - isDialog, -}: { - onRemainLocal: () => void; - isDialog: boolean; -}) { - const ideMessenger = useContext(IdeMessengerContext); - const onboardingCard = useOnboardingCard(); - const auth = useAuth(); - const dispatch = useAppDispatch(); - const currentOrg = useAppSelector(selectCurrentOrg); - - function onGetStarted() { - void auth.login(true).then((success) => { - if (success) { - onboardingCard.close(isDialog); - - // A new assistant is created when the account is created - // We want to switch to this immediately - void dispatch(selectFirstHubProfile()); - } - }); - } - - function openPastFreeTrialOnboarding() { - ideMessenger.post("controlPlane/openUrl", { - path: "setup-models", - orgSlug: currentOrg?.slug, - }); - onboardingCard.close(isDialog); - } - - const pastFreeTrialLimit = hasPassedFTL(); - - return ( -
-
- -
- - {pastFreeTrialLimit ? ( - <> -

- You've reached the free trial limit. Visit the Continue Platform to - select a Coding Assistant. -

- - - ) : onboardingCard.activeTab === "ExistingUserHubIntro" ? ( - <> -

- You can now browse and create custom AI code assistants at{" "} - hub.continue.dev -

- - - - ) : ( - <> -

- Log in to quickly build your first custom AI code assistant -

- - - - )} - - {onboardingCard.activeTab === "ExistingUserHubIntro" ? ( - onboardingCard.close(isDialog)}> -
- Or, use Continue as usual - -
-
- ) : ( - -
- Or, remain local - -
-
- )} -
- ); -} diff --git a/gui/src/components/OnboardingCard/tabs/OnboardingBestTab.tsx b/gui/src/components/OnboardingCard/tabs/OnboardingBestTab.tsx deleted file mode 100644 index 17d2ead00..000000000 --- a/gui/src/components/OnboardingCard/tabs/OnboardingBestTab.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import BestExperienceConfigForm from "../components/BestExperienceConfigForm"; -import ProviderAlert from "../components/ProviderAlert"; -import { useSubmitOnboarding } from "../hooks"; - -interface OnboardingBestTabProps { - isDialog?: boolean; -} - -function OnboardingBestTab({ isDialog }: OnboardingBestTabProps) { - const { submitOnboarding } = useSubmitOnboarding("Best", isDialog); - - return ( -
-
- -
- -
- ); -} - -export default OnboardingBestTab; diff --git a/gui/src/components/OnboardingCard/tabs/OnboardingQuickstartTab.tsx b/gui/src/components/OnboardingCard/tabs/OnboardingQuickstartTab.tsx deleted file mode 100644 index f291cf7c8..000000000 --- a/gui/src/components/OnboardingCard/tabs/OnboardingQuickstartTab.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import ContinueLogo from "../../gui/ContinueLogo"; -import QuickStartSubmitButton from "../components/QuickStartSubmitButton"; - -interface OnboardingQuickstartTabProps { - isDialog?: boolean; -} - -function OnboardingQuickstartTab({ isDialog }: OnboardingQuickstartTabProps) { - return ( -
-
-
- -
- -

- Quickly get up and running using our API keys. After this trial, we'll - help you set up your own models. -

- -

- To prevent abuse, we'll ask you to sign in to GitHub. -

- - -
-
- ); -} - -export default OnboardingQuickstartTab; diff --git a/gui/src/components/OnboardingCard/tabs/index.ts b/gui/src/components/OnboardingCard/tabs/index.ts deleted file mode 100644 index 1e6aae37d..000000000 --- a/gui/src/components/OnboardingCard/tabs/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { default as Local } from "../components/OnboardingLocalTab"; -export { default as Best } from "./OnboardingBestTab"; -export { default as Quickstart } from "./OnboardingQuickstartTab"; diff --git a/gui/src/components/OnboardingCard/utils.ts b/gui/src/components/OnboardingCard/utils.ts index 4d2b8ef2c..33d4e59d3 100644 --- a/gui/src/components/OnboardingCard/utils.ts +++ b/gui/src/components/OnboardingCard/utils.ts @@ -24,7 +24,7 @@ export function isNewUserOnboarding() { export const defaultOnboardingCardState: OnboardingCardState = { show: false, - activeTab: "Quickstart", + activeTab: undefined, }; export enum OllamaConnectionStatuses { diff --git a/gui/src/components/dialogs/FreeTrialOverDialog.tsx b/gui/src/components/dialogs/FreeTrialOverDialog.tsx index a200b2f15..8f66075bc 100644 --- a/gui/src/components/dialogs/FreeTrialOverDialog.tsx +++ b/gui/src/components/dialogs/FreeTrialOverDialog.tsx @@ -2,7 +2,7 @@ import { useEffect } from "react"; import { useDispatch } from "react-redux"; import { useAppSelector } from "../../redux/hooks"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; -import { PlatformOnboardingCard } from "../OnboardingCard/platform/PlatformOnboardingCard"; +import { OnboardingCard } from "../OnboardingCard"; function FreeTrialOverDialog() { const dispatch = useDispatch(); @@ -17,7 +17,7 @@ function FreeTrialOverDialog() { return (
- +
); } diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index a313f68d9..71fd4ae0c 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -85,13 +85,6 @@ export const GhostButton = styled.button` } `; -export const InputSubtext = styled.span` - font-size: 0.75rem; - line-height: 1rem; - color: ${lightGray}; - margin-top: 0.25rem; -`; - export const ButtonSubtext = styled.span` display: block; margin-top: 0; diff --git a/gui/src/components/loaders/FreeTrialProgressBar.tsx b/gui/src/components/loaders/FreeTrialProgressBar.tsx index dd8d2be39..1307ba900 100644 --- a/gui/src/components/loaders/FreeTrialProgressBar.tsx +++ b/gui/src/components/loaders/FreeTrialProgressBar.tsx @@ -1,7 +1,7 @@ import { ExclamationCircleIcon } from "@heroicons/react/24/outline"; import { useDispatch } from "react-redux"; import { useNavigate } from "react-router-dom"; -import AddModelForm from "../../forms/AddModelForm"; +import { AddModelForm } from "../../forms"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial"; import { ToolTip } from "../gui/Tooltip"; diff --git a/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx index 6ff314692..50e5a2509 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx @@ -104,7 +104,7 @@ function BlockSettingsToolbarIcon( ? "bg-error" : "bg-badge" : undefined - } relative flex select-none items-center rounded-full px-[3px] transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/50 sm:px-1 ${props.className || ""}`} + } relative flex select-none items-center rounded-full px-[3px] py-0.5 transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/50 sm:px-1 ${props.className || ""}`} > { - ideMessenger - .request("controlPlane/getFreeTrialStatus", undefined) - .then((resp) => { - if (resp.status === "success") { - setFreeTrialStatus(resp.content); - } - }) - .catch(() => {}); - }, []); + const fetchFreeTrialStatus = () => { + ideMessenger + .request("controlPlane/getFreeTrialStatus", undefined) + .then((resp) => { + if (resp.status === "success") { + setFreeTrialStatus(resp.content); + } + }) + .catch(() => {}); + }; + + fetchFreeTrialStatus(); + + let intervalId: NodeJS.Timeout | null = null; + + if (isUsingFreeTrial) { + intervalId = setInterval(fetchFreeTrialStatus, 15000); + } + + return () => { + if (intervalId) { + clearInterval(intervalId); + } + }; + }, [ideMessenger, isUsingFreeTrial]); const handleEllipsisClick = () => { if (isToolbarExpanded) { @@ -180,7 +196,7 @@ export function BlockSettingsTopToolbar() { return (
-
+
-
+
handleRoleUpdate("chat", model)} + setupURL="https://docs.continue.dev/chat/model-setup" /> handleRoleUpdate("autocomplete", model)} + setupURL="https://docs.continue.dev/autocomplete/model-setup" /> {/* Jetbrains has a model selector inline */} {!jetbrains && ( @@ -53,6 +54,7 @@ export function ModelsSection() { models={config.modelsByRole.edit} selectedModel={config.selectedModelByRole.edit} onSelect={(model) => handleRoleUpdate("edit", model)} + setupURL="https://docs.continue.dev/edit/model-setup" /> )} handleRoleUpdate("apply", model)} + setupURL="https://docs.continue.dev/customize/model-roles/apply" /> handleRoleUpdate("embed", model)} + setupURL="https://docs.continue.dev/customize/model-roles/embeddings" /> handleRoleUpdate("rerank", model)} + setupURL="https://docs.continue.dev/customize/model-roles/reranking" />
-
); } diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index 390d7f893..c6f946b89 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -1,4 +1,5 @@ import { + ArrowPathIcon, CheckIcon, ChevronDownIcon, Cog6ToothIcon, @@ -6,14 +7,18 @@ import { PlusIcon, } from "@heroicons/react/24/outline"; import { useContext, useEffect, useRef, useState } from "react"; -import { lightGray } from ".."; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; -import AddModelForm from "../../forms/AddModelForm"; +import { AddModelForm } from "../../forms"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; +import { EMPTY_CONFIG } from "../../redux/slices/configSlice"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; import { updateSelectedModelByRole } from "../../redux/thunks"; -import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; +import { + fontSize, + getMetaKeyLabel, + isMetaEquivalentKeyPressed, +} from "../../util"; import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../ui"; interface ModelOptionProps { @@ -48,15 +53,6 @@ function ModelOption({ }: ModelOptionProps) { const ideMessenger = useContext(IdeMessengerContext); - const [hovered, setHovered] = useState(false); - - function onClickGear(e: any) { - e.stopPropagation(); - e.preventDefault(); - - ideMessenger.post("config/openProfile", { profileId: undefined }); - } - function handleOptionClick(e: any) { if (showMissingApiKeyMsg) { e.preventDefault(); @@ -69,33 +65,21 @@ function ModelOption({ key={idx} disabled={showMissingApiKeyMsg} value={option.value} - onMouseEnter={() => setHovered(true)} - onMouseLeave={() => setHovered(false)} onClick={handleOptionClick} > -
-
-
- - - {option.title} - {showMissingApiKeyMsg && ( - - (Missing API key) - - )} - -
-
- {isSelected && } - {hovered && ( - +
+
+ + + {option.title} + {showMissingApiKeyMsg && ( + (Missing API key) )} -
+
+
); @@ -106,6 +90,11 @@ function ModelSelect() { const isInEdit = useAppSelector((store) => store.session.isInEdit); const config = useAppSelector((state) => state.config.config); + const ideMessenger = useContext(IdeMessengerContext); + const buttonRef = useRef(null); + const [options, setOptions] = useState([]); + const [sortedOptions, setSortedOptions] = useState([]); + const { selectedProfile } = useAuth(); let selectedModel = null; let allModels = null; @@ -120,11 +109,6 @@ function ModelSelect() { allModels = config.modelsByRole.chat; } - const buttonRef = useRef(null); - const [options, setOptions] = useState([]); - const [sortedOptions, setSortedOptions] = useState([]); - const { selectedProfile } = useAuth(); - // Sort so that options without an API key are at the end useEffect(() => { const alphaSort = options.sort((a, b) => a.title.localeCompare(b.title)); @@ -203,6 +187,9 @@ function ModelSelect() { ); } + const isConfigLoading = config === EMPTY_CONFIG; + const hasNoModels = allModels?.length === 0; + return ( { @@ -230,39 +217,69 @@ function ModelSelect() { aria-hidden="true" /> - -
- {sortedOptions.map((option, idx) => ( - - ))} + +
+ Models + + ideMessenger.post("config/openProfile", { + profileId: undefined, + }) + } + />
-
- {selectedProfile?.profileType === "local" && ( - <> - -
- - Add Chat model -
-
- +
+ {isConfigLoading ? ( +
+ + Loading config +
+ ) : hasNoModels ? ( +
+ No models configured +
+ ) : ( + sortedOptions.map((option, idx) => ( + + )) )} - - - {getMetaKeyLabel()}' to toggle model -
+ + {!isConfigLoading && selectedProfile?.profileType === "local" && ( + +
+ + Add Chat model +
+
+ )} + + {!isConfigLoading && ( +
+ {getMetaKeyLabel()}' to toggle model +
+ )}
diff --git a/gui/src/components/modelSelection/ModelSelectionListbox.tsx b/gui/src/components/modelSelection/ModelSelectionListbox.tsx index 3db8ce9c5..04510b6bb 100644 --- a/gui/src/components/modelSelection/ModelSelectionListbox.tsx +++ b/gui/src/components/modelSelection/ModelSelectionListbox.tsx @@ -4,16 +4,6 @@ import { CubeIcon, } from "@heroicons/react/24/outline"; import { Fragment } from "react"; -import styled from "styled-components"; -import { - defaultBorderRadius, - lightGray, - vscBackground, - vscForeground, - vscInputBackground, - vscListActiveBackground, - vscListActiveForeground, -} from ".."; import { Listbox, ListboxButton, @@ -22,85 +12,9 @@ import { Transition, } from "../../components/ui"; import { DisplayInfo } from "../../pages/AddNewModel/configs/models"; -export const StyledListbox = styled(Listbox)` - background-color: ${vscBackground}; -`; - -export const StyledListboxButton = styled(ListboxButton)` - cursor: pointer; - background-color: ${vscBackground}; - text-align: left; - - padding-left: 0.75rem; - padding-right: 2.5rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - - border-radius: 0.5em; - border: 1px solid ${lightGray}; - - margin: 0; - height: 100%; - width: 100%; - - position: relative; - - display: grid; - grid-template-columns: 1fr auto; - align-items: center; - - color: ${vscForeground}; - - &:focus { - outline: none; - } - - &:hover { - background-color: ${vscInputBackground}; - } -`; - -export const StyledListboxOptions = styled(ListboxOptions)` - background-color: ${vscInputBackground}; - padding: 0; - - position: absolute; - top: 100%; - left: 0; - - margin-top: 0.25rem; - - height: fit-content; - max-height: 15rem; - width: 60%; - - border-radius: ${defaultBorderRadius}; - overflow-y: auto; - z-index: 10; - - &:focus { - outline: none; - } -`; -export const StyledListboxOption = styled(ListboxOption)<{ - selected: boolean; -}>` - background-color: ${({ selected }) => - selected ? vscListActiveBackground : vscInputBackground}; - cursor: pointer; - padding: 6px 8px 6px 12px; - - display: flex; - gap: 8px; - align-items: center; - - &:hover { - background-color: ${vscListActiveBackground}; - color: ${vscListActiveForeground}; - } -`; interface ModelSelectionListboxProps { + /** Model selection listbox for choosing AI providers */ selectedProvider: DisplayInfo; setSelectedProvider: (val: DisplayInfo) => void; topOptions?: DisplayInfo[]; @@ -114,9 +28,9 @@ function ModelSelectionListbox({ otherOptions = [], }: ModelSelectionListboxProps) { return ( - +
- + {window.vscMediaUrl && selectedProvider.icon && ( - + + - + {topOptions.length > 0 && (
+
+ Popular +
{topOptions.map((option, index) => ( - + ` ${selected ? "bg-list-active" : "bg-input"} hover:bg-list-active hover:text-list-active-foreground relative flex cursor-default cursor-pointer select-none items-center justify-between gap-2 p-1.5 px-3 py-2 pr-4` + } value={option} > {({ selected }) => ( <> - {option.title === "Autodetect" ? ( - - ) : ( - window.vscMediaUrl && - option.icon && ( - - ) - )} - {option.title} - +
+ {option.title === "Autodetect" ? ( + + ) : ( + window.vscMediaUrl && + option.icon && ( + + ) + )} + {option.title} +
{selected && ( - - +
+ ))}
)} - {topOptions.length > 0 && otherOptions.length > 0 && ( -
+
)} - {otherOptions.length > 0 && (
+
+ Additional providers +
{otherOptions.map((option, index) => ( - + ` ${selected ? "bg-list-active" : "bg-input"} hover:bg-list-active hover:text-list-active-foreground relative flex cursor-default cursor-pointer select-none items-center justify-between gap-2 p-1.5 px-3 py-2 pr-4` + } value={option} > {({ selected }) => ( <> - {option.title === "Autodetect" ? ( - - ) : ( - window.vscMediaUrl && - option.icon && ( - - ) - )} - {option.title} +
+ {option.title === "Autodetect" ? ( + + ) : ( + window.vscMediaUrl && + option.icon && ( + + ) + )} + {option.title} +
{selected && ( - - +
+ ))}
)} - +
- + ); } diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index a97dea525..aebae2aa6 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -32,7 +32,6 @@ import { import type { ProfileDescription } from "core/config/ConfigHandler"; import { useNavigate } from "react-router-dom"; -import { vscCommandCenterInactiveBorder } from "../.."; import { cn } from "../../../util/cn"; import { ROUTES } from "../../../util/navigation"; import { useLump } from "../../mainInput/Lump/LumpContext"; @@ -115,7 +114,7 @@ const AssistantSelectOption = ({ {profile.errors && profile.errors?.length > 0 && ( { e.preventDefault(); e.stopPropagation(); @@ -290,7 +289,7 @@ export default function AssistantSelect() {
- Assistants + Assistants
{ @@ -326,18 +325,11 @@ export default function AssistantSelect() {
-
-
login(false)} >
-
-
void; hideFreeTrialLimitMessage?: boolean; } @@ -26,20 +25,18 @@ const MODEL_PROVIDERS_URL = const CODESTRAL_URL = "https://console.mistral.ai/codestral"; const CONTINUE_SETUP_URL = "https://docs.continue.dev/setup/overview"; -function AddModelForm({ +export function AddModelForm({ onDone, hideFreeTrialLimitMessage, -}: QuickModelSetupProps) { +}: AddModelFormProps) { const [selectedProvider, setSelectedProvider] = useState( providers["openai"]!, ); const dispatch = useAppDispatch(); const { selectedProfile } = useAuth(); - const [selectedModel, setSelectedModel] = useState( selectedProvider.packages[0], ); - const formMethods = useForm(); const ideMessenger = useContext(IdeMessengerContext); @@ -94,6 +91,7 @@ function AddModelForm({ function onSubmit() { const apiKey = formMethods.watch("apiKey"); const hasValidApiKey = apiKey !== undefined && apiKey !== ""; + const reqInputFields: Record = {}; for (let input of selectedProvider.collectInputFor ?? []) { reqInputFields[input.key] = formMethods.watch(input.key); @@ -109,11 +107,12 @@ function AddModelForm({ }; ideMessenger.post("config/addModel", { model }); + ideMessenger.post("config/openProfile", { profileId: "local", }); - dispatch( + void dispatch( updateSelectedModelByRole({ selectedProfile, role: "chat", @@ -134,6 +133,7 @@ function AddModelForm({

Add Chat model

+ {/* TODO sync free trial limit with hub */} {/* {!hideFreeTrialLimitMessage && hasPassedFTL() && (

@@ -166,7 +166,7 @@ function AddModelForm({ topOptions={popularProviders} otherOptions={otherProviders} /> - + Don't see your provider?{" "} {" "} to view the full list - +

{selectedProvider.downloadUrl && ( @@ -185,7 +185,6 @@ function AddModelForm({ -

{selectedProvider.downloadUrl} @@ -212,7 +211,7 @@ function AddModelForm({ setSelectedModel(match); } }} - otherOptions={ + topOptions={ Object.entries(providers).find( ([, provider]) => provider?.title === selectedProvider.title, @@ -242,12 +241,13 @@ function AddModelForm({ - + { if (selectedProviderApiKeyUrl) { ideMessenger.post( @@ -260,7 +260,7 @@ function AddModelForm({ Click here {" "} to create a {selectedProvider.title} API key - +

)} @@ -276,7 +276,7 @@ function AddModelForm({ field.key !== "apiKey", ) .map((field) => ( -
+
<>
diff --git a/gui/src/forms/index.ts b/gui/src/forms/index.ts new file mode 100644 index 000000000..410a55a37 --- /dev/null +++ b/gui/src/forms/index.ts @@ -0,0 +1 @@ +export * from "./AddModelForm"; diff --git a/gui/src/pages/config/HelpCenterSection.tsx b/gui/src/pages/config/HelpCenterSection.tsx index e49a17780..004e5b78a 100644 --- a/gui/src/pages/config/HelpCenterSection.tsx +++ b/gui/src/pages/config/HelpCenterSection.tsx @@ -81,7 +81,12 @@ export function HelpCenterSection() { generateTitle: true, }), ); - dispatch(setOnboardingCard({ show: true, activeTab: "Best" })); + dispatch( + setOnboardingCard({ + show: true, + activeTab: undefined, + }), + ); ideMessenger.post("showTutorial", undefined); }} /> diff --git a/gui/src/pages/config/ModelRoleSelector.tsx b/gui/src/pages/config/ModelRoleSelector.tsx index 2214853a4..0065552a8 100644 --- a/gui/src/pages/config/ModelRoleSelector.tsx +++ b/gui/src/pages/config/ModelRoleSelector.tsx @@ -26,6 +26,7 @@ interface ModelRoleSelectorProps { onSelect: (model: ModelDescription | null) => void; displayName: string; description: string; + setupURL: string; } const ModelRoleSelector = ({ @@ -34,6 +35,7 @@ const ModelRoleSelector = ({ onSelect, displayName, description, + setupURL, }: ModelRoleSelectorProps) => { const ideMessenger = useContext(IdeMessengerContext); const [hoveredIdx, setHoveredIdx] = useState(null); @@ -65,102 +67,111 @@ const ModelRoleSelector = ({ return ( <>
- - {displayName} - + {displayName} {description}
+
- - {models.length === 0 || noConfiguredModels ? ( - - {`No ${models.length === 0 ? "" : "valid "}${displayName} models${ - ["Chat", "Apply", "Edit"].includes(displayName) - ? ". Using Chat model" - : "" - }`} - - ) : ( - - {selectedModel?.title ?? `Select ${displayName} model`} - - )} - {models.length ? ( -
-
- ) : null} -
- - - ideMessenger.post("openUrl", setupURL)} + className="bg-vsc-editor-background hover:bg-list-active hover:text-list-active-foreground text-description w-full justify-between px-2 py-1 underline hover:underline" > - {[...models] - .sort((a, b) => a.title.localeCompare(b.title)) - .map((option, idx) => { - const showMissingApiKeyMsg = - option.configurationStatus === - LLMConfigurationStatuses.MISSING_API_KEY; + + Setup {displayName} model + + + ) : ( + <> + + {models.length === 0 || noConfiguredModels ? ( + + {`No ${models.length === 0 ? "" : "valid "}${displayName} models${ + ["Chat", "Apply", "Edit"].includes(displayName) + ? ". Using Chat model" + : "" + }`} + + ) : ( + + {selectedModel?.title ?? `Select ${displayName} model`} + + )} - return ( - setHoveredIdx(idx)} - onMouseLeave={() => setHoveredIdx(null)} - onClick={(e: any) => - handleOptionClick(showMissingApiKeyMsg, e) - } - className={""} - > -
-
-
- - - {option.title} - {showMissingApiKeyMsg && ( - - (Missing API key) + {models.length > 0 && ( +
+
+ )} + + + + {[...models] + .sort((a, b) => a.title.localeCompare(b.title)) + .map((option, idx) => { + const showMissingApiKeyMsg = + option.configurationStatus === + LLMConfigurationStatuses.MISSING_API_KEY; + + return ( + setHoveredIdx(idx)} + onMouseLeave={() => setHoveredIdx(null)} + onClick={(e: any) => + handleOptionClick(showMissingApiKeyMsg, e) + } + className="" + > +
+
+
+ + + {option.title} + {showMissingApiKeyMsg && ( + + (Missing API key) + + )} - )} - +
+ +
+ {hoveredIdx === idx && ( + + )} + {option.title === selectedModel?.title && ( + + )} +
+
-
- {hoveredIdx === idx && ( - - )} - {option.title === selectedModel?.title && ( - - )} -
-
-
- - ); - })} - - + + ); + })} + + + + )}
diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index f2caf727c..b369e0a53 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -49,6 +49,7 @@ import { streamEditThunk } from "../../redux/thunks/edit"; import { loadLastSession } from "../../redux/thunks/session"; import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util"; +import { OnboardingModes } from "core/protocol/core"; import { getLocalStorage, setLocalStorage } from "../../util/localStorage"; import { EmptyChatBody } from "./EmptyChatBody"; import { ExploreDialogWatcher } from "./ExploreDialogWatcher"; @@ -201,9 +202,9 @@ export function Chat() { // "You've reached the free trial limit. Please configure a model to continue.", // ); - // // Card in chat will only show if no history - // // Also, note that platform card ignore the "Best", always opens to main tab - // onboardingCard.open("Best"); + // Card in chat will only show if no history + // Also, note that platform card ignore the "Best", always opens to main tab + onboardingCard.open(OnboardingModes.API_KEY); // // If history, show the dialog, which will automatically close if there is not history // if (history.length) { diff --git a/gui/src/pages/gui/EmptyChatBody.tsx b/gui/src/pages/gui/EmptyChatBody.tsx index ac8ba7631..54185f597 100644 --- a/gui/src/pages/gui/EmptyChatBody.tsx +++ b/gui/src/pages/gui/EmptyChatBody.tsx @@ -1,7 +1,6 @@ import { ConversationStarterCards } from "../../components/ConversationStarters"; import { ExploreHubCard } from "../../components/ExploreHubCard"; import { OnboardingCard } from "../../components/OnboardingCard"; -import { PlatformOnboardingCard } from "../../components/OnboardingCard/platform/PlatformOnboardingCard"; export interface EmptyChatBodyProps { showOnboardingCard?: boolean; @@ -11,12 +10,7 @@ export function EmptyChatBody({ showOnboardingCard }: EmptyChatBodyProps) { if (showOnboardingCard) { return (
- {true ? ( - // For now we are excluding local onboarding options other than ollama - - ) : ( - - )} +
); } diff --git a/gui/src/redux/slices/configSlice.ts b/gui/src/redux/slices/configSlice.ts index 0c78a27e0..b26d596c8 100644 --- a/gui/src/redux/slices/configSlice.ts +++ b/gui/src/redux/slices/configSlice.ts @@ -8,7 +8,7 @@ export type ConfigState = { config: BrowserSerializedContinueConfig; }; -const EMPTY_CONFIG: BrowserSerializedContinueConfig = { +export const EMPTY_CONFIG: BrowserSerializedContinueConfig = { slashCommands: [ { name: "share", diff --git a/gui/src/redux/thunks/selectFirstHubProfile.ts b/gui/src/redux/thunks/selectFirstHubProfile.ts index f8018702c..d1715ed98 100644 --- a/gui/src/redux/thunks/selectFirstHubProfile.ts +++ b/gui/src/redux/thunks/selectFirstHubProfile.ts @@ -11,23 +11,46 @@ export const selectFirstHubProfile = createAsyncThunk< void, undefined, ThunkApiType ->("selectFirstHubProfile", async (messages, { dispatch, extra, getState }) => { - const state = getState(); +>("selectFirstHubProfile", async (_, { dispatch, extra, getState }) => { + let attempts = 0; + const maxAttempts = 3; - const currentOrgProfiles = state.profiles.organizations.find( - (org) => org.id === (state.profiles.selectedOrganizationId ?? "personal"), - ); + const findAndSelectProfile = () => { + const state = getState(); - const firstHubProfile = currentOrgProfiles?.profiles.find( - (profile) => profile.profileType === "platform", - ); + const currentOrgProfiles = state.profiles.organizations.find( + (org) => org.id === (state.profiles.selectedOrganizationId ?? "personal"), + ); - if (!firstHubProfile) { + const firstHubProfile = currentOrgProfiles?.profiles.find( + (profile) => profile.profileType === "platform", + ); + + if (firstHubProfile) { + dispatch(setSelectedProfile(firstHubProfile.id)); + extra.ideMessenger.post("didChangeSelectedProfile", { + id: firstHubProfile.id, + }); + return true; + } + + return false; + }; + + // Try immediately first + if (findAndSelectProfile()) { return; } - dispatch(setSelectedProfile(firstHubProfile.id)); - extra.ideMessenger.post("didChangeSelectedProfile", { - id: firstHubProfile.id, + // If not found, poll every second for up to maxAttempts + return new Promise((resolve) => { + const interval = setInterval(() => { + attempts++; + + if (findAndSelectProfile() || attempts >= maxAttempts) { + clearInterval(interval); + resolve(); + } + }, 1000); }); });