From 9414b23b684f04b2cd0859fe84a7a53c0cfc0d71 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Thu, 12 Jun 2025 00:34:11 +0600 Subject: [PATCH] feat: show chat history always --- src/components/AIChat/AIChat.tsx | 18 ++--- .../AIChatHistory/AIChatHistory.tsx | 25 +++++-- .../AIChatHistory/ListChatHistory.tsx | 71 ++++++++++++++----- 3 files changed, 79 insertions(+), 35 deletions(-) diff --git a/src/components/AIChat/AIChat.tsx b/src/components/AIChat/AIChat.tsx index 440ab2384..83551f9a3 100644 --- a/src/components/AIChat/AIChat.tsx +++ b/src/components/AIChat/AIChat.tsx @@ -30,10 +30,9 @@ import { type MessagePartRenderer, } from '../../lib/render-chat-message'; import { RoadmapRecommendations } from '../RoadmapAIChat/RoadmapRecommendations'; -import type { RoadmapAIChatHistoryType } from '../RoadmapAIChat/RoadmapAIChat'; +import type { RoadmapAIChatHistoryType } from '../../hooks/use-roadmap-ai-chat'; import { AIChatCourse } from './AIChatCouse'; import { showLoginPopup } from '../../lib/popup'; -import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal'; import { readChatStream } from '../../lib/chat'; import { chatHistoryOptions } from '../../queries/chat-history'; import { cn } from '../../lib/classname'; @@ -51,6 +50,7 @@ type AIChatProps = { messages?: RoadmapAIChatHistoryType[]; chatHistoryId?: string; setChatHistoryId?: (chatHistoryId: string) => void; + onUpgrade?: () => void; }; export function AIChat(props: AIChatProps) { @@ -58,6 +58,7 @@ export function AIChat(props: AIChatProps) { messages: defaultMessages, chatHistoryId: defaultChatHistoryId, setChatHistoryId: setDefaultChatHistoryId, + onUpgrade, } = props; const toast = useToast(); @@ -70,7 +71,6 @@ export function AIChat(props: AIChatProps) { RoadmapAIChatHistoryType[] >(defaultMessages ?? []); - const [showUpgradeModal, setShowUpgradeModal] = useState(false); const [isPersonalizedResponseFormOpen, setIsPersonalizedResponseFormOpen] = useState(false); const [isUploadResumeModalOpen, setIsUploadResumeModalOpen] = useState(false); @@ -128,7 +128,7 @@ export function AIChat(props: AIChatProps) { if (isLimitExceeded) { if (!isPaidUser) { - setShowUpgradeModal(true); + onUpgrade?.(); } toast.error('Limit reached for today. Please wait until tomorrow.'); @@ -343,7 +343,7 @@ export function AIChat(props: AIChatProps) { (index: number) => { if (isLimitExceeded) { if (!isPaidUser) { - setShowUpgradeModal(true); + onUpgrade?.(); } toast.error('Limit reached for today. Please wait until tomorrow.'); @@ -430,10 +430,6 @@ export function AIChat(props: AIChatProps) { /> )} - {showUpgradeModal && ( - setShowUpgradeModal(false)} /> - )} -
+ ); + + if (!isPaidUser) { + return ( +
+
{closeButton}
+ +
+ +

+ Upgrade to Pro to keep your chat history. +

+ +
+
+ ); + } + + return ( +
{isLoading && } {!isLoading && isError && } @@ -138,18 +182,11 @@ export function ListChatHistory(props: ListChatHistoryProps) {

Chat History

- + {closeButton}