From 4a2254e25d5dd58d75571420772762eae4ef155b Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 8 Jun 2025 13:44:44 -0700 Subject: [PATCH] switch to the free trial assistant once logged in for the first time --- core/llm/utils/extractPathsFromCodeBlocks.ts | 2 -- .../OnboardingCard/platform/tabs/main.tsx | 8 ++++- gui/src/redux/thunks/index.ts | 1 + gui/src/redux/thunks/selectFirstHubProfile.ts | 33 +++++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 gui/src/redux/thunks/selectFirstHubProfile.ts diff --git a/core/llm/utils/extractPathsFromCodeBlocks.ts b/core/llm/utils/extractPathsFromCodeBlocks.ts index 00f723c7a..99f2764b2 100644 --- a/core/llm/utils/extractPathsFromCodeBlocks.ts +++ b/core/llm/utils/extractPathsFromCodeBlocks.ts @@ -2,8 +2,6 @@ * Extracts file paths from markdown code blocks */ export function extractPathsFromCodeBlocks(content: string): string[] { - console.log("CONTENT", content); - const paths: string[] = []; // Match code block opening patterns: diff --git a/gui/src/components/OnboardingCard/platform/tabs/main.tsx b/gui/src/components/OnboardingCard/platform/tabs/main.tsx index 9bad6a50f..31fad1c4e 100644 --- a/gui/src/components/OnboardingCard/platform/tabs/main.tsx +++ b/gui/src/components/OnboardingCard/platform/tabs/main.tsx @@ -4,7 +4,8 @@ import { ButtonSubtext } from "../../.."; import { useAuth } from "../../../../context/Auth"; import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import { selectCurrentOrg } from "../../../../redux"; -import { useAppSelector } from "../../../../redux/hooks"; +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"; @@ -20,12 +21,17 @@ export default function MainTab({ 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()); } }); } diff --git a/gui/src/redux/thunks/index.ts b/gui/src/redux/thunks/index.ts index 81c3e937c..43e35fd21 100644 --- a/gui/src/redux/thunks/index.ts +++ b/gui/src/redux/thunks/index.ts @@ -4,6 +4,7 @@ export * from "./cancelStream"; export * from "./edit"; export * from "./gatherContext"; export * from "./resetStateForNewMessage"; +export * from "./selectFirstHubProfile"; export * from "./streamNormalInput"; export * from "./streamResponse"; export * from "./streamResponseAfterToolCall"; diff --git a/gui/src/redux/thunks/selectFirstHubProfile.ts b/gui/src/redux/thunks/selectFirstHubProfile.ts new file mode 100644 index 000000000..f8018702c --- /dev/null +++ b/gui/src/redux/thunks/selectFirstHubProfile.ts @@ -0,0 +1,33 @@ +import { createAsyncThunk } from "@reduxjs/toolkit"; +import { setSelectedProfile } from "../slices"; +import { ThunkApiType } from "../store"; + +/** + * If there is a hub profile, select it. + * Used primarily after onboarding when a new profile is created and we + * want to switch to it immediately + */ +export const selectFirstHubProfile = createAsyncThunk< + void, + undefined, + ThunkApiType +>("selectFirstHubProfile", async (messages, { dispatch, extra, getState }) => { + const state = getState(); + + const currentOrgProfiles = state.profiles.organizations.find( + (org) => org.id === (state.profiles.selectedOrganizationId ?? "personal"), + ); + + const firstHubProfile = currentOrgProfiles?.profiles.find( + (profile) => profile.profileType === "platform", + ); + + if (!firstHubProfile) { + return; + } + + dispatch(setSelectedProfile(firstHubProfile.id)); + extra.ideMessenger.post("didChangeSelectedProfile", { + id: firstHubProfile.id, + }); +});