33import React , { useEffect , useState } from "react" ;
44import { motion , AnimatePresence } from "framer-motion" ;
55import dynamic from "next/dynamic" ;
6- import { Loader2 , ExternalLink , Cpu , MessageSquare , Play } from "lucide-react" ;
6+ import { Loader2 , ExternalLink , Cpu , MessageSquare } from "lucide-react" ;
77import { Button } from "@/components/ui/button" ;
88import { Role , TextMessage } from "@copilotkit/runtime-client-gql" ;
99import ChatInterface from "@/components/ChatInterface" ;
@@ -17,6 +17,7 @@ import GitHubStarButtons from "@/components/StarComponent";
1717import Image from "next/image" ;
1818import { CopilotSidebar } from "@copilotkit/react-ui" ;
1919import "@copilotkit/react-ui/styles.css" ;
20+ import VideoSection from "@/components/VideoSection" ;
2021
2122interface AgentState {
2223 question : string ;
@@ -183,13 +184,12 @@ const DSASolutionInterface = () => {
183184 timeComplexity,
184185 spaceComplexity,
185186 } ;
186-
187- // Only update if the state has actually changed
187+
188188 if ( ! isStateEqual ( state , newState ) ) {
189189 setState ( ( prevState = state ) => ( {
190190 ...prevState ,
191191 ...newState ,
192- // Preserve other fields that aren't being updated
192+
193193 code : prevState . code ,
194194 explanation : prevState . explanation ,
195195 visualization : prevState . visualization ,
@@ -205,7 +205,6 @@ const DSASolutionInterface = () => {
205205
206206 setShowChat ( true ) ;
207207
208- // First, send the problem context
209208 const contextMessage = new TextMessage ( {
210209 id : "context-" + Date . now ( ) . toString ( ) ,
211210 role : Role . System ,
@@ -218,14 +217,14 @@ const DSASolutionInterface = () => {
218217 ` ,
219218 } ) ;
220219
221- // Then send the user's question
220+
222221 const userMessage = new TextMessage ( {
223222 id : "user-" + Date . now ( ) . toString ( ) ,
224223 role : Role . User ,
225224 content : question ,
226225 } ) ;
227226
228- // Send messages with a slight delay
227+
229228 setTimeout ( ( ) => {
230229 appendMessage ( contextMessage ) ;
231230 setTimeout ( ( ) => {
@@ -236,27 +235,23 @@ const DSASolutionInterface = () => {
236235
237236 const handleSolutionUpdate = ( content : string ) => {
238237 try {
239- // Extract code block
238+
240239 const codeMatch = content . match ( / ` ` ` p y t h o n \n ( [ \s \S ] * ?) ` ` ` / ) ;
241240 const code = codeMatch ? codeMatch [ 1 ] . trim ( ) : "" ;
242241
243- // Extract explanation (text before code block)
242+
244243 const explanation = content . split ( "```" ) [ 0 ] . trim ( ) ;
245244
246- // Extract complexities
247245 const timeMatch = content . match ( / [ T t ] i m e [ C c ] o m p l e x i t y : ? \s * ( O \( [ ^ ) ] + \) ) / ) ;
248246 const spaceMatch = content . match (
249247 / [ S s ] p a c e [ C c ] o m p l e x i t y : ? \s * ( O \( [ ^ ) ] + \) ) /
250248 ) ;
251249
252- // // Extract visualization if present
253- // const visualMatch = content.match(/```mermaid\n([\s\S]*?)```/);
254250
255- // Update all states
256251 setSolution ( prevSolution => ( {
257252 code : code ,
258253 explanation : explanation ,
259- visualization : prevSolution ?. visualization // Preserve existing visualization
254+ visualization : prevSolution ?. visualization
260255 } ) ) ;
261256
262257 if ( timeMatch ) setTimeComplexity ( timeMatch [ 1 ] ) ;
@@ -288,19 +283,6 @@ const DSASolutionInterface = () => {
288283 } , [ visibleMessages ] ) ;
289284
290285
291- const [ isPlaying , setIsPlaying ] = useState ( false ) ;
292- const videoUrl = "https://vimeo.com/1044157863" ;
293-
294- const getVimeoEmbedUrl = ( url : string ) => {
295- const videoId = url . split ( "vimeo.com/" ) [ 1 ] ;
296- return `https://player.vimeo.com/video/${ videoId } ` ;
297- } ;
298-
299- const embedUrl = getVimeoEmbedUrl ( videoUrl ) ;
300- const handlePlayClick = ( ) => {
301- setIsPlaying ( true ) ;
302- } ;
303-
304286 return (
305287 < div className = "flex min-h-screen dark:from-gray-900 dark:to-gray-800 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-blue-900/20 via-transparent to-transparent" >
306288
@@ -414,53 +396,7 @@ const DSASolutionInterface = () => {
414396 </ Button >
415397 </ motion . div >
416398 < GitHubStarButtons />
417- { /* Video Section */ }
418- < motion . div
419- className = "relative max-w-4xl flex-col mx-auto mb-32 rounded-2xl overflow-hidden shadow-xl"
420- initial = { { opacity : 0 } }
421- animate = { { opacity : 1 } }
422- transition = { { duration : 1 } }
423- >
424- < div className = "aspect-video bg-gray-800 rounded-2xl overflow-hidden relative" >
425- { isPlaying ? (
426- < iframe
427- className = "w-full h-full"
428- src = { embedUrl }
429- title = "Vimeo video player"
430- frameBorder = "0"
431- allow = "autoplay; fullscreen; picture-in-picture"
432- allowFullScreen
433- > </ iframe >
434- ) : (
435- < >
436- < Image src = "/thumbnail.png" width = { 1800 } height = { 1800 } alt = "CoAgents and Langgraph" className = "object-cover h-full w-full" />
437- < div className = "absolute bottom-0 left-0 right-0 p-8" >
438- < div className = "flex items-center justify-between" >
439- < div className = "flex items-center space-x-4" >
440- < div
441- className = "w-12 h-12 rounded-full bg-purple-600 flex items-center justify-center cursor-pointer hover:bg-purple-700 transition-colors"
442- onClick = { handlePlayClick }
443- >
444- < Play className = "h-6 w-6" />
445- </ div >
446- < div >
447- < p className = "text-lg text-white font-semibold" > See A Full Fledged Demo</ p >
448- < p className = "text-purple-200" > Watch the demo insight during development</ p >
449- </ div >
450- </ div >
451- < Button
452- variant = "outline"
453- className = "text-black border-white/20 hover:bg-white/10 transition-colors"
454- onClick = { ( ) => setIsPlaying ( ! isPlaying ) }
455- >
456- Learn More
457- </ Button >
458- </ div >
459- </ div >
460- </ >
461- ) }
462- </ div >
463- </ motion . div >
399+ < VideoSection />
464400 </ div >
465401
466402 { ! showChat && (
0 commit comments