diff --git a/src/components/AIChatHistory/ListChatHistory.tsx b/src/components/AIChatHistory/ListChatHistory.tsx
index fc906b370..15cf500c9 100644
--- a/src/components/AIChatHistory/ListChatHistory.tsx
+++ b/src/components/AIChatHistory/ListChatHistory.tsx
@@ -113,25 +113,11 @@ export function ListChatHistory(props: ListChatHistoryProps) {
if (!isPaidUser) {
return (
-
-
{closeButton}
-
-
-
-
- Upgrade to Pro to keep your chat history.
-
-
-
-
+
);
}
@@ -224,3 +210,37 @@ export function ListChatHistory(props: ListChatHistoryProps) {
);
}
+
+type UpgradeToProMessageProps = {
+ className?: string;
+ onUpgrade?: () => void;
+ closeButton?: React.ReactNode;
+};
+
+export function UpgradeToProMessage(props: UpgradeToProMessageProps) {
+ const { className, onUpgrade, closeButton } = props;
+
+ return (
+
+ {closeButton && (
+
{closeButton}
+ )}
+
+
+
+
+ Upgrade to Pro to keep your chat history.
+
+
+
+
+ );
+}
diff --git a/src/components/FrameRenderer/RoadmapFloatingChat.tsx b/src/components/FrameRenderer/RoadmapFloatingChat.tsx
index 7ba1bff75..da3ba0d6c 100644
--- a/src/components/FrameRenderer/RoadmapFloatingChat.tsx
+++ b/src/components/FrameRenderer/RoadmapFloatingChat.tsx
@@ -412,6 +412,9 @@ export function RoadmapFloatingChat(props: RoadmapChatProps) {
onNewChat={() => {
setActiveChatHistoryId(undefined);
}}
+ onUpgrade={() => {
+ setShowUpgradeModal(true);
+ }}
/>
)}
diff --git a/src/components/RoadmapAIChatHistory/RoadmapAIChatHistory.tsx b/src/components/RoadmapAIChatHistory/RoadmapAIChatHistory.tsx
index b2713034f..9382ebd77 100644
--- a/src/components/RoadmapAIChatHistory/RoadmapAIChatHistory.tsx
+++ b/src/components/RoadmapAIChatHistory/RoadmapAIChatHistory.tsx
@@ -1,13 +1,15 @@
import { HistoryIcon, Loader2Icon, PlusIcon } from 'lucide-react';
import { Popover, PopoverContent, PopoverTrigger } from '../Popover';
import { useEffect, useMemo, useState } from 'react';
-import { useInfiniteQuery } from '@tanstack/react-query';
+import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
import { listChatHistoryOptions } from '../../queries/chat-history';
import { isLoggedIn } from '../../lib/jwt';
import { groupChatHistory } from '../../helper/grouping';
import { ChatHistoryGroup } from '../AIChatHistory/ChatHistoryGroup';
import { queryClient } from '../../stores/query-client';
import { SearchAIChatHistory } from '../AIChatHistory/SearchAIChatHistory';
+import { billingDetailsOptions } from '../../queries/billing';
+import { UpgradeToProMessage } from '../AIChatHistory/ListChatHistory';
type RoadmapAIChatHistoryProps = {
roadmapId: string;
@@ -15,6 +17,7 @@ type RoadmapAIChatHistoryProps = {
onChatHistoryClick: (id: string) => void;
onDelete?: (id: string) => void;
onNewChat?: () => void;
+ onUpgrade?: () => void;
};
export function RoadmapAIChatHistory(props: RoadmapAIChatHistoryProps) {
@@ -24,12 +27,16 @@ export function RoadmapAIChatHistory(props: RoadmapAIChatHistoryProps) {
onChatHistoryClick,
onDelete,
onNewChat,
+ onUpgrade,
} = props;
const [isOpen, setIsOpen] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [query, setQuery] = useState('');
+ const { data: userBillingDetails, isLoading: isBillingDetailsLoading } =
+ useQuery(billingDetailsOptions(), queryClient);
+ const isPaidUser = userBillingDetails?.status === 'active';
const {
data: chatHistory,
hasNextPage,
@@ -48,12 +55,12 @@ export function RoadmapAIChatHistory(props: RoadmapAIChatHistoryProps) {
);
useEffect(() => {
- if (!chatHistory) {
+ if (!chatHistory || isBillingDetailsLoading) {
return;
}
setIsLoading(false);
- }, [chatHistory]);
+ }, [chatHistory, isBillingDetailsLoading]);
const groupedChatHistory = useMemo(() => {
const allHistories = chatHistory?.pages?.flatMap((page) => page.data);
@@ -65,8 +72,9 @@ export function RoadmapAIChatHistory(props: RoadmapAIChatHistoryProps) {
return (
-
-
+
+
+ Chat History
)}
- {!isLoading && (
+
+ {!isLoading && !isPaidUser && (
+ {
+ setIsOpen(false);
+ onUpgrade?.();
+ }}
+ />
+ )}
+
+ {!isLoading && isPaidUser && (
<>