dialog onboarding
This commit is contained in:
parent
79213304c1
commit
498a43fb79
6 changed files with 41 additions and 7 deletions
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.253",
|
||||
"version": "0.9.252",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.253",
|
||||
"version": "0.9.252",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {
|
|||
ArrowPathIcon,
|
||||
ArrowTopRightOnSquareIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState, useContext } from "react";
|
||||
import { useState, useContext, useEffect } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { providers } from "../../../pages/AddNewModel/configs/providers";
|
||||
import { StyledActionButton } from "../..";
|
||||
|
|
@ -19,10 +19,15 @@ export function OllamaStatus({ isOllamaConnected }: OllamaStatusProps) {
|
|||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [status, setStatus] = useState<OllamaConnectionStatuses>(
|
||||
isOllamaConnected
|
||||
? OllamaConnectionStatuses.Connected
|
||||
: OllamaConnectionStatuses.WaitingToDownload,
|
||||
OllamaConnectionStatuses.WaitingToDownload,
|
||||
);
|
||||
useEffect(() => {
|
||||
if (isOllamaConnected) {
|
||||
setStatus(OllamaConnectionStatuses.Connected);
|
||||
} else if (status !== OllamaConnectionStatuses.Downloading) {
|
||||
setStatus(OllamaConnectionStatuses.WaitingToDownload);
|
||||
}
|
||||
}, [status, isOllamaConnected]);
|
||||
|
||||
function onClickDownload() {
|
||||
ideMessenger.post("openUrl", downloadUrl);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import { TabTitle } from "../components/OnboardingCardTabs";
|
|||
import { useOnboardingCard } from "../hooks";
|
||||
import OnboardingLocalTab from "../tabs/OnboardingLocalTab";
|
||||
import MainTab from "./tabs/main";
|
||||
import { hasPassedFTL } from "../../../util/freeTrial";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
|
||||
const StyledCard = styled.div`
|
||||
margin: auto;
|
||||
|
|
@ -30,8 +32,18 @@ export function PlatformOnboardingCard() {
|
|||
setLocalStorage("onboardingStatus", "Started");
|
||||
}
|
||||
|
||||
const isPastFreeTrialLimit = hasPassedFTL();
|
||||
const isShowingDialog = useAppSelector((store) => store.ui.showDialog);
|
||||
|
||||
const [currentTab, setCurrentTab] = useState<"main" | "local">("main");
|
||||
|
||||
// A version of this pops up in a dialog
|
||||
// so that history doesn't disappear or jump
|
||||
// If free trial limit is reached mid-chat
|
||||
if (isPastFreeTrialLimit && isShowingDialog) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledCard className="xs:py-4 xs:px-4 relative px-2 py-3">
|
||||
<CloseButton onClick={onboardingCard.close}>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import { useDispatch } from "react-redux";
|
|||
import styled from "styled-components";
|
||||
import { Button, SecondaryButton } from "..";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface FreeTrialOverDialogProps {
|
||||
onConfirm: () => void;
|
||||
|
|
@ -14,6 +16,14 @@ interface FreeTrialOverDialogProps {
|
|||
|
||||
function FreeTrialOverDialog(props: FreeTrialOverDialogProps) {
|
||||
const dispatch = useDispatch();
|
||||
const history = useAppSelector((store) => store.session.history);
|
||||
|
||||
useEffect(() => {
|
||||
if (history.length === 0) {
|
||||
dispatch(setShowDialog(false));
|
||||
dispatch(setDialogMessage(undefined));
|
||||
}
|
||||
}, [history]);
|
||||
|
||||
return (
|
||||
<div className="p-4 pt-0">
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ const TextDialog = (props: TextDialogProps) => {
|
|||
>
|
||||
<Dialog>
|
||||
<CloseButton onClick={props.onClose}>
|
||||
<XMarkIcon className="h-5 w-5 hover:brightness-125" />
|
||||
<XMarkIcon className="z-50 h-5 w-5 hover:brightness-125" />
|
||||
</CloseButton>
|
||||
|
||||
{typeof props.message === "string" ? (
|
||||
|
|
|
|||
|
|
@ -247,12 +247,18 @@ export function Chat() {
|
|||
editorToClearOnSend?: Editor,
|
||||
) => {
|
||||
if (defaultModel?.provider === "free-trial") {
|
||||
dispatch(setDialogMessage(<PlatformOnboardingCard />));
|
||||
dispatch(setShowDialog(true));
|
||||
return;
|
||||
const u = getLocalStorage("ftc") ?? 0;
|
||||
setLocalStorage("ftc", u + 1);
|
||||
if (u === FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
posthog?.capture("ftc_reached");
|
||||
}
|
||||
if (u >= FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
if (usePlatform) {
|
||||
} else {
|
||||
}
|
||||
onboardingCard.open("Best");
|
||||
ideMessenger.ide.showToast(
|
||||
"info",
|
||||
|
|
@ -298,6 +304,7 @@ export function Chat() {
|
|||
streamResponse,
|
||||
isSingleRangeEditOrInsertion,
|
||||
codeToEdit,
|
||||
usePlatform,
|
||||
],
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue