3
3
import React , { useEffect , useState } from "react" ;
4
4
import { motion , AnimatePresence } from "framer-motion" ;
5
5
import dynamic from "next/dynamic" ;
6
- import { Loader2 , ExternalLink , Cpu , MessageSquare , Play } from "lucide-react" ;
6
+ import { Loader2 , ExternalLink , Cpu , MessageSquare } from "lucide-react" ;
7
7
import { Button } from "@/components/ui/button" ;
8
8
import { Role , TextMessage } from "@copilotkit/runtime-client-gql" ;
9
9
import ChatInterface from "@/components/ChatInterface" ;
@@ -17,6 +17,7 @@ import GitHubStarButtons from "@/components/StarComponent";
17
17
import Image from "next/image" ;
18
18
import { CopilotSidebar } from "@copilotkit/react-ui" ;
19
19
import "@copilotkit/react-ui/styles.css" ;
20
+ import VideoSection from "@/components/VideoSection" ;
20
21
21
22
interface AgentState {
22
23
question : string ;
@@ -183,13 +184,12 @@ const DSASolutionInterface = () => {
183
184
timeComplexity,
184
185
spaceComplexity,
185
186
} ;
186
-
187
- // Only update if the state has actually changed
187
+
188
188
if ( ! isStateEqual ( state , newState ) ) {
189
189
setState ( ( prevState = state ) => ( {
190
190
...prevState ,
191
191
...newState ,
192
- // Preserve other fields that aren't being updated
192
+
193
193
code : prevState . code ,
194
194
explanation : prevState . explanation ,
195
195
visualization : prevState . visualization ,
@@ -205,7 +205,6 @@ const DSASolutionInterface = () => {
205
205
206
206
setShowChat ( true ) ;
207
207
208
- // First, send the problem context
209
208
const contextMessage = new TextMessage ( {
210
209
id : "context-" + Date . now ( ) . toString ( ) ,
211
210
role : Role . System ,
@@ -218,14 +217,14 @@ const DSASolutionInterface = () => {
218
217
` ,
219
218
} ) ;
220
219
221
- // Then send the user's question
220
+
222
221
const userMessage = new TextMessage ( {
223
222
id : "user-" + Date . now ( ) . toString ( ) ,
224
223
role : Role . User ,
225
224
content : question ,
226
225
} ) ;
227
226
228
- // Send messages with a slight delay
227
+
229
228
setTimeout ( ( ) => {
230
229
appendMessage ( contextMessage ) ;
231
230
setTimeout ( ( ) => {
@@ -236,27 +235,23 @@ const DSASolutionInterface = () => {
236
235
237
236
const handleSolutionUpdate = ( content : string ) => {
238
237
try {
239
- // Extract code block
238
+
240
239
const codeMatch = content . match ( / ` ` ` p y t h o n \n ( [ \s \S ] * ?) ` ` ` / ) ;
241
240
const code = codeMatch ? codeMatch [ 1 ] . trim ( ) : "" ;
242
241
243
- // Extract explanation (text before code block)
242
+
244
243
const explanation = content . split ( "```" ) [ 0 ] . trim ( ) ;
245
244
246
- // Extract complexities
247
245
const timeMatch = content . match ( / [ T t ] i m e [ C c ] o m p l e x i t y : ? \s * ( O \( [ ^ ) ] + \) ) / ) ;
248
246
const spaceMatch = content . match (
249
247
/ [ S s ] p a c e [ C c ] o m p l e x i t y : ? \s * ( O \( [ ^ ) ] + \) ) /
250
248
) ;
251
249
252
- // // Extract visualization if present
253
- // const visualMatch = content.match(/```mermaid\n([\s\S]*?)```/);
254
250
255
- // Update all states
256
251
setSolution ( prevSolution => ( {
257
252
code : code ,
258
253
explanation : explanation ,
259
- visualization : prevSolution ?. visualization // Preserve existing visualization
254
+ visualization : prevSolution ?. visualization
260
255
} ) ) ;
261
256
262
257
if ( timeMatch ) setTimeComplexity ( timeMatch [ 1 ] ) ;
@@ -288,19 +283,6 @@ const DSASolutionInterface = () => {
288
283
} , [ visibleMessages ] ) ;
289
284
290
285
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
-
304
286
return (
305
287
< 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" >
306
288
@@ -414,53 +396,7 @@ const DSASolutionInterface = () => {
414
396
</ Button >
415
397
</ motion . div >
416
398
< 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 />
464
400
</ div >
465
401
466
402
{ ! showChat && (
0 commit comments