Merge pull request #6034 from continuedev/pe/onboarding-card-refactor

feat: refactor onboarding card
This commit is contained in:
Nate Sesti 2025-06-08 23:26:01 -07:00 • committed by GitHub
commit ffdd5f2608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 884 additions and 1089 deletions

View file

@ -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)`

View file

@ -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],
};
}

View file

@ -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<CompleteOnboardingPayload>,
) {
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:

0
core/core_temp.ts Normal file
View file

6
core/index.d.ts vendored
View file

@ -1578,3 +1578,9 @@ export interface RuleWithSource {
ruleFile?: string;
alwaysApply?: boolean;
}
export interface CompleteOnboardingPayload {
mode: OnboardingModes;
provider?: string;
apiKey?: string;
}

View file

@ -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: [

View file

@ -55,7 +55,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
"docs/initStatuses",
"docs/getDetails",
//
"completeOnboarding",
"onboarding/complete",
"addAutocompleteModel",
"didChangeSelectedProfile",
"didChangeSelectedOrg",

View file

@ -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

View file

@ -121,7 +121,7 @@ class MessageTypes {
"docs/initStatuses",
"docs/getDetails",
//
"completeOnboarding",
"onboarding/complete",
"addAutocompleteModel",
"didChangeSelectedProfile",
"didChangeSelectedOrg",

View file

@ -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"

View file

@ -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) =>

17
gui/package-lock.json generated
View file

@ -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"
},

View file

@ -1,25 +0,0 @@
import { useContext } from "react";
import { ButtonSubtext } from ".";
import { IdeMessengerContext } from "../context/IdeMessenger";
function AddModelButtonSubtext() {
const ideMessenger = useContext(IdeMessengerContext);
return (
<ButtonSubtext>
This will update your{" "}
<span
className="cursor-pointer underline"
onClick={() =>
ideMessenger.post("config/openProfile", {
profileId: undefined,
})
}
>
config file
</span>
</ButtonSubtext>
);
}
export default AddModelButtonSubtext;

View file

@ -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]);

View file

@ -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 <Tabs.Quickstart />;
case "Best":
return <Tabs.Best />;
case "Local":
return <Tabs.Local />;
default:
return <Tabs.Quickstart />;
}
}
if (getLocalStorage("onboardingStatus") === undefined) {
setLocalStorage("onboardingStatus", "Started");
}
function renderTabContent() {
switch (activeTab) {
case OnboardingModes.API_KEY:
return <OnboardingProvidersTab />;
case OnboardingModes.LOCAL:
return <OnboardingLocalTab />;
default:
return <OnboardingProvidersTab />;
}
}
if (activeTab) {
return (
<ReusableCard
showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
onClose={close}
testId="onboarding-card"
>
<OnboardingCardTabs activeTab={activeTab} onTabClick={setActiveTab} />
{renderTabContent()}
</ReusableCard>
);
}
return (
<ReusableCard
showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
onClose={() => onboardingCard.close()}
testId="onboarding-card"
onClose={close}
>
<OnboardingCardTabs
activeTab={onboardingCard.activeTab || "Best"}
onTabClick={onboardingCard.setActiveTab}
/>
{renderTabContent()}
<div className="flex h-full w-full items-center justify-center">
<OnboardingCardLanding
onSelectConfigure={() => setActiveTab(OnboardingModes.API_KEY)}
isDialog={isDialog}
/>
</div>
</ReusableCard>
);
}

View file

@ -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<HTMLFormElement> = 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 (
<form onSubmit={handleSubmit}>
<div className="flex flex-col gap-3">
<div>
<div className="mb-1 flex flex-row justify-between gap-4 text-lg font-bold">
<label className="text-lg font-bold">Chat model</label>
<div
className="hidden items-center justify-end text-xs font-semibold sm:flex"
style={{ color: lightGray }}
>
<CubeIcon className="mr-1 h-4 w-4 flex-shrink-0" />
<span className="inline text-right italic">
{chatModel.title}{" "}
<span className="hidden md:inline">by Anthropic</span>
</span>
</div>
</div>
<div className="flex w-full flex-col pb-4">
<Input
placeholder="Enter your Anthropic API Key"
value={chatApiKey}
onChange={(e) => setChatApiKey(e.target.value)}
data-testid="best-chat-api-key-input"
/>
<InputSubtext>
<a
href={chatProvider.apiKeyUrl}
target="_blank"
className="cursor-pointer text-inherit underline hover:text-inherit"
>
Click here
</a>{" "}
to create an Anthropic API key
</InputSubtext>
</div>
</div>
<div>
<div className="mb-1 flex flex-row justify-between gap-4 text-lg font-bold">
<label className="text-lg font-bold">Autocomplete model</label>
<div
className="flex hidden items-center text-xs font-semibold sm:flex"
style={{ color: lightGray }}
>
<CubeIcon className="mr-1 inline h-4 w-4 flex-shrink-0" />
<span className="text-right italic">
{autocompleteModel.title}{" "}
<span className="hidden md:inline">by Mistral</span>
</span>
</div>
</div>
<div className="flex w-full flex-col pb-4">
<Input
placeholder="Enter your Mistral API Key"
value={autocompleteApiKey}
onChange={(e) => setAutocompleteApiKey(e.target.value)}
data-testid="best-autocomplete-api-key-input"
/>
<InputSubtext>
<a
href={autocompleteProvider.apiKeyUrl}
target="_blank"
className="cursor-pointer text-inherit underline hover:text-inherit"
>
Click here
</a>{" "}
to create a Mistral API key
</InputSubtext>
</div>
</div>
<div className="w-full">
<Button className="w-full" type="submit" disabled={!chatApiKey}>
Connect
</Button>
<AddModelButtonSubtext />
</div>
</div>
</form>
);
}
export default BestExperienceConfigForm;

View file

@ -27,7 +27,7 @@ function OllamaModelDownload({
return (
<div className="flex flex-col">
<p className="mb-1 mt-4 text-base font-semibold">{title}</p>
<p className="mb-0 mt-4 text-base font-semibold">{title}</p>
{hasDownloaded ? (
<OllamaCompletedStep text={command} />
) : (

View file

@ -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 (
<div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center">
<div className="xs:flex hidden">
<ContinueLogo height={75} />
</div>
{pastFreeTrialLimit ? (
<>
<p className="xs:w-3/4 w-full text-sm">
You've reached the free trial limit. Visit the Continue Platform to
select a Coding Assistant.
</p>
<Button
onClick={openPastFreeTrialOnboarding}
className="mt-4 grid w-full grid-flow-col items-center gap-2"
>
Go to Continue Platform
</Button>
</>
) : (
<>
<p className="mb-5 mt-0 w-full text-sm">
Log in to access a free trial of the
<br />
<span
className="cursor-pointer underline hover:brightness-125"
data-tooltip-id="models-addon-tooltip"
onClick={() =>
ideMessenger.post("controlPlane/openUrl", {
path: "pricing",
})
}
>
Models Add-On
</span>
<ToolTip id="models-addon-tooltip" place="bottom">
Free trial includes 50 Chat requests and 2,000 autocomplete
requests
</ToolTip>
</p>
<Button
onClick={onGetStarted}
className="mt-4 grid w-full grid-flow-col items-center gap-2"
>
Log in to Continue Hub
</Button>
</>
)}
<SecondaryButton onClick={onSelectConfigure} className="w-full">
Or, configure your own models
</SecondaryButton>
</div>
);
}

View file

@ -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 <KeyIcon className="h-4 w-4" />;
}
if (tabTitle === OnboardingModes.LOCAL) {
return (
<img
src={`${window.vscMediaUrl}/logos/ollama.png`}
alt="Ollama"
className="h-4 w-4 object-contain"
/>
);
}
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 (
<div>
<div className="xs:block hidden">
<TabList>
{Object.entries(TabTitles).map(([tabType, titles]) => {
if (hasPassedFTL() && tabType === "Quickstart") {
return undefined;
}
<div className="border-foreground border-x-0 border-b border-t-0 border-solid">
{Object.values(OnboardingModes).map((tabTitle) => {
const isActive = activeTab === tabTitle;
return (
<TabButton
className="xs:py-2 xs:px-3 rounded-t-sm px-6 py-2 hover:brightness-125 sm:px-5"
key={tabType}
isActive={activeTab === tabType}
onClick={() => onTabClick(tabType as TabTitle)}
data-testid={`onboarding-tab-${tabType}`}
<button
className={`xs:py-2 xs:px-3 text-foreground -mb-px cursor-pointer rounded-t-sm border-none bg-transparent px-6 py-2 font-medium hover:brightness-125 focus:outline-none sm:px-5 ${isActive ? "font-semibold" : ""}`}
key={tabTitle}
onClick={() => onTabClick(tabTitle as OnboardingModes)}
data-testid={`onboarding-tab-${tabTitle}`}
>
<p className="m-0 hidden font-medium md:block">
{titles.default}
<p className="m-0 flex items-center gap-2">
{getTabIcon(tabTitle)}
{tabTitle}
</p>
<p className="m-0 block font-medium md:hidden">{titles.md}</p>
</TabButton>
</button>
);
})}
</TabList>
</div>
</div>
<div className="xs:hidden block">
<StyledSelect
value={activeTab}
onChange={(e) => onTabClick(e.target.value as TabTitle)}
>
{Object.entries(TabTitles).map(([tabType, titles]) => {
if (hasPassedFTL() && tabType === "Quickstart") {
return null;
}
<div className="xs:hidden block">
<select
className="text-foreground border-foreground w-full cursor-pointer rounded-none border-b border-none bg-transparent p-2 text-base focus:outline-none"
value={activeTab}
onChange={(e) => onTabClick(e.target.value as OnboardingModes)}
>
{Object.values(OnboardingModes).map((tabTitle) => {
return (
<option key={tabType} value={tabType}>
{titles.md}
<option key={tabTitle} value={tabTitle}>
{tabTitle}
</option>
);
})}
</StyledSelect>
</select>
</div>
</div>
);

View file

@ -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 (
<div className="mt-3 flex flex-col gap-1 px-2">
<div className="flex flex-col">
<p className="mb-0 pb-1 text-base font-bold leading-tight">
Install Ollama
</p>
<OllamaStatus isOllamaConnected={isOllamaConnected} />
</div>
<div className="flex h-full w-full items-center justify-center">
<div className="w-full max-w-md">
<div className="mt-3 flex flex-col gap-1 px-2">
<div className="flex flex-col">
<p className="mb-0 text-base font-bold leading-tight">
Install Ollama
</p>
<OllamaStatus isOllamaConnected={isOllamaConnected} />
</div>
<OllamaModelDownload
title="Download Chat model"
modelName={LOCAL_ONBOARDING_CHAT_MODEL}
hasDownloaded={hasDownloadedChatModel}
/>
<OllamaModelDownload
title="Download Chat model"
modelName={LOCAL_ONBOARDING_CHAT_MODEL}
hasDownloaded={hasDownloadedChatModel}
/>
<OllamaModelDownload
title="Download Autocomplete model"
modelName={LOCAL_ONBOARDING_FIM_MODEL}
hasDownloaded={hasDownloadedAutocompleteModel}
/>
<OllamaModelDownload
title="Download Autocomplete model"
modelName={LOCAL_ONBOARDING_FIM_MODEL}
hasDownloaded={hasDownloadedAutocompleteModel}
/>
<OllamaModelDownload
title="Download Embeddings model"
modelName={LOCAL_ONBOARDING_EMBEDDINGS_MODEL}
hasDownloaded={hasDownloadedEmbeddingsModel}
/>
<OllamaModelDownload
title="Download Embeddings model"
modelName={LOCAL_ONBOARDING_EMBEDDINGS_MODEL}
hasDownloaded={hasDownloadedEmbeddingsModel}
/>
<div className="mt-4 w-full">
<Button
onClick={onClickSubmitOnboarding}
className="w-full"
disabled={!allDownloaded}
>
Connect
</Button>
<ButtonSubtext>
<span className="cursor-pointer underline" onClick={onClickSkip}>
Skip and configure manually
</span>
</ButtonSubtext>
<div className="mt-4 w-full">
<Button
onClick={onClickSubmitOnboarding}
className="w-full"
disabled={!allDownloaded}
>
Connect
</Button>
<div className="w-full text-center">
<span
className="text-description-muted cursor-pointer underline"
onClick={onClickSkip}
>
Skip and configure manually
</span>
</div>
</div>
</div>
</div>
</div>
);
}
export default OnboardingLocalTab;

View file

@ -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(
<AddModelForm
onDone={() => {
dispatch(setShowDialog(false));
submitOnboarding();
}}
/>,
),
);
};
const hasAnyApiKey = providerConfigs.some((config) => {
const apiKey = formMethods.watch(`${config?.provider}_apiKey`);
return apiKey?.trim();
});
return (
<div className="flex h-full w-full items-center justify-center">
<div className="w-full max-w-md">
<FormProvider {...formMethods}>
<div className="mt-5 space-y-6">
<div className="space-y-4">
{providerConfigs.map((config) => (
<div key={config?.provider}>
<label className="mb-1 flex items-center gap-3 text-sm font-medium">
{window.vscMediaUrl && (
<img
src={`${window.vscMediaUrl}/logos/${config?.icon}`}
alt={config?.provider}
className="h-4 w-4 object-contain"
/>
)}
{config?.title}
</label>
<Input
id={`${config?.provider}_apiKey`}
type="password"
placeholder={`Enter your ${config?.title} API key`}
className="w-full"
{...formMethods.register(`${config?.provider}_apiKey`)}
/>
<span className="text-description-muted mt-1 block text-xs">
<a
href={config?.apiKeyUrl}
target="_blank"
rel="noopener noreferrer"
className="cursor-pointer text-inherit underline hover:text-inherit hover:brightness-125"
>
Click here
</a>{" "}
to create a {config?.title} API key
</span>
</div>
))}
</div>
<div>
<Button
type="button"
onClick={handleFormSubmit}
disabled={!hasAnyApiKey}
className="w-full"
>
Connect
</Button>
<div className="w-full text-center">
<span className="text-description-muted">
<span
className="cursor-pointer underline hover:brightness-125"
onClick={handleClickMoreProviders}
>
Click here
</span>{" "}
to view more providers
</span>
</div>
</div>
</div>
</FormProvider>
</div>
</div>
);
}

View file

@ -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(<AddModelForm onDone={submitOnboarding} />));
}
return (
<div className="w-full">
<Alert type="info">
<p className="m-0 text-sm font-semibold">
Prefer to use a different provider like OpenAI?
</p>
<p className="m-0 mt-1 text-xs">
<a
className="cursor-pointer text-inherit underline hover:text-inherit"
onClick={onClick}
>
Click here
</a>{" "}
to add a Chat model from OpenAI, Gemini, and more
</p>
</Alert>
</div>
);
}
export default ProviderAlert;

View file

@ -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 (
<div className="mt-4 w-full">
<Button
onClick={onClick}
className="grid w-full grid-flow-col items-center gap-2"
>
Get started using our API keys
</Button>
<ButtonSubtext>Try 50 chat and 2k autocomplete requests</ButtonSubtext>
</div>
);
}
export default QuickstartSubmitButton;

View file

@ -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";

View file

@ -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 }));
}

View file

@ -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 {

View file

@ -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 (
<ReusableCard
showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
onClose={() => onboardingCard.close()}
>
<div className="flex h-full w-full items-center justify-center">
{currentTab === "main" ? (
<MainTab
onRemainLocal={() => setCurrentTab("local")}
isDialog={isDialog}
/>
) : (
<div className="mt-4 flex flex-col">
<Alert type="info">
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{" "}
<a href="#" onClick={onGetStarted}>
here
</a>
</Alert>
<OnboardingLocalTab isDialog={isDialog} />
</div>
)}
</div>
</ReusableCard>
);
}

View file

@ -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 (
<div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center">
<div className="xs:flex hidden">
<ContinueLogo height={75} />
</div>
{pastFreeTrialLimit ? (
<>
<p className="xs:w-3/4 w-full text-sm">
You've reached the free trial limit. Visit the Continue Platform to
select a Coding Assistant.
</p>
<Button
onClick={openPastFreeTrialOnboarding}
className="mt-4 grid w-full grid-flow-col items-center gap-2"
>
Go to Continue Platform
</Button>
</>
) : onboardingCard.activeTab === "ExistingUserHubIntro" ? (
<>
<p className="xs:w-3/4 w-full text-sm">
You can now browse and create custom AI code assistants at{" "}
<code>hub.continue.dev</code>
</p>
<Button
onClick={onGetStarted}
className="mt-4 grid w-full grid-flow-col items-center gap-2"
>
Get started with Free Trial
</Button>
</>
) : (
<>
<p className="xs:w-3/4 w-full text-sm">
Log in to quickly build your first custom AI code assistant
</p>
<Button
onClick={onGetStarted}
className="mt-4 grid w-full grid-flow-col items-center gap-2"
>
Get started with Free Trial
</Button>
</>
)}
{onboardingCard.activeTab === "ExistingUserHubIntro" ? (
<ButtonSubtext onClick={() => onboardingCard.close(isDialog)}>
<div className="mt-1 flex cursor-pointer items-center justify-center gap-1">
<span>Or, use Continue as usual</span>
<ChevronRightIcon className="h-3 w-3" />
</div>
</ButtonSubtext>
) : (
<ButtonSubtext onClick={onRemainLocal}>
<div className="mt-1 flex cursor-pointer items-center justify-center gap-1 hover:brightness-125">
<span>Or, remain local</span>
<ChevronRightIcon className="h-3 w-3" />
</div>
</ButtonSubtext>
)}
</div>
);
}

View file

@ -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 (
<div className="flex flex-col gap-8">
<div className="xs:flex hidden w-full">
<ProviderAlert />
</div>
<BestExperienceConfigForm onComplete={submitOnboarding} />
</div>
);
}
export default OnboardingBestTab;

View file

@ -1,31 +0,0 @@
import ContinueLogo from "../../gui/ContinueLogo";
import QuickStartSubmitButton from "../components/QuickStartSubmitButton";
interface OnboardingQuickstartTabProps {
isDialog?: boolean;
}
function OnboardingQuickstartTab({ isDialog }: OnboardingQuickstartTabProps) {
return (
<div className="flex h-full w-full items-center justify-center">
<div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center">
<div className="xs:flex hidden">
<ContinueLogo height={75} />
</div>
<p className="xs:w-3/4 w-full text-sm">
Quickly get up and running using our API keys. After this trial, we'll
help you set up your own models.
</p>
<p className="xs:w-3/4 w-full text-sm">
To prevent abuse, we'll ask you to sign in to GitHub.
</p>
<QuickStartSubmitButton isDialog={isDialog} />
</div>
</div>
);
}
export default OnboardingQuickstartTab;

View file

@ -1,3 +0,0 @@
export { default as Local } from "../components/OnboardingLocalTab";
export { default as Best } from "./OnboardingBestTab";
export { default as Quickstart } from "./OnboardingQuickstartTab";

View file

@ -24,7 +24,7 @@ export function isNewUserOnboarding() {
export const defaultOnboardingCardState: OnboardingCardState = {
show: false,
activeTab: "Quickstart",
activeTab: undefined,
};
export enum OllamaConnectionStatuses {

View file

@ -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 (
<div className="flex-1">
<PlatformOnboardingCard isDialog />
<OnboardingCard isDialog />
</div>
);
}

View file

@ -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;

View file

@ -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";

View file

@ -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 || ""}`}
>
<props.icon
className={`h-[13px] w-[13px] flex-shrink-0 hover:brightness-125 ${
@ -154,15 +154,31 @@ export function BlockSettingsTopToolbar() {
const isUsingFreeTrial = usesFreeTrialApiKey(config);
useEffect(() => {
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 (
<div className="flex flex-1 items-center justify-between gap-2">
<div className="flex flex-row">
<div className="xs:flex text-description hidden items-center justify-center">
<div className="xs:flex text-description hidden items-center justify-center gap-0.5">
<BlockSettingsToolbarIcon
className="-ml-1.5"
icon={isToolbarExpanded ? ChevronLeftIcon : EllipsisHorizontalIcon}

View file

@ -5,7 +5,6 @@ import ModelRoleSelector from "../../../../pages/config/ModelRoleSelector";
import { useAppDispatch, useAppSelector } from "../../../../redux/hooks";
import { updateSelectedModelByRole } from "../../../../redux/thunks";
import { isJetBrains } from "../../../../util";
import { ExploreBlocksButton } from "./ExploreBlocksButton";
export function ModelsSection() {
const { selectedProfile } = useAuth();
@ -19,7 +18,7 @@ export function ModelsSection() {
return;
}
dispatch(
void dispatch(
updateSelectedModelByRole({
role,
selectedProfile,
@ -30,13 +29,14 @@ export function ModelsSection() {
return (
<div>
<div className="text-[${getFontSize() - 1}px] grid grid-cols-1 gap-x-2 gap-y-1 pb-2 sm:grid-cols-[auto_1fr]">
<div className="text-[${getFontSize() - 1}px] grid grid-cols-1 gap-x-2 gap-y-1 sm:grid-cols-[auto_1fr]">
<ModelRoleSelector
displayName="Chat"
description="Used in the chat interface"
models={config.modelsByRole.chat}
selectedModel={config.selectedModelByRole.chat}
onSelect={(model) => handleRoleUpdate("chat", model)}
setupURL="https://docs.continue.dev/chat/model-setup"
/>
<ModelRoleSelector
displayName="Autocomplete"
@ -44,6 +44,7 @@ export function ModelsSection() {
models={config.modelsByRole.autocomplete}
selectedModel={config.selectedModelByRole.autocomplete}
onSelect={(model) => 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"
/>
)}
<ModelRoleSelector
@ -61,6 +63,7 @@ export function ModelsSection() {
models={config.modelsByRole.apply}
selectedModel={config.selectedModelByRole.apply}
onSelect={(model) => handleRoleUpdate("apply", model)}
setupURL="https://docs.continue.dev/customize/model-roles/apply"
/>
<ModelRoleSelector
displayName="Embed"
@ -68,6 +71,7 @@ export function ModelsSection() {
models={config.modelsByRole.embed}
selectedModel={config.selectedModelByRole.embed}
onSelect={(model) => handleRoleUpdate("embed", model)}
setupURL="https://docs.continue.dev/customize/model-roles/embeddings"
/>
<ModelRoleSelector
displayName="Rerank"
@ -75,9 +79,9 @@ export function ModelsSection() {
models={config.modelsByRole.rerank}
selectedModel={config.selectedModelByRole.rerank}
onSelect={(model) => handleRoleUpdate("rerank", model)}
setupURL="https://docs.continue.dev/customize/model-roles/reranking"
/>
</div>
<ExploreBlocksButton blockType={"models"} />
</div>
);
}

View file

@ -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}
>
<div className="flex flex-col gap-0.5">
<div className="flex flex-1 flex-row items-center justify-between gap-2">
<div className="flex flex-1 flex-row items-center gap-2">
<CubeIcon className="h-3 w-3 flex-shrink-0" />
<span className="line-clamp-1 flex-1">
{option.title}
{showMissingApiKeyMsg && (
<span className="ml-2 text-[10px] italic">
(Missing API key)
</span>
)}
</span>
</div>
<div className="flex flex-shrink-0 flex-row items-center gap-1">
{isSelected && <CheckIcon className="h-3 w-3 flex-shrink-0" />}
{hovered && (
<Cog6ToothIcon
className="h-3 w-3 flex-shrink-0"
onClick={onClickGear}
/>
<div className="flex w-full items-center justify-between">
<div className="flex items-center gap-2">
<CubeIcon className="h-3 w-3 flex-shrink-0" />
<span className="line-clamp-1">
{option.title}
{showMissingApiKeyMsg && (
<span className="ml-2 text-[10px] italic">(Missing API key)</span>
)}
</div>
</span>
</div>
<CheckIcon
className={`h-3 w-3 flex-shrink-0 ${isSelected ? "" : "invisible"}`}
/>
</div>
</ListboxOption>
);
@ -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<HTMLButtonElement>(null);
const [options, setOptions] = useState<Option[]>([]);
const [sortedOptions, setSortedOptions] = useState<Option[]>([]);
const { selectedProfile } = useAuth();
let selectedModel = null;
let allModels = null;
@ -120,11 +109,6 @@ function ModelSelect() {
allModels = config.modelsByRole.chat;
}
const buttonRef = useRef<HTMLButtonElement>(null);
const [options, setOptions] = useState<Option[]>([]);
const [sortedOptions, setSortedOptions] = useState<Option[]>([]);
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 (
<Listbox
onChange={async (val: string) => {
@ -230,39 +217,69 @@ function ModelSelect() {
aria-hidden="true"
/>
</ListboxButton>
<ListboxOptions className={"min-w-[160px]"}>
<div className={`no-scrollbar max-h-[300px] overflow-y-auto`}>
{sortedOptions.map((option, idx) => (
<ModelOption
option={option}
idx={idx}
key={idx}
showMissingApiKeyMsg={option.apiKey === ""}
isSelected={option.value === selectedModel?.title}
/>
))}
<ListboxOptions className="min-w-[160px]">
<div className="flex items-center justify-between gap-1 px-2 py-1">
<span className="font-semibold">Models</span>
<Cog6ToothIcon
className="text-description h-3 w-3 cursor-pointer hover:brightness-125"
onClick={() =>
ideMessenger.post("config/openProfile", {
profileId: undefined,
})
}
/>
</div>
<div className="">
{selectedProfile?.profileType === "local" && (
<>
<ListboxOption
key={options.length}
onClick={onClickAddModel}
value={"addModel" as any}
>
<div className="flex items-center py-0.5">
<PlusIcon className="mr-2 h-3 w-3" />
Add Chat model
</div>
</ListboxOption>
</>
<div className="no-scrollbar max-h-[300px] overflow-y-auto">
{isConfigLoading ? (
<div className="text-description flex items-center gap-2 px-2 pb-2 pt-1 text-xs">
<ArrowPathIcon className="animate-spin-slow h-3 w-3" />
<span>Loading config</span>
</div>
) : hasNoModels ? (
<div className="text-description-muted px-2 py-4 text-center text-sm">
No models configured
</div>
) : (
sortedOptions.map((option, idx) => (
<ModelOption
option={option}
idx={idx}
key={idx}
showMissingApiKeyMsg={option.apiKey === ""}
isSelected={option.value === selectedModel?.title}
/>
))
)}
<span className="block px-2 py-1" style={{ color: lightGray }}>
{getMetaKeyLabel()}' to toggle model
</span>
</div>
{!isConfigLoading && selectedProfile?.profileType === "local" && (
<ListboxOption
key={options.length}
onClick={onClickAddModel}
value={"addModel" as any}
className="border-border border-x-0 border-y border-solid"
>
<div
className="text-description flex items-center py-0.5 hover:text-inherit"
style={{
fontSize: fontSize(-3),
}}
>
<PlusIcon className="mr-2 h-3 w-3" />
Add Chat model
</div>
</ListboxOption>
)}
{!isConfigLoading && (
<div
className="text-description-muted px-2 py-1"
style={{ fontSize: fontSize(-3) }}
>
<code>{getMetaKeyLabel()}'</code> to toggle model
</div>
)}
</ListboxOptions>
</div>
</Listbox>

View file

@ -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 (
<StyledListbox value={selectedProvider} onChange={setSelectedProvider}>
<Listbox value={selectedProvider} onChange={setSelectedProvider}>
<div className="relative mb-2 mt-1">
<StyledListboxButton>
<ListboxButton className="bg-background border-border text-foreground hover:bg-input relative m-0 grid h-full w-full cursor-pointer grid-cols-[1fr_auto] items-center rounded-lg border border-solid py-2 pl-3 pr-10 text-left focus:outline-none">
<span className="flex items-center">
{window.vscMediaUrl && selectedProvider.icon && (
<img
@ -128,97 +42,103 @@ function ModelSelectionListbox({
</span>
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<ChevronUpDownIcon
className="h-5 w-5 text-gray-400"
className="text-description-muted h-5 w-5"
aria-hidden="true"
/>
</span>
</StyledListboxButton>
</ListboxButton>
<Transition
as={Fragment}
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<StyledListboxOptions>
<ListboxOptions className="bg-input rounded-default absolute left-0 top-full z-10 mt-1 h-fit w-3/5 overflow-y-auto p-0 focus:outline-none [&]:!max-h-[30vh]">
{topOptions.length > 0 && (
<div className="py-1">
<div className="text-description-muted px-3 py-1 text-xs font-medium uppercase tracking-wider">
Popular
</div>
{topOptions.map((option, index) => (
<StyledListboxOption
selected={selectedProvider.title === option.title}
<ListboxOption
key={index}
className="relative cursor-default select-none py-2 pr-4 text-gray-400"
className={({ selected }: { selected: boolean }) =>
` ${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" ? (
<CubeIcon className="mr-2 h-4 w-4 text-gray-400" />
) : (
window.vscMediaUrl &&
option.icon && (
<img
src={`${window.vscMediaUrl}/logos/${option.icon}`}
className="mr-1 h-4 w-4 object-contain object-center"
/>
)
)}
<span className="text-xs">{option.title}</span>
<div className="flex items-center">
{option.title === "Autodetect" ? (
<CubeIcon className="mr-2 h-4 w-4" />
) : (
window.vscMediaUrl &&
option.icon && (
<img
src={`${window.vscMediaUrl}/logos/${option.icon}`}
className="mr-2 h-4 w-4 object-contain object-center"
/>
)
)}
<span className="text-xs">{option.title}</span>
</div>
{selected && (
<span className="inset-y-0 ml-auto flex items-center pl-3">
<CheckIcon className="h-5 w-5" aria-hidden="true" />
</span>
<CheckIcon className="h-3 w-3" aria-hidden="true" />
)}
</>
)}
</StyledListboxOption>
</ListboxOption>
))}
</div>
)}
{topOptions.length > 0 && otherOptions.length > 0 && (
<div className="my-1 h-px bg-zinc-500" />
<div className="bg-border my-1 h-px min-h-px" />
)}
{otherOptions.length > 0 && (
<div className="py-1">
<div className="text-description-muted px-3 py-1 text-xs font-medium uppercase tracking-wider">
Additional providers
</div>
{otherOptions.map((option, index) => (
<StyledListboxOption
selected={selectedProvider.title === option.title}
<ListboxOption
key={index}
className="relative cursor-default select-none py-2 pr-4 text-gray-400"
className={({ selected }: { selected: boolean }) =>
` ${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" ? (
<CubeIcon className="mr-2 h-4 w-4 text-gray-400" />
) : (
window.vscMediaUrl &&
option.icon && (
<img
src={`${window.vscMediaUrl}/logos/${option.icon}`}
className="mr-1 h-4 w-4 object-contain object-center"
/>
)
)}
<span className="text-xs">{option.title}</span>
<div className="flex items-center">
{option.title === "Autodetect" ? (
<CubeIcon className="mr-2 h-4 w-4" />
) : (
window.vscMediaUrl &&
option.icon && (
<img
src={`${window.vscMediaUrl}/logos/${option.icon}`}
className="mr-2 h-4 w-4 object-contain object-center"
/>
)
)}
<span className="text-xs">{option.title}</span>
</div>
{selected && (
<span className="inset-y-0 ml-auto flex items-center pl-3">
<CheckIcon className="h-5 w-5" aria-hidden="true" />
</span>
<CheckIcon className="h-3 w-3" aria-hidden="true" />
)}
</>
)}
</StyledListboxOption>
</ListboxOption>
))}
</div>
)}
</StyledListboxOptions>
</ListboxOptions>
</Transition>
</div>
</StyledListbox>
</Listbox>
);
}

View file

@ -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 && (
<ExclamationTriangleIcon
data-tooltip-id={`${profile.id}-errors-tooltip`}
className="h-3 w-3 flex-shrink-0 cursor-pointer text-red-500"
className="text-error h-3 w-3 flex-shrink-0 cursor-pointer"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
@ -290,7 +289,7 @@ export default function AssistantSelect() {
<Transition>
<ListboxOptions className="pb-0">
<div className="flex gap-1.5 px-2.5 py-1">
<span>Assistants</span>
<span className="font-semibold">Assistants</span>
<div
className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125"
onClick={async (e) => {
@ -326,18 +325,11 @@ export default function AssistantSelect() {
</div>
<div className="flex flex-col">
<div
className="my-0 h-[0.5px]"
style={{
backgroundColor: vscCommandCenterInactiveBorder,
}}
/>
<div className="flex flex-row items-center">
<ListboxOption
className="w-full"
value={"new-assistant"}
fontSizeModifier={-2}
className="border-border w-full border-x-0 border-y border-solid"
onClick={session ? onNewAssistant : () => login(false)}
>
<div
@ -352,13 +344,6 @@ export default function AssistantSelect() {
</ListboxOption>
</div>
<div
className="my-0 h-[0.5px]"
style={{
backgroundColor: vscCommandCenterInactiveBorder,
}}
/>
<div
className="text-description flex items-center justify-between gap-1.5 px-2 py-1"
style={{

View file

@ -1,8 +1,7 @@
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
import { useContext, useEffect, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { Button, Input, InputSubtext, StyledActionButton } from "../components";
import AddModelButtonSubtext from "../components/AddModelButtonSubtext";
import { Button, Input, StyledActionButton } from "../components";
import Alert from "../components/gui/Alert";
import ModelSelectionListbox from "../components/modelSelection/ModelSelectionListbox";
import { useAuth } from "../context/Auth";
@ -16,7 +15,7 @@ import {
import { useAppDispatch } from "../redux/hooks";
import { updateSelectedModelByRole } from "../redux/thunks";
interface QuickModelSetupProps {
interface AddModelFormProps {
onDone: () => 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<ProviderInfo>(
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<string, any> = {};
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({
<form onSubmit={formMethods.handleSubmit(onSubmit)}>
<div className="mx-auto max-w-md p-6">
<h1 className="mb-0 text-center text-2xl">Add Chat model</h1>
{/* TODO sync free trial limit with hub */}
{/* {!hideFreeTrialLimitMessage && hasPassedFTL() && (
<p className="text-sm text-gray-400">
@ -166,7 +166,7 @@ function AddModelForm({
topOptions={popularProviders}
otherOptions={otherProviders}
/>
<InputSubtext className="mb-0">
<span className="text-description-muted mt-1 block text-xs">
Don't see your provider?{" "}
<a
className="cursor-pointer text-inherit underline hover:text-inherit"
@ -177,7 +177,7 @@ function AddModelForm({
Click here
</a>{" "}
to view the full list
</InputSubtext>
</span>
</div>
{selectedProvider.downloadUrl && (
@ -185,7 +185,6 @@ function AddModelForm({
<label className="mb-1 block text-sm font-medium">
Install provider
</label>
<StyledActionButton onClick={onClickDownloadProvider}>
<p className="text-sm underline">
{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({
<Input
id="apiKey"
className="w-full"
type="password"
placeholder={`Enter your ${selectedProvider.title} API key`}
{...formMethods.register("apiKey")}
/>
<InputSubtext className="mb-0">
<span className="text-description-muted mt-1 block text-xs">
<a
className="cursor-pointer text-inherit underline hover:text-inherit"
className="cursor-pointer text-inherit underline hover:text-inherit hover:brightness-125"
onClick={() => {
if (selectedProviderApiKeyUrl) {
ideMessenger.post(
@ -260,7 +260,7 @@ function AddModelForm({
Click here
</a>{" "}
to create a {selectedProvider.title} API key
</InputSubtext>
</span>
</>
</div>
)}
@ -276,7 +276,7 @@ function AddModelForm({
field.key !== "apiKey",
)
.map((field) => (
<div>
<div key={field.key}>
<>
<label className="mb-1 block text-sm font-medium">
{field.label}
@ -297,7 +297,20 @@ function AddModelForm({
<Button type="submit" className="w-full" disabled={isDisabled()}>
Connect
</Button>
<AddModelButtonSubtext />
<span className="text-description-muted block w-full text-center text-xs">
This will update your{" "}
<span
className="cursor-pointer underline hover:brightness-125"
onClick={() =>
ideMessenger.post("config/openProfile", {
profileId: undefined,
})
}
>
config file
</span>
</span>
</div>
</div>
</form>

1
gui/src/forms/index.ts Normal file
View file

@ -0,0 +1 @@
export * from "./AddModelForm";

View file

@ -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);
}}
/>

View file

@ -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<number | null>(null);
@ -65,102 +67,111 @@ const ModelRoleSelector = ({
return (
<>
<div className="mt-2 flex flex-row items-center gap-1 sm:mt-0">
<span
style={{
fontSize: fontSize(-3),
}}
>
{displayName}
</span>
<span style={{ fontSize: fontSize(-3) }}>{displayName}</span>
<InfoHover size="3" id={displayName} msg={description} />
<ToolTip id={`${displayName}-description`} place={"bottom"}>
{description}
</ToolTip>
</div>
<Listbox value={selectedModel?.title ?? null} onChange={handleSelect}>
<div className="relative">
<ListboxButton
disabled={models.length === 0}
className={`bg-vsc-editor-background hover:bg-list-active hover:text-list-active-foreground w-full justify-between`}
>
{models.length === 0 || noConfiguredModels ? (
<span className="text-lightgray line-clamp-1 italic">
{`No ${models.length === 0 ? "" : "valid "}${displayName} models${
["Chat", "Apply", "Edit"].includes(displayName)
? ". Using Chat model"
: ""
}`}
</span>
) : (
<span className="line-clamp-1">
{selectedModel?.title ?? `Select ${displayName} model`}
</span>
)}
{models.length ? (
<div className="pointer-events-none flex items-center">
<ChevronUpDownIcon className="h-3 w-3" aria-hidden="true" />
</div>
) : null}
</ListboxButton>
<Transition>
<ListboxOptions
style={{ borderRadius: defaultBorderRadius }}
className="min-w-40"
{models.length === 0 ? (
<ListboxButton
onClick={() => 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;
<span className="line-clamp-1" style={{ fontSize: fontSize(-3) }}>
Setup {displayName} model
</span>
</ListboxButton>
) : (
<>
<ListboxButton
disabled={models.length === 0}
className="bg-vsc-editor-background hover:bg-list-active hover:text-list-active-foreground w-full justify-between px-2 py-1"
>
{models.length === 0 || noConfiguredModels ? (
<span className="text-lightgray line-clamp-1 italic">
{`No ${models.length === 0 ? "" : "valid "}${displayName} models${
["Chat", "Apply", "Edit"].includes(displayName)
? ". Using Chat model"
: ""
}`}
</span>
) : (
<span className="line-clamp-1">
{selectedModel?.title ?? `Select ${displayName} model`}
</span>
)}
return (
<ListboxOption
key={idx}
value={option.title}
disabled={showMissingApiKeyMsg}
onMouseEnter={() => setHoveredIdx(idx)}
onMouseLeave={() => setHoveredIdx(null)}
onClick={(e: any) =>
handleOptionClick(showMissingApiKeyMsg, e)
}
className={""}
>
<div className="flex flex-col gap-0.5">
<div className="flex flex-1 flex-row items-center justify-between gap-2">
<div className="flex flex-1 flex-row items-center gap-2">
<CubeIcon className="h-3 w-3 flex-shrink-0" />
<span
className="line-clamp-1 flex-1"
style={{ fontSize: fontSize(-3) }}
>
{option.title}
{showMissingApiKeyMsg && (
<span className="ml-2 text-[10px] italic">
(Missing API key)
{models.length > 0 && (
<div className="pointer-events-none flex items-center">
<ChevronUpDownIcon className="h-3 w-3" aria-hidden="true" />
</div>
)}
</ListboxButton>
<Transition>
<ListboxOptions
style={{ borderRadius: defaultBorderRadius }}
className="min-w-40"
>
{[...models]
.sort((a, b) => a.title.localeCompare(b.title))
.map((option, idx) => {
const showMissingApiKeyMsg =
option.configurationStatus ===
LLMConfigurationStatuses.MISSING_API_KEY;
return (
<ListboxOption
key={idx}
value={option.title}
disabled={showMissingApiKeyMsg}
onMouseEnter={() => setHoveredIdx(idx)}
onMouseLeave={() => setHoveredIdx(null)}
onClick={(e: any) =>
handleOptionClick(showMissingApiKeyMsg, e)
}
className=""
>
<div className="flex flex-col gap-0.5">
<div className="flex flex-1 flex-row items-center justify-between gap-2">
<div className="flex flex-1 flex-row items-center gap-2">
<CubeIcon className="h-3 w-3 flex-shrink-0" />
<span
className="line-clamp-1 flex-1"
style={{ fontSize: fontSize(-3) }}
>
{option.title}
{showMissingApiKeyMsg && (
<span className="ml-2 text-[10px] italic">
(Missing API key)
</span>
)}
</span>
)}
</span>
</div>
<div className="flex flex-shrink-0 flex-row items-center gap-1">
{hoveredIdx === idx && (
<Cog6ToothIcon
className="h-3 w-3 flex-shrink-0"
onClick={onClickGear}
/>
)}
{option.title === selectedModel?.title && (
<CheckIcon className="h-3 w-3 flex-shrink-0" />
)}
</div>
</div>
</div>
<div className="flex flex-shrink-0 flex-row items-center gap-1">
{hoveredIdx === idx && (
<Cog6ToothIcon
className="h-3 w-3 flex-shrink-0"
onClick={onClickGear}
/>
)}
{option.title === selectedModel?.title && (
<CheckIcon className="h-3 w-3 flex-shrink-0" />
)}
</div>
</div>
</div>
</ListboxOption>
);
})}
</ListboxOptions>
</Transition>
</ListboxOption>
);
})}
</ListboxOptions>
</Transition>
</>
)}
</div>
</Listbox>
</>

View file

@ -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) {

View file

@ -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 (
<div className="mx-2 mt-6">
{true ? (
// For now we are excluding local onboarding options other than ollama
<PlatformOnboardingCard isDialog={false} />
) : (
<OnboardingCard isDialog={false} />
)}
<OnboardingCard />
</div>
);
}

View file

@ -8,7 +8,7 @@ export type ConfigState = {
config: BrowserSerializedContinueConfig;
};
const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
export const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
slashCommands: [
{
name: "share",

View file

@ -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<void>((resolve) => {
const interval = setInterval(() => {
attempts++;
if (findAndSelectProfile() || attempts >= maxAttempts) {
clearInterval(interval);
resolve();
}
}, 1000);
});
});