|
| 1 | +import { |
| 2 | + CheckBadgeIcon, |
| 3 | + GiftIcon, |
| 4 | + Cog6ToothIcon, |
| 5 | + ComputerDesktopIcon, |
| 6 | +} from "@heroicons/react/24/outline"; |
| 7 | +import { ToCoreFromIdeOrWebviewProtocol } from "core/protocol/core"; |
| 8 | +import { useContext, useState } from "react"; |
| 9 | +import { useNavigate } from "react-router-dom"; |
| 10 | +import GitHubSignInButton from "../../components/modelSelection/quickSetup/GitHubSignInButton"; |
| 11 | +import { IdeMessengerContext } from "../../context/IdeMessenger"; |
| 12 | +import { isJetBrains } from "../../util"; |
| 13 | +import { Div, StyledButton } from "./components"; |
| 14 | +import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../../util/freeTrial"; |
| 15 | +import { useOnboarding } from "./utils"; |
| 16 | + |
| 17 | +type OnboardingMode = |
| 18 | + ToCoreFromIdeOrWebviewProtocol["completeOnboarding"][0]["mode"]; |
| 19 | + |
| 20 | +function Onboarding() { |
| 21 | + const navigate = useNavigate(); |
| 22 | + const ideMessenger = useContext(IdeMessengerContext); |
| 23 | + |
| 24 | + const [hasSignedIntoGh, setHasSignedIntoGh] = useState(false); |
| 25 | + const [selectedOnboardingMode, setSlectedOnboardingMode] = useState< |
| 26 | + OnboardingMode | undefined |
| 27 | + >(undefined); |
| 28 | + |
| 29 | + const { completeOnboarding } = useOnboarding(); |
| 30 | + |
| 31 | + function onSubmit() { |
| 32 | + ideMessenger.post("completeOnboarding", { |
| 33 | + mode: selectedOnboardingMode, |
| 34 | + }); |
| 35 | + |
| 36 | + /** |
| 37 | + * "completeOnboarding" above will update the config with our |
| 38 | + * new embeddings provider. If it's not the default local provider, |
| 39 | + * we need to re-index the codebase. |
| 40 | + */ |
| 41 | + if (selectedOnboardingMode !== "local") { |
| 42 | + ideMessenger.post("index/forceReIndex", undefined); |
| 43 | + } |
| 44 | + |
| 45 | + switch (selectedOnboardingMode) { |
| 46 | + case "local": |
| 47 | + navigate("/localOnboarding"); |
| 48 | + break; |
| 49 | + |
| 50 | + case "apiKeys": |
| 51 | + navigate("/apiKeysOnboarding"); |
| 52 | + break; |
| 53 | + |
| 54 | + case "freeTrial": |
| 55 | + completeOnboarding(); |
| 56 | + break; |
| 57 | + |
| 58 | + default: |
| 59 | + break; |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + return ( |
| 64 | + <div className="max-w-96 mx-auto leading-normal"> |
| 65 | + <div className="leading-relaxed"> |
| 66 | + <h1 className="text-center">Welcome to Continue</h1> |
| 67 | + <p className="text-center "> |
| 68 | + Let's find the setup that works best for you. You can update your |
| 69 | + configuration after onboarding by clicking the |
| 70 | + <Cog6ToothIcon className="inline-block h-5 w-5 align-middle px-1" /> |
| 71 | + icon in the bottom-right corner of Continue. |
| 72 | + </p> |
| 73 | + </div> |
| 74 | + |
| 75 | + <div className="flex flex-col gap-6 pb-8 pt-4"> |
| 76 | + {(!hasPassedFTL() || isJetBrains()) && ( |
| 77 | + <Div |
| 78 | + selected={selectedOnboardingMode === "freeTrial"} |
| 79 | + onClick={() => setSlectedOnboardingMode("freeTrial")} |
| 80 | + > |
| 81 | + <h3> |
| 82 | + <GiftIcon |
| 83 | + width="1.4em" |
| 84 | + height="1.4em" |
| 85 | + className="align-middle pr-2" |
| 86 | + /> |
| 87 | + Free trial |
| 88 | + </h3> |
| 89 | + <p> |
| 90 | + Start your free trial of {FREE_TRIAL_LIMIT_REQUESTS} requests by |
| 91 | + signing into GitHub. |
| 92 | + </p> |
| 93 | + |
| 94 | + <ul className="pl-4 mb-0"> |
| 95 | + <li> |
| 96 | + <b>Chat:</b> Llama 3 with Ollama, LM Studio, etc. |
| 97 | + </li> |
| 98 | + <li> |
| 99 | + <b>Embeddings:</b> Nomic Embed |
| 100 | + </li> |
| 101 | + <li> |
| 102 | + <b>Autocomplete:</b> Starcoder2 3B |
| 103 | + </li> |
| 104 | + </ul> |
| 105 | + |
| 106 | + {!hasSignedIntoGh && ( |
| 107 | + <div className="flex justify-center py-3"> |
| 108 | + <GitHubSignInButton |
| 109 | + onComplete={() => setHasSignedIntoGh(true)} |
| 110 | + ></GitHubSignInButton> |
| 111 | + </div> |
| 112 | + )} |
| 113 | + </Div> |
| 114 | + )} |
| 115 | + <Div |
| 116 | + selected={selectedOnboardingMode === "local"} |
| 117 | + onClick={() => setSlectedOnboardingMode("local")} |
| 118 | + > |
| 119 | + <h3> |
| 120 | + <ComputerDesktopIcon |
| 121 | + width="1.4em" |
| 122 | + height="1.4em" |
| 123 | + className="align-middle pr-2" |
| 124 | + /> |
| 125 | + Local models |
| 126 | + </h3> |
| 127 | + <p> |
| 128 | + No code will leave your computer, but less powerful models are used. |
| 129 | + </p> |
| 130 | + |
| 131 | + <ul className="pl-4 "> |
| 132 | + <li> |
| 133 | + <b>Chat:</b> Llama 3 with Ollama, LM Studio, etc. |
| 134 | + </li> |
| 135 | + <li> |
| 136 | + <b>Embeddings:</b> Nomic Embed |
| 137 | + </li> |
| 138 | + <li> |
| 139 | + <b>Autocomplete:</b> Starcoder2 3B |
| 140 | + </li> |
| 141 | + </ul> |
| 142 | + </Div> |
| 143 | + |
| 144 | + <Div |
| 145 | + selected={selectedOnboardingMode === "apiKeys"} |
| 146 | + onClick={() => setSlectedOnboardingMode("apiKeys")} |
| 147 | + > |
| 148 | + <h3> |
| 149 | + <CheckBadgeIcon |
| 150 | + width="1.4em" |
| 151 | + height="1.4em" |
| 152 | + className="align-middle pr-2" |
| 153 | + /> |
| 154 | + Best experience |
| 155 | + </h3> |
| 156 | + <p> |
| 157 | + Start with the most powerful models available, or customize your own |
| 158 | + configuration. |
| 159 | + </p> |
| 160 | + |
| 161 | + <ul className="pl-4 "> |
| 162 | + <li> |
| 163 | + <b>Chat:</b> Claude 3.5 Sonnet |
| 164 | + </li> |
| 165 | + <li> |
| 166 | + <b>Embeddings:</b> Voyage Code 2 |
| 167 | + </li> |
| 168 | + <li> |
| 169 | + <b>Autocomplete:</b> Codestral |
| 170 | + </li> |
| 171 | + </ul> |
| 172 | + </Div> |
| 173 | + </div> |
| 174 | + |
| 175 | + <div className="flex justify-end"> |
| 176 | + <StyledButton disabled={!selectedOnboardingMode} onClick={onSubmit}> |
| 177 | + Continue |
| 178 | + </StyledButton> |
| 179 | + </div> |
| 180 | + </div> |
| 181 | + ); |
| 182 | +} |
| 183 | + |
| 184 | +export default Onboarding; |
0 commit comments