Skip to content

Commit 7c73f5f

Browse files
authored
feat(debug): create debugger (#1174)
* Updates * Updates * Updates * Checkpoint * Checkpoint * Checkpoitn * Var improvements * Fixes * Execution status * UI improvements * Ui updates * Fix * Fix scoping * Fix workflow vars * Fix env vars * Remove number styling * Variable highlighting * Updates * Update * Fix resume * Stuff * Breakpoint ui * Ui * Ui updates * Loops and parallels * HIde env vars * Checkpoint * Stuff * Panel toggle * Lint
1 parent bb5f40a commit 7c73f5f

File tree

9 files changed

+2322
-71
lines changed

9 files changed

+2322
-71
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/control-bar.tsx

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import {
88
Layers,
99
Play,
1010
RefreshCw,
11-
SkipForward,
12-
StepForward,
1311
Store,
1412
Trash2,
1513
WifiOff,
@@ -44,6 +42,7 @@ import {
4442
getKeyboardShortcutText,
4543
useKeyboardShortcuts,
4644
} from '@/app/workspace/[workspaceId]/w/hooks/use-keyboard-shortcuts'
45+
import { useExecutionStore } from '@/stores/execution/store'
4746
import { useFolderStore } from '@/stores/folders/store'
4847
import { usePanelStore } from '@/stores/panel/store'
4948
import { useGeneralStore } from '@/stores/settings/general/store'
@@ -111,6 +110,9 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
111110
const [isExpanded, setIsExpanded] = useState(false)
112111
const [isTemplateModalOpen, setIsTemplateModalOpen] = useState(false)
113112
const [isAutoLayouting, setIsAutoLayouting] = useState(false)
113+
// Remove chat modal state
114+
// const [isChatPromptOpen, setIsChatPromptOpen] = useState(false)
115+
// const [chatPrompt, setChatPrompt] = useState('')
114116

115117
// Delete workflow state - grouped for better organization
116118
const [deleteState, setDeleteState] = useState({
@@ -146,6 +148,13 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
146148
}
147149
}, [setActiveTab, isOpen, togglePanel])
148150

151+
const openDebugPanel = useCallback(() => {
152+
setActiveTab('debug')
153+
if (!isOpen) {
154+
togglePanel()
155+
}
156+
}, [setActiveTab, isOpen, togglePanel])
157+
149158
// Shared condition for keyboard shortcut and button disabled state
150159
const isWorkflowBlocked = isExecuting || hasValidationErrors
151160

@@ -819,15 +828,29 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
819828
return // Do nothing if no executable blocks
820829
}
821830

822-
// Start debugging
831+
// Determine starter id for focus
832+
const starter = Object.values(blocks).find((b) => b.type === 'starter') as any
833+
const starterId = starter?.id as string | undefined
834+
835+
// Enable debug UI but do NOT start execution
823836
if (!isDebugModeEnabled) {
824837
toggleDebugMode()
825838
}
826839
if (usageExceeded) {
827840
openSubscriptionSettings()
828841
} else {
829-
openConsolePanel()
830-
handleRunWorkflow(undefined, true) // Start in debug mode
842+
// Activate debug session state so the panel is active
843+
const execStore = useExecutionStore.getState()
844+
execStore.setIsExecuting(false)
845+
execStore.setIsDebugging(true)
846+
// Set the Start block as pending - it will execute on first Step
847+
execStore.setPendingBlocks(starterId ? [starterId] : [])
848+
849+
// Show Debug tab and mark starter as the current block to execute
850+
openDebugPanel()
851+
if (starterId) {
852+
execStore.setActiveBlocks(new Set([starterId]))
853+
}
831854
}
832855
}
833856
}, [
@@ -838,8 +861,7 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
838861
blocks,
839862
handleCancelDebug,
840863
toggleDebugMode,
841-
handleRunWorkflow,
842-
openConsolePanel,
864+
openDebugPanel,
843865
])
844866

845867
/**
@@ -859,40 +881,7 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
859881

860882
return (
861883
<div className='flex items-center gap-1'>
862-
<Tooltip>
863-
<TooltipTrigger asChild>
864-
<Button
865-
onClick={() => {
866-
openConsolePanel()
867-
handleStepDebug()
868-
}}
869-
className={debugButtonClass}
870-
disabled={isControlDisabled}
871-
>
872-
<StepForward className='h-5 w-5' />
873-
<span className='sr-only'>Step Forward</span>
874-
</Button>
875-
</TooltipTrigger>
876-
<TooltipContent>Step Forward</TooltipContent>
877-
</Tooltip>
878-
879-
<Tooltip>
880-
<TooltipTrigger asChild>
881-
<Button
882-
onClick={() => {
883-
openConsolePanel()
884-
handleResumeDebug()
885-
}}
886-
className={debugButtonClass}
887-
disabled={isControlDisabled}
888-
>
889-
<SkipForward className='h-5 w-5' />
890-
<span className='sr-only'>Resume Until End</span>
891-
</Button>
892-
</TooltipTrigger>
893-
<TooltipContent>Resume Until End</TooltipContent>
894-
</Tooltip>
895-
884+
{/* Keep only cancel (X) here; step/resume moved to panel */}
896885
<Tooltip>
897886
<TooltipTrigger asChild>
898887
<Button
@@ -1214,7 +1203,7 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
12141203
{isExpanded && renderPublishButton()}
12151204
{renderDeleteButton()}
12161205
{renderDuplicateButton()}
1217-
{!isDebugging && renderDebugModeToggle()}
1206+
{renderDebugModeToggle()}
12181207
{renderDeployButton()}
12191208
{isDebugging ? renderDebugControlsBar() : renderRunButton()}
12201209

@@ -1226,6 +1215,8 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
12261215
workflowId={activeWorkflowId}
12271216
/>
12281217
)}
1218+
1219+
{/* Removed chat prompt dialog; chat input now lives in DebugPanel */}
12291220
</div>
12301221
)
12311222
}

0 commit comments

Comments
 (0)