From c5a6ea65f042348166dcb5e9d4d1b431ae9a1ccb Mon Sep 17 00:00:00 2001 From: MalithaPrabhashana Date: Mon, 12 May 2025 08:03:50 +0530 Subject: [PATCH 1/2] Enhance debugging functionality by conditionally highlighting execution lines and managing breakpoints based on debug state --- src/pages/Index.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index ec13982..baf45a2 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -57,7 +57,9 @@ const Index = () => { // Assign all the callbacks -------------------------------------------- pythonThread.callbackBreakHit = (line: number) => { - codeEditorRef.current?.highlightExecutionLine(line); + if (isDebugging) { + codeEditorRef.current?.highlightExecutionLine(line); + } } pythonThread.callbackStdout = (outputText: string) => { setOutput(prev => prev + outputText); @@ -120,15 +122,18 @@ const Index = () => { useEffect(() => { if (pythonThread != null && pythonThread.loaded) { - pythonThread.setBreakpoints(breakpoints); + if (isDebugging) { + pythonThread.setBreakpoints(breakpoints); + } else { + pythonThread.setBreakpoints([]); + } } - }, [breakpoints, pythonThread]); + }, [breakpoints, pythonThread, isDebugging]); const handleDebugAction = useCallback(async (action: DebugAction) => { switch (action) { - // Toggles between debug and run mode. case "toggle": setIsDebugging(prev => { From dd3b85925b016b16229b5450ca0ccfc9ff1bee8a Mon Sep 17 00:00:00 2001 From: MalithaPrabhashana Date: Mon, 12 May 2025 09:42:18 +0530 Subject: [PATCH 2/2] Refactor DebugControls and DebugPanel components for improved readability and functionality; update Index page to manage debugging state correctly --- src/components/DebugControls.tsx | 95 ++++++++++++++------------------ src/components/DebugPanel.tsx | 6 +- src/pages/Index.tsx | 6 +- 3 files changed, 48 insertions(+), 59 deletions(-) diff --git a/src/components/DebugControls.tsx b/src/components/DebugControls.tsx index 154c567..926e300 100644 --- a/src/components/DebugControls.tsx +++ b/src/components/DebugControls.tsx @@ -1,17 +1,17 @@ import { Button } from "@/components/ui/button"; import { Toggle } from "@/components/ui/toggle"; -import { - Play, - SkipForward, - ArrowDown, - ArrowUp, - RotateCw, - Square, +import { + Play, + SkipForward, + ArrowDown, + ArrowUp, + RotateCw, + Square, ToggleRight } from "lucide-react"; import { cn } from "@/lib/utils"; -import { +import { Tooltip, TooltipContent, TooltipProvider, @@ -27,7 +27,7 @@ interface DebugControlsProps { className?: string; } -export function DebugControls({ +export function DebugControls({ isDebugging, isPaused, onDebugAction, @@ -36,37 +36,26 @@ export function DebugControls({ return (
- - - onDebugAction("toggle")} - aria-label="Toggle debug mode" - className="gap-1" - > - - - {!isDebugging ? "Debug Mode" : "Run Mode"} - - - - -

Debug Mode

-
-
- + + {isDebugging && ( <>
- + -
diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index baf45a2..cc95451 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -71,6 +71,7 @@ const Index = () => { } pythonThread.callbackExecEnd = () => { setIsRunning(false); + setIsPaused(false); codeEditorRef.current?.clearExecutionLine(); } @@ -86,6 +87,9 @@ const Index = () => { try { setIsRunning(true); pythonThread.startExecution(code); + if (isDebugging) { + setIsPaused(true); + } } catch (error) { console.error("Error running Jac code:", error); setOutput(`Error: ${error}`); @@ -230,7 +234,7 @@ const Index = () => {