fix(ui): functional start chat button in agent dialog

This commit is contained in:
Soumyadas15 2025-06-01 12:46:54 +05:30
parent b2a6361e2d
commit 4741e6bced
2 changed files with 13 additions and 2 deletions

View File

@ -185,7 +185,7 @@ export const AgentsGrid = ({
};
const handleChat = (agentId: string) => {
router.push(`/agents/new/${agentId}`);
router.push(`/dashboard?agent_id=${agentId}`);
setSelectedAgent(null);
};

View File

@ -2,7 +2,7 @@
import React, { useState, Suspense, useEffect, useRef } from 'react';
import { Skeleton } from '@/components/ui/skeleton';
import { useRouter } from 'next/navigation';
import { useRouter, useSearchParams } from 'next/navigation';
import { Menu } from 'lucide-react';
import {
ChatInput,
@ -40,6 +40,7 @@ function DashboardContent() {
const { billingError, handleBillingError, clearBillingError } =
useBillingError();
const router = useRouter();
const searchParams = useSearchParams();
const isMobile = useIsMobile();
const { setOpenMobile } = useSidebar();
const { data: accounts } = useAccounts();
@ -48,6 +49,16 @@ function DashboardContent() {
const initiateAgentMutation = useInitiateAgentWithInvalidation();
const { onOpen } = useModal();
useEffect(() => {
const agentIdFromUrl = searchParams.get('agent_id');
if (agentIdFromUrl && agentIdFromUrl !== selectedAgentId) {
setSelectedAgentId(agentIdFromUrl);
const newUrl = new URL(window.location.href);
newUrl.searchParams.delete('agent_id');
router.replace(newUrl.pathname + newUrl.search, { scroll: false });
}
}, [searchParams, selectedAgentId, router]);
const secondaryGradient =
'bg-gradient-to-r from-blue-500 to-blue-500 bg-clip-text text-transparent';