Merge branch 'pe/onboarding-refactor' of https://github.com/continuedev/continue into pe/onboarding-refactor
This commit is contained in:
commit
abdba0078f
19 changed files with 184 additions and 148 deletions
|
|
@ -14,12 +14,6 @@ export function setupBestConfig(
|
|||
return {
|
||||
...config,
|
||||
models: config.models.filter((model) => model.provider !== "free-trial"),
|
||||
embeddingsProvider: {
|
||||
provider: "free-trial",
|
||||
},
|
||||
reranker: {
|
||||
name: "free-trial",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -30,9 +24,9 @@ export function setupLocalConfig(
|
|||
...config,
|
||||
models: [
|
||||
{
|
||||
title: "Llama 3",
|
||||
title: "Llama 3.1 8B",
|
||||
provider: "ollama",
|
||||
model: "llama3",
|
||||
model: "llama3.1:8b",
|
||||
},
|
||||
{
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
|
|
@ -50,7 +44,6 @@ export function setupLocalConfig(
|
|||
provider: "ollama",
|
||||
model: "nomic-embed-text",
|
||||
},
|
||||
reranker: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -84,9 +77,9 @@ export function setupLocalConfigAfterFreeTrial(
|
|||
...config,
|
||||
models: [
|
||||
{
|
||||
title: "Llama 3",
|
||||
title: "Llama 3.1 8B",
|
||||
provider: "ollama",
|
||||
model: "llama3",
|
||||
model: "llama3.1:8b",
|
||||
},
|
||||
{
|
||||
title: ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
|
|
|
|||
|
|
@ -1,21 +1,8 @@
|
|||
# 👋 Welcome to Continue
|
||||
|
||||
## ❗️ Before you get started
|
||||
|
||||
Continue is currently in the left sidebar, but we recommend moving it to the right. This way it won't cover your file explorer.
|
||||
|
||||
You can move it back at any time. If you close the sidebar, it can be re-opened with <kbd>Cmd/Ctrl</kbd> + <kbd>L</kbd>.
|
||||
# Move Continue to the right sidebar
|
||||
|
||||

|
||||
|
||||
## 🔑 Most important shortcuts
|
||||
Continue is currently in the left sidebar, but we recommend moving it to the right.
|
||||
This way it won't cover your file explorer.
|
||||
|
||||
> If you'd prefer different keys, these shortcuts can be customized in VS Code settings.
|
||||
|
||||
<kbd>Cmd/Ctrl</kbd> + <kbd>L</kbd> = Select code
|
||||
|
||||
<kbd>Cmd/Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>L</kbd> = Select code for follow-up
|
||||
|
||||
<kbd>Cmd/Ctrl</kbd> + <kbd>I</kbd> = Quick edit
|
||||
|
||||
<kbd>Cmd/Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>R</kbd> = Automatically debug terminal
|
||||
You can move it back at any time. If you close the sidebar, it can be re-opened with <kbd>Cmd/Ctrl</kbd> + <kbd>L</kbd>.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
CONTINUE_WORKSPACE_KEY,
|
||||
getContinueWorkspaceConfig,
|
||||
} from "../util/workspaceConfig";
|
||||
import { ILLM } from "core";
|
||||
|
||||
export enum StatusBarStatus {
|
||||
Disabled,
|
||||
|
|
@ -134,3 +135,37 @@ export function monitorBatteryChanges(battery: Battery): vscode.Disposable {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getAutocompleteStatusBarDescription(
|
||||
selected: string | undefined,
|
||||
{ title, apiKey, providerName }: ILLM,
|
||||
): string | undefined {
|
||||
if (title !== selected) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let description = "Currently selected";
|
||||
|
||||
// Only set for Mistral since our default config includes Codestral without
|
||||
// an API key
|
||||
if ((apiKey === undefined || apiKey === "") && providerName === "mistral") {
|
||||
description += " (Missing API key)";
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
export function getAutocompleteStatusBarTitle(
|
||||
selected: string | undefined,
|
||||
{ title }: ILLM,
|
||||
): string {
|
||||
if (!title) {
|
||||
return "Unnamed Model";
|
||||
}
|
||||
|
||||
if (title === selected) {
|
||||
return `$(check) ${title}`;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import * as fs from "node:fs";
|
|||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
import { ContextMenuConfig, IDE } from "core";
|
||||
import { CompletionProvider } from "core/autocomplete/completionProvider";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
|
|
@ -16,6 +15,8 @@ import { Telemetry } from "core/util/posthog";
|
|||
import readLastLines from "read-last-lines";
|
||||
import {
|
||||
StatusBarStatus,
|
||||
getAutocompleteStatusBarDescription,
|
||||
getAutocompleteStatusBarTitle,
|
||||
getStatusBarStatus,
|
||||
getStatusBarStatusFromQuickPickItemLabel,
|
||||
quickPickStatusText,
|
||||
|
|
@ -635,16 +636,9 @@ const commandsMap: (
|
|||
kind: vscode.QuickPickItemKind.Separator,
|
||||
label: "Switch model",
|
||||
},
|
||||
...autocompleteModels.map(({ title, apiKey }) => ({
|
||||
label:
|
||||
title === selected ? `$(check) ${title}` : title || "Unnamed Model",
|
||||
description:
|
||||
title === selected
|
||||
? `Currently selected${
|
||||
(apiKey === undefined || apiKey === "") &&
|
||||
" (API key required)"
|
||||
}`
|
||||
: undefined,
|
||||
...autocompleteModels.map((model) => ({
|
||||
label: getAutocompleteStatusBarTitle(selected, model),
|
||||
description: getAutocompleteStatusBarDescription(selected, model),
|
||||
})),
|
||||
];
|
||||
quickPick.onDidAccept(() => {
|
||||
|
|
|
|||
|
|
@ -17,15 +17,11 @@ export default function ContinueLogo({
|
|||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<g
|
||||
className="origin-center animate-spin-slow"
|
||||
style={{ transformOrigin: "150px 150px" }}
|
||||
>
|
||||
<path
|
||||
d="M199.142 100.633L191.304 114.263L211.044 148.774C211.334 149.065 211.334 149.355 211.334 149.645C211.334 149.935 211.334 150.225 211.044 150.515L191.304 185.026L199.142 198.656L227.3 149.645L199.142 100.633ZM188.401 112.523L196.239 98.8928H180.563L172.725 112.523H188.401ZM172.435 116.003L190.723 147.904H206.399L188.111 116.003H172.435ZM188.401 182.996L206.689 151.095H191.014L172.725 182.996H188.401ZM172.435 186.766L180.273 200.396H195.949L188.111 186.766H172.435ZM119.311 203.586C119.021 203.586 118.73 203.586 118.44 203.296C118.15 203.006 117.859 203.006 117.859 202.716L97.8292 168.205H82.1533L110.312 217.217H166.919L159.081 203.586H119.311ZM161.984 201.846L169.822 215.477L177.66 201.846L169.822 188.216L161.984 201.846ZM166.919 186.476H130.052L122.214 200.106H158.791L166.919 186.476ZM127.149 184.736L108.86 152.835L101.022 166.465L119.311 198.366L127.149 184.736ZM82.1533 164.725H97.8292L105.667 151.095H89.9913L82.1533 164.725ZM117.569 96.5728C117.569 96.2827 117.859 95.9927 118.15 95.9927C118.44 95.9927 118.73 95.7027 119.021 95.7027H158.791L166.629 82.0723H110.312L82.1533 131.084H97.8292L117.569 96.5728ZM105.667 148.194L97.8292 134.564H82.1533L89.9913 148.194H105.667ZM119.021 100.923L100.732 132.824L108.57 146.454L126.859 114.553L119.021 100.923ZM159.081 99.1828H122.214L130.052 112.813H166.919L159.081 99.1828ZM169.822 111.073L177.66 97.4428L169.822 83.8123L161.984 97.4428L169.822 111.073Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
</g>
|
||||
<path
|
||||
d="M199.142 100.633L191.304 114.263L211.044 148.774C211.334 149.065 211.334 149.355 211.334 149.645C211.334 149.935 211.334 150.225 211.044 150.515L191.304 185.026L199.142 198.656L227.3 149.645L199.142 100.633ZM188.401 112.523L196.239 98.8928H180.563L172.725 112.523H188.401ZM172.435 116.003L190.723 147.904H206.399L188.111 116.003H172.435ZM188.401 182.996L206.689 151.095H191.014L172.725 182.996H188.401ZM172.435 186.766L180.273 200.396H195.949L188.111 186.766H172.435ZM119.311 203.586C119.021 203.586 118.73 203.586 118.44 203.296C118.15 203.006 117.859 203.006 117.859 202.716L97.8292 168.205H82.1533L110.312 217.217H166.919L159.081 203.586H119.311ZM161.984 201.846L169.822 215.477L177.66 201.846L169.822 188.216L161.984 201.846ZM166.919 186.476H130.052L122.214 200.106H158.791L166.919 186.476ZM127.149 184.736L108.86 152.835L101.022 166.465L119.311 198.366L127.149 184.736ZM82.1533 164.725H97.8292L105.667 151.095H89.9913L82.1533 164.725ZM117.569 96.5728C117.569 96.2827 117.859 95.9927 118.15 95.9927C118.44 95.9927 118.73 95.7027 119.021 95.7027H158.791L166.629 82.0723H110.312L82.1533 131.084H97.8292L117.569 96.5728ZM105.667 148.194L97.8292 134.564H82.1533L89.9913 148.194H105.667ZM119.021 100.923L100.732 132.824L108.57 146.454L126.859 114.553L119.021 100.923ZM159.081 99.1828H122.214L130.052 112.813H166.919L159.081 99.1828ZM169.822 111.073L177.66 97.4428L169.822 83.8123L161.984 97.4428L169.822 111.073Z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
|
||||
<path
|
||||
d="M512.369 123.254C501.918 123.254 493.5 128.184 487.984 136.884H486.533V126.154H473.76V203.587H486.533V158.345C486.533 144.715 497.854 134.854 510.917 134.854C523.981 134.854 532.109 144.425 532.109 157.475V203.877H544.882V157.475C544.592 137.754 532.109 123.254 512.369 123.254Z"
|
||||
fill={vscForeground}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import ProgressBar from "./loaders/ProgressBar";
|
|||
import PostHogPageView from "./PosthogPageView";
|
||||
import ProfileSwitcher from "./ProfileSwitcher";
|
||||
import { isNewUserOnboarding } from "./OnboardingCard/utils";
|
||||
import { useOnboardingCard } from "./OnboardingCard";
|
||||
|
||||
const FOOTER_HEIGHT = "1.8em";
|
||||
|
||||
|
|
@ -108,6 +109,7 @@ const Layout = () => {
|
|||
const location = useLocation();
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const onboardingCard = useOnboardingCard();
|
||||
|
||||
const dialogMessage = useSelector(
|
||||
(state: RootState) => state.uiState.dialogMessage,
|
||||
|
|
@ -188,8 +190,7 @@ const Layout = () => {
|
|||
useWebviewListener(
|
||||
"openOnboardingCard",
|
||||
async () => {
|
||||
navigate("/");
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: "Best" }));
|
||||
onboardingCard.open("Best");
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
|
@ -197,10 +198,9 @@ const Layout = () => {
|
|||
useWebviewListener(
|
||||
"setupLocalConfig",
|
||||
async () => {
|
||||
navigate("/");
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: "Local" }));
|
||||
onboardingCard.open("Local");
|
||||
},
|
||||
[navigate],
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -208,7 +208,7 @@ const Layout = () => {
|
|||
isNewUserOnboarding() &&
|
||||
(location.pathname === "/" || location.pathname === "/index.html")
|
||||
) {
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: "Quickstart" }));
|
||||
onboardingCard.open("Quickstart");
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,10 @@
|
|||
import { useState } from "react";
|
||||
import * as Tabs from "./tabs";
|
||||
import OnboardingCardTabs, { TabTitle } from "./components/OnboardingCardTabs";
|
||||
import { XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
CloseButton,
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscInputBackground,
|
||||
} from "../";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setOnboardingCard } from "../../redux/slices/uiStateSlice";
|
||||
import { CloseButton, defaultBorderRadius, vscInputBackground } from "../";
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { useOnboardingCard } from "./hooks/useOnboardingCard";
|
||||
|
||||
const StyledCard = styled.div`
|
||||
margin: auto;
|
||||
|
|
@ -35,22 +28,10 @@ export const defaultOnboardingCardState: OnboardingCardState = {
|
|||
export type OnboardingCardProps = Pick<OnboardingCardState, "activeTab">;
|
||||
|
||||
function OnboardingCard(props: OnboardingCardProps) {
|
||||
const dispatch = useDispatch();
|
||||
const [activeTab, setActiveTab] = useState<TabTitle>(
|
||||
props.activeTab ?? "Best",
|
||||
);
|
||||
|
||||
function handleTabClick(tabName) {
|
||||
setActiveTab(tabName);
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
setLocalStorage("hasDismissedOnboardingCard", true);
|
||||
dispatch(setOnboardingCard({ show: false }));
|
||||
}
|
||||
const onboardingCard = useOnboardingCard();
|
||||
|
||||
function renderTabContent() {
|
||||
switch (activeTab) {
|
||||
switch (onboardingCard.activeTab) {
|
||||
case "Quickstart":
|
||||
return <Tabs.Quickstart />;
|
||||
case "Best":
|
||||
|
|
@ -68,8 +49,11 @@ function OnboardingCard(props: OnboardingCardProps) {
|
|||
|
||||
return (
|
||||
<StyledCard className="relative">
|
||||
<OnboardingCardTabs activeTab={activeTab} onTabClick={handleTabClick} />
|
||||
<CloseButton onClick={handleClose}>
|
||||
<OnboardingCardTabs
|
||||
activeTab={onboardingCard.activeTab}
|
||||
onTabClick={onboardingCard.setActiveTab}
|
||||
/>
|
||||
<CloseButton onClick={onboardingCard.close}>
|
||||
<XMarkIcon className="h-5 w-5" />
|
||||
</CloseButton>
|
||||
<div className="content py-4">{renderTabContent()}</div>
|
||||
|
|
|
|||
|
|
@ -1,28 +1,37 @@
|
|||
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useState } from "react";
|
||||
import { StyledActionButton, Input, Button, ButtonSubtext } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { QuickstartSubmitButtonProps } from "../OnboardingCard/components/QuickStartSubmitButton";
|
||||
import { StyledActionButton, Input, Button, ButtonSubtext } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { setShowDialog } from "../../../redux/slices/uiStateSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
interface JetBrainsFetchGitHubTokenDialogProps {
|
||||
onComplete: () => void;
|
||||
}
|
||||
|
||||
const GITHUB_AUTH_URL =
|
||||
"https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20";
|
||||
|
||||
function JetBrainsFetchGitHubTokenDialog({
|
||||
onComplete,
|
||||
}: QuickstartSubmitButtonProps) {
|
||||
}: JetBrainsFetchGitHubTokenDialogProps) {
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [jbGhAuthToken, setJbGhAuthToken] = useState("");
|
||||
const [hasClickedGitHubButton, setHasClickedGitHubButton] = useState(false);
|
||||
|
||||
const submitJetBrainsToken = async () => {
|
||||
await ideMessenger.request("setGitHubAuthToken", { token: jbGhAuthToken });
|
||||
onComplete(jbGhAuthToken);
|
||||
};
|
||||
async function submitJetBrainsToken() {
|
||||
await ideMessenger.request("setGitHubAuthToken", {
|
||||
token: jbGhAuthToken,
|
||||
});
|
||||
dispatch(setShowDialog(false));
|
||||
onComplete();
|
||||
}
|
||||
|
||||
const openGitHubTokenPage = () => {
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20",
|
||||
);
|
||||
function openGitHubTokenPage() {
|
||||
ideMessenger.post("openUrl", GITHUB_AUTH_URL);
|
||||
setHasClickedGitHubButton(true);
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="p-8 flex flex-col gap-3">
|
||||
|
|
@ -2,7 +2,6 @@ import {
|
|||
ArrowPathIcon,
|
||||
ArrowTopRightOnSquareIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { CheckCircleIcon } from "@heroicons/react/24/solid";
|
||||
import { useState, useContext } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { providers } from "../../../pages/AddNewModel/configs/providers";
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import {
|
|||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../../redux/slices/uiStateSlice";
|
||||
import JetBrainsFetchGitHubTokenDialog from "../../dialogs/JetBrainsFetchGitHubTokenDialog";
|
||||
import JetBrainsFetchGitHubTokenDialog from "./JetBrainsFetchGitHubTokenDialog";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
|
||||
function QuickstartSubmitButton() {
|
||||
|
|
@ -17,7 +17,7 @@ function QuickstartSubmitButton() {
|
|||
|
||||
const { submitOnboarding } = useSubmitOnboarding("Quickstart");
|
||||
|
||||
function handleTokenAcquisition(token: string) {
|
||||
function onComplete() {
|
||||
setLocalStorage("signedInToGh", true);
|
||||
submitOnboarding();
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ function QuickstartSubmitButton() {
|
|||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<JetBrainsFetchGitHubTokenDialog onComplete={handleTokenAcquisition} />,
|
||||
<JetBrainsFetchGitHubTokenDialog onComplete={onComplete} />,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ function QuickstartSubmitButton() {
|
|||
async function fetchGitHubAuthToken() {
|
||||
const result = await ideMessenger.request("getGitHubAuthToken", undefined);
|
||||
if (result.status === "success") {
|
||||
handleTokenAcquisition(result.content);
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
67
gui/src/components/OnboardingCard/hooks/useOnboardingCard.ts
Normal file
67
gui/src/components/OnboardingCard/hooks/useOnboardingCard.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { TabTitle } from "../components/OnboardingCardTabs";
|
||||
import useHistory from "../../../hooks/useHistory";
|
||||
import { setOnboardingCard } from "../../../redux/slices/uiStateSlice";
|
||||
import { OnboardingCardState } from "..";
|
||||
import { RootState } from "../../../redux/store";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
|
||||
export interface UseOnboardingCard {
|
||||
show: OnboardingCardState["show"];
|
||||
activeTab: OnboardingCardState["activeTab"];
|
||||
setActiveTab: (tab: TabTitle) => void;
|
||||
open: (tab: TabTitle) => void;
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
export function useOnboardingCard(): UseOnboardingCard {
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const { saveSession } = useHistory(dispatch);
|
||||
|
||||
const onboardingCard = useSelector(
|
||||
(state: RootState) => state.uiState.onboardingCard,
|
||||
);
|
||||
|
||||
const onboardingStatus = getLocalStorage("onboardingStatus");
|
||||
const hasDismissedOnboardingCard = getLocalStorage(
|
||||
"hasDismissedOnboardingCard",
|
||||
);
|
||||
|
||||
let show: boolean;
|
||||
|
||||
// Always show if we explicitly want to, e.g. passing free trial
|
||||
// and setting up keys
|
||||
if (onboardingCard.show) {
|
||||
show = true;
|
||||
} else {
|
||||
show = onboardingStatus !== "Completed" && !hasDismissedOnboardingCard;
|
||||
}
|
||||
|
||||
function open(tab: TabTitle) {
|
||||
navigate("/");
|
||||
|
||||
// Used to clear the chat panel before showing onboarding card
|
||||
saveSession();
|
||||
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: tab }));
|
||||
}
|
||||
|
||||
function close() {
|
||||
setLocalStorage("hasDismissedOnboardingCard", true);
|
||||
dispatch(setOnboardingCard({ show: false }));
|
||||
}
|
||||
|
||||
function setActiveTab(tab: TabTitle) {
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: tab }));
|
||||
}
|
||||
|
||||
return {
|
||||
show,
|
||||
setActiveTab,
|
||||
open,
|
||||
close,
|
||||
activeTab: onboardingCard.activeTab,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,24 +1,22 @@
|
|||
import { usePostHog } from "posthog-js/react";
|
||||
import { useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { setOnboardingCard } from "../../../redux/slices/uiStateSlice";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
import { OnboardingModes } from "core/protocol/core";
|
||||
import { useTutorialCard } from "../../../hooks/useTutorialCard";
|
||||
import { useOnboardingCard } from "./useOnboardingCard";
|
||||
|
||||
export function useSubmitOnboarding(mode: OnboardingModes) {
|
||||
const posthog = usePostHog();
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { openTutorialCard } = useTutorialCard();
|
||||
const { close: closeOnboardingCard } = useOnboardingCard();
|
||||
|
||||
function submitOnboarding() {
|
||||
debugger;
|
||||
const onboardingStatus = getLocalStorage("onboardingStatus");
|
||||
|
||||
// Always close the onboarding card and update config.json
|
||||
dispatch(setOnboardingCard({ show: false }));
|
||||
closeOnboardingCard();
|
||||
ideMessenger.post("completeOnboarding", {
|
||||
mode,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
export * from "./OnboardingCard";
|
||||
export { default } from "./OnboardingCard";
|
||||
export * from "./utils";
|
||||
export * from "./hooks/useOnboardingCard";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootState } from "../../redux/store";
|
||||
import { OnboardingCardState } from "./OnboardingCard";
|
||||
|
||||
// Note that there is no "NotStarted" status since the
|
||||
// local storage value is null until onboarding begins
|
||||
|
|
@ -9,8 +6,6 @@ export type OnboardingStatus = "Started" | "Completed";
|
|||
|
||||
// If there is no value in local storage for "onboardingStatus",
|
||||
// it implies that the user has not begun or completed onboarding.
|
||||
|
||||
// TODO: Is this still valid
|
||||
export function isNewUserOnboarding() {
|
||||
// We used to use "onboardingComplete", but switched to "onboardingStatus"
|
||||
const onboardingCompleteLegacyValue =
|
||||
|
|
@ -25,26 +20,3 @@ export function isNewUserOnboarding() {
|
|||
|
||||
return onboardingStatus === undefined;
|
||||
}
|
||||
|
||||
export function useOnboardingCard(): OnboardingCardState {
|
||||
const onboardingStatus = getLocalStorage("onboardingStatus");
|
||||
const hasDismissedOnboardingCard = getLocalStorage(
|
||||
"hasDismissedOnboardingCard",
|
||||
);
|
||||
|
||||
const onboardingCard = useSelector(
|
||||
(state: RootState) => state.uiState.onboardingCard,
|
||||
);
|
||||
|
||||
let show: boolean;
|
||||
|
||||
// Always show if we explicitly want to, e.g. passing free trial
|
||||
// and setting up keys
|
||||
if (onboardingCard.show) {
|
||||
show = true;
|
||||
} else {
|
||||
show = onboardingStatus !== "Completed" && !hasDismissedOnboardingCard;
|
||||
}
|
||||
|
||||
return { show, activeTab: onboardingCard.activeTab };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { Button, Input } from "..";
|
|||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
import { setShowDialog } from "../../redux/slices/uiStateSlice";
|
||||
import { useOnboardingCard } from "../OnboardingCard";
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
|
|
@ -18,9 +19,15 @@ function SetupLocalOrKeyDialog() {
|
|||
const navigate = useNavigate();
|
||||
const [apiKey, setApiKey] = React.useState("");
|
||||
const dispatch = useDispatch();
|
||||
const onboardingCard = useOnboardingCard();
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
function onClickLocal() {
|
||||
dispatch(setShowDialog(false));
|
||||
onboardingCard.open("Local");
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<h3>Set up your own model</h3>
|
||||
|
|
@ -60,17 +67,7 @@ function SetupLocalOrKeyDialog() {
|
|||
</Button>
|
||||
<div className="text-center">— OR —</div>
|
||||
<GridDiv>
|
||||
<Button
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
ideMessenger.request("completeOnboarding", {
|
||||
mode: "localAfterFreeTrial",
|
||||
});
|
||||
navigate("/localOnboarding");
|
||||
}}
|
||||
>
|
||||
Use local model
|
||||
</Button>
|
||||
<Button onClick={onClickLocal}>Use local model</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ function ModelOption({
|
|||
<CubeIcon className="w-4 h-4 mr-2 flex-shrink-0" />
|
||||
<span className="flex-grow">{option.title}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 ml-2">
|
||||
<div className="flex items-center ml-2">
|
||||
<StyledCog6ToothIcon hovered={hovered} onClick={onClickGear} />
|
||||
{showDelete && (
|
||||
<StyledTrashIcon hovered={hovered} onClick={onClickDelete} />
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import {
|
|||
} from "react";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
Button,
|
||||
|
|
@ -57,10 +56,11 @@ import {
|
|||
isMetaEquivalentKeyPressed,
|
||||
} from "../util";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import OnboardingCard from "../components/OnboardingCard";
|
||||
import { useOnboardingCard } from "../components/OnboardingCard/utils";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial";
|
||||
import { useTutorialCard } from "../hooks/useTutorialCard";
|
||||
import OnboardingCard, {
|
||||
useOnboardingCard,
|
||||
} from "../components/OnboardingCard";
|
||||
|
||||
const TopGuiDiv = styled.div<{
|
||||
showScrollbar?: boolean;
|
||||
|
|
@ -219,7 +219,7 @@ function GUI() {
|
|||
setLocalStorage("ftc", u + 1);
|
||||
|
||||
if (u >= FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: "Best" }));
|
||||
onboardingCard.open("Best");
|
||||
posthog?.capture("ftc_reached");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { useNavigationListener } from "../hooks/useNavigationListener";
|
|||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setOnboardingCard } from "../redux/slices/uiStateSlice";
|
||||
import useHistory from "../hooks/useHistory";
|
||||
|
||||
interface MoreActionRowProps {
|
||||
title: string;
|
||||
|
|
@ -55,6 +56,7 @@ function MorePage() {
|
|||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { saveSession } = useHistory(dispatch);
|
||||
|
||||
const [indexingState, setIndexingState] = useState<IndexingProgressUpdate>({
|
||||
desc: "Loading indexing config",
|
||||
|
|
@ -117,6 +119,8 @@ function MorePage() {
|
|||
buttonText="Open quickstart"
|
||||
onClick={() => {
|
||||
navigate("/");
|
||||
// Used to clear the chat panel before showing onboarding card
|
||||
saveSession();
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: "Best" }));
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export function getFontSize(): number {
|
|||
}
|
||||
|
||||
export function isJetBrains() {
|
||||
return getLocalStorage("ide") === "jetbrains";
|
||||
return getLocalStorage("ide") !== "jetbrains";
|
||||
}
|
||||
|
||||
export function isWebEnvironment(): boolean {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue