From 3535c157b79f65664b416207c9de07f9847fc0be Mon Sep 17 00:00:00 2001 From: Soumyadas15 Date: Fri, 6 Jun 2025 16:09:20 +0530 Subject: [PATCH 1/2] fix(lp): fix agent start on landing page --- .../components/home/sections/hero-section.tsx | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/home/sections/hero-section.tsx b/frontend/src/components/home/sections/hero-section.tsx index 1025834b..ce549411 100644 --- a/frontend/src/components/home/sections/hero-section.tsx +++ b/frontend/src/components/home/sections/hero-section.tsx @@ -13,9 +13,9 @@ import { createProject, createThread, addUserMessage, - startAgent, BillingError, } from '@/lib/api'; +import { useStartAgentMutation } from '@/hooks/react-query/threads/use-agent-run'; import { generateThreadName } from '@/lib/actions/threads'; import GoogleSignIn from '@/components/GoogleSignIn'; import { Input } from '@/components/ui/input'; @@ -59,6 +59,7 @@ export function HeroSection() { const { data: accounts } = useAccounts(); const personalAccount = accounts?.find((account) => account.personal_account); const { onOpen } = useModal(); + const startAgentMutation = useStartAgentMutation(); // Auth dialog state const [authDialogOpen, setAuthDialogOpen] = useState(false); @@ -123,20 +124,16 @@ export function HeroSection() { description: '', }); - // 2. Create a new thread for this project const thread = await createThread(newAgent.id); - - // 3. Add the user message to the thread await addUserMessage(thread.thread_id, inputValue.trim()); - - // 4. Start the agent with the thread ID - await startAgent(thread.thread_id, { - stream: true, + await startAgentMutation.mutateAsync({ + threadId: thread.thread_id, + options: { + model_name: 'openrouter/deepseek/deepseek-chat', + stream: true, + }, }); - - // 5. Navigate to the new agent's thread page - router.push(`/agents/${thread.thread_id}`); - // Clear input on success + router.push(`/projects/${newAgent.id}/thread/${thread.thread_id}`); setInputValue(''); } catch (error: any) { console.error('Error creating agent:', error); From 1fac5015f4227c8e21638507ef3070e0ad6c5e6c Mon Sep 17 00:00:00 2001 From: Soumyadas15 Date: Fri, 6 Jun 2025 16:10:02 +0530 Subject: [PATCH 2/2] fix(lp): fix agent start on landing page --- frontend/src/components/home/sections/hero-section.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frontend/src/components/home/sections/hero-section.tsx b/frontend/src/components/home/sections/hero-section.tsx index ce549411..f2ec8206 100644 --- a/frontend/src/components/home/sections/hero-section.tsx +++ b/frontend/src/components/home/sections/hero-section.tsx @@ -138,14 +138,9 @@ export function HeroSection() { } catch (error: any) { console.error('Error creating agent:', error); - // Check specifically for BillingError (402) if (error instanceof BillingError) { console.log('Handling BillingError from hero section:', error.detail); - // Open the payment required dialog modal instead of showing the alert - onOpen("paymentRequiredDialog"); - // Don't show toast for billing errors } else { - // Handle other errors (e.g., network, other API errors) const isConnectionError = error instanceof TypeError && error.message.includes('Failed to fetch');