Skip to content

Commit 989a772

Browse files
fix(debug-mode): remove duplicate debug mode flag (#1714)
1 parent 5ab4821 commit 989a772

File tree

8 files changed

+15
-42
lines changed

8 files changed

+15
-42
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import {
5050
import { useFolderStore } from '@/stores/folders/store'
5151
import { useOperationQueueStore } from '@/stores/operation-queue/store'
5252
import { usePanelStore } from '@/stores/panel/store'
53-
import { useGeneralStore } from '@/stores/settings/general/store'
5453
import { useSubscriptionStore } from '@/stores/subscription/store'
5554
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
5655
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
@@ -104,7 +103,6 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
104103
const userPermissions = useUserPermissionsContext()
105104

106105
// Debug mode state
107-
const { isDebugModeEnabled, toggleDebugMode } = useGeneralStore()
108106
const { isDebugging, pendingBlocks, handleStepDebug, handleCancelDebug, handleResumeDebug } =
109107
useWorkflowExecution()
110108

@@ -874,9 +872,6 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
874872
}
875873

876874
// Start debugging
877-
if (!isDebugModeEnabled) {
878-
toggleDebugMode()
879-
}
880875
if (usageExceeded) {
881876
openSubscriptionSettings()
882877
} else {
@@ -887,11 +882,9 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
887882
}, [
888883
userPermissions.canRead,
889884
isDebugging,
890-
isDebugModeEnabled,
891885
usageExceeded,
892886
blocks,
893887
handleCancelDebug,
894-
toggleDebugMode,
895888
handleRunWorkflow,
896889
openConsolePanel,
897890
])

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { useExecutionStore } from '@/stores/execution/store'
1313
import { useConsoleStore } from '@/stores/panel/console/store'
1414
import { useVariablesStore } from '@/stores/panel/variables/store'
1515
import { useEnvironmentStore } from '@/stores/settings/environment/store'
16-
import { useGeneralStore } from '@/stores/settings/general/store'
1716
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
1817
import { mergeSubblockState } from '@/stores/workflows/utils'
1918
import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/workflow/utils'
@@ -100,7 +99,6 @@ export function useWorkflowExecution() {
10099
const { activeWorkflowId, workflows } = useWorkflowRegistry()
101100
const { toggleConsole } = useConsoleStore()
102101
const { getAllVariables, loadWorkspaceEnvironment } = useEnvironmentStore()
103-
const { isDebugModeEnabled } = useGeneralStore()
104102
const { getVariablesByWorkflowId, variables } = useVariablesStore()
105103
const {
106104
isExecuting,
@@ -145,19 +143,13 @@ export function useWorkflowExecution() {
145143
setExecutor(null)
146144
setPendingBlocks([])
147145
setActiveBlocks(new Set())
148-
149-
// Reset debug mode setting if it was enabled
150-
if (isDebugModeEnabled) {
151-
useGeneralStore.getState().toggleDebugMode()
152-
}
153146
}, [
154147
setIsExecuting,
155148
setIsDebugging,
156149
setDebugContext,
157150
setExecutor,
158151
setPendingBlocks,
159152
setActiveBlocks,
160-
isDebugModeEnabled,
161153
])
162154

163155
/**
@@ -626,11 +618,10 @@ export function useWorkflowExecution() {
626618
}
627619
} else if (result && 'success' in result) {
628620
setExecutionResult(result)
629-
if (!isDebugModeEnabled) {
630-
setIsExecuting(false)
631-
setIsDebugging(false)
632-
setActiveBlocks(new Set())
633-
}
621+
// Reset execution state after successful non-debug execution
622+
setIsExecuting(false)
623+
setIsDebugging(false)
624+
setActiveBlocks(new Set())
634625

635626
if (isChatExecution) {
636627
if (!result.metadata) {
@@ -659,7 +650,6 @@ export function useWorkflowExecution() {
659650
getAllVariables,
660651
loadWorkspaceEnvironment,
661652
getVariablesByWorkflowId,
662-
isDebugModeEnabled,
663653
setIsExecuting,
664654
setIsDebugging,
665655
setDebugContext,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ const WorkflowContent = React.memo(() => {
252252
} = useCollaborativeWorkflow()
253253

254254
// Execution and debug mode state
255-
const { activeBlockIds, pendingBlocks } = useExecutionStore()
256-
const { isDebugModeEnabled } = useGeneralStore()
255+
const { activeBlockIds, pendingBlocks, isDebugging } = useExecutionStore()
257256
const [dragStartParentId, setDragStartParentId] = useState<string | null>(null)
258257

259258
// Helper function to validate workflow for nested subflows
@@ -1273,7 +1272,7 @@ const WorkflowContent = React.memo(() => {
12731272
const position = block.position
12741273

12751274
const isActive = activeBlockIds.has(block.id)
1276-
const isPending = isDebugModeEnabled && pendingBlocks.includes(block.id)
1275+
const isPending = isDebugging && pendingBlocks.includes(block.id)
12771276

12781277
// Create stable node object - React Flow will handle shallow comparison
12791278
nodeArray.push({
@@ -1302,7 +1301,7 @@ const WorkflowContent = React.memo(() => {
13021301
blocks,
13031302
activeBlockIds,
13041303
pendingBlocks,
1305-
isDebugModeEnabled,
1304+
isDebugging,
13061305
nestedSubflowErrors,
13071306
getBlockConfig,
13081307
])

apps/sim/executor/__test-utils__/executor-mocks.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const setupHandlerMocks = () => {
5757
* Setup store mocks with configurable options
5858
*/
5959
export const setupStoreMocks = (options?: {
60-
isDebugModeEnabled?: boolean
60+
isDebugging?: boolean
6161
consoleAddFn?: ReturnType<typeof vi.fn>
6262
consoleUpdateFn?: ReturnType<typeof vi.fn>
6363
}) => {
@@ -66,15 +66,14 @@ export const setupStoreMocks = (options?: {
6666

6767
vi.doMock('@/stores/settings/general/store', () => ({
6868
useGeneralStore: {
69-
getState: () => ({
70-
isDebugModeEnabled: options?.isDebugModeEnabled ?? false,
71-
}),
69+
getState: () => ({}),
7270
},
7371
}))
7472

7573
vi.doMock('@/stores/execution/store', () => ({
7674
useExecutionStore: {
7775
getState: () => ({
76+
isDebugging: options?.isDebugging ?? false,
7877
setIsExecuting: vi.fn(),
7978
reset: vi.fn(),
8079
setActiveBlocks: vi.fn(),
@@ -925,7 +924,7 @@ export const setupParallelTestMocks = (options?: {
925924
* Sets up all standard mocks for executor tests
926925
*/
927926
export const setupAllMocks = (options?: {
928-
isDebugModeEnabled?: boolean
927+
isDebugging?: boolean
929928
consoleAddFn?: ReturnType<typeof vi.fn>
930929
consoleUpdateFn?: ReturnType<typeof vi.fn>
931930
}) => {

apps/sim/executor/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ describe('Executor', () => {
386386
* Debug mode tests
387387
*/
388388
describe('debug mode', () => {
389-
it('should detect debug mode from settings', async () => {
389+
it('should detect debug mode from execution store', async () => {
390390
vi.resetModules()
391391
vi.clearAllMocks()
392392

393-
setupAllMocks({ isDebugModeEnabled: true })
393+
setupAllMocks({ isDebugging: true })
394394

395395
const { Executor } = await import('@/executor/index')
396396

@@ -405,7 +405,7 @@ describe('Executor', () => {
405405
vi.resetModules()
406406
vi.clearAllMocks()
407407

408-
setupAllMocks({ isDebugModeEnabled: false })
408+
setupAllMocks({ isDebugging: false })
409409

410410
const { Executor } = await import('@/executor/index')
411411

apps/sim/executor/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { VirtualBlockUtils } from '@/executor/utils/virtual-blocks'
3636
import type { SerializedBlock, SerializedWorkflow } from '@/serializer/types'
3737
import { useExecutionStore } from '@/stores/execution/store'
3838
import { useConsoleStore } from '@/stores/panel/console/store'
39-
import { useGeneralStore } from '@/stores/settings/general/store'
4039

4140
const logger = createLogger('Executor')
4241

@@ -217,7 +216,7 @@ export class Executor {
217216
new GenericBlockHandler(),
218217
]
219218

220-
this.isDebugging = useGeneralStore.getState().isDebugModeEnabled
219+
this.isDebugging = useExecutionStore.getState().isDebugging
221220
}
222221

223222
/**

apps/sim/stores/settings/general/store.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const useGeneralStore = create<GeneralStore>()(
2121
isAutoConnectEnabled: true,
2222
isAutoPanEnabled: true,
2323
isConsoleExpandedByDefault: true,
24-
isDebugModeEnabled: false,
2524
showFloatingControls: true,
2625
showTrainingControls: false,
2726
theme: 'system' as const, // Keep for compatibility but not used
@@ -101,10 +100,6 @@ export const useGeneralStore = create<GeneralStore>()(
101100
)
102101
},
103102

104-
toggleDebugMode: () => {
105-
set({ isDebugModeEnabled: !get().isDebugModeEnabled })
106-
},
107-
108103
toggleFloatingControls: async () => {
109104
if (get().isFloatingControlsLoading) return
110105
const newValue = !get().showFloatingControls

apps/sim/stores/settings/general/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export interface General {
22
isAutoConnectEnabled: boolean
33
isAutoPanEnabled: boolean
44
isConsoleExpandedByDefault: boolean
5-
isDebugModeEnabled: boolean
65
showFloatingControls: boolean
76
showTrainingControls: boolean
87
theme: 'system' | 'light' | 'dark'
@@ -24,7 +23,6 @@ export interface GeneralActions {
2423
toggleAutoConnect: () => Promise<void>
2524
toggleAutoPan: () => Promise<void>
2625
toggleConsoleExpandedByDefault: () => Promise<void>
27-
toggleDebugMode: () => void
2826
toggleFloatingControls: () => Promise<void>
2927
toggleTrainingControls: () => Promise<void>
3028
setTheme: (theme: 'system' | 'light' | 'dark') => Promise<void>

0 commit comments

Comments
 (0)