mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
fix(debug-mode): remove duplicate debug mode flag (#1714)
This commit is contained in:
committed by
GitHub
parent
5ab482127d
commit
989a77261c
@@ -50,7 +50,6 @@ import {
|
|||||||
import { useFolderStore } from '@/stores/folders/store'
|
import { useFolderStore } from '@/stores/folders/store'
|
||||||
import { useOperationQueueStore } from '@/stores/operation-queue/store'
|
import { useOperationQueueStore } from '@/stores/operation-queue/store'
|
||||||
import { usePanelStore } from '@/stores/panel/store'
|
import { usePanelStore } from '@/stores/panel/store'
|
||||||
import { useGeneralStore } from '@/stores/settings/general/store'
|
|
||||||
import { useSubscriptionStore } from '@/stores/subscription/store'
|
import { useSubscriptionStore } from '@/stores/subscription/store'
|
||||||
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||||
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
|
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
|
||||||
@@ -104,7 +103,6 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
|
|||||||
const userPermissions = useUserPermissionsContext()
|
const userPermissions = useUserPermissionsContext()
|
||||||
|
|
||||||
// Debug mode state
|
// Debug mode state
|
||||||
const { isDebugModeEnabled, toggleDebugMode } = useGeneralStore()
|
|
||||||
const { isDebugging, pendingBlocks, handleStepDebug, handleCancelDebug, handleResumeDebug } =
|
const { isDebugging, pendingBlocks, handleStepDebug, handleCancelDebug, handleResumeDebug } =
|
||||||
useWorkflowExecution()
|
useWorkflowExecution()
|
||||||
|
|
||||||
@@ -874,9 +872,6 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start debugging
|
// Start debugging
|
||||||
if (!isDebugModeEnabled) {
|
|
||||||
toggleDebugMode()
|
|
||||||
}
|
|
||||||
if (usageExceeded) {
|
if (usageExceeded) {
|
||||||
openSubscriptionSettings()
|
openSubscriptionSettings()
|
||||||
} else {
|
} else {
|
||||||
@@ -887,11 +882,9 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
|
|||||||
}, [
|
}, [
|
||||||
userPermissions.canRead,
|
userPermissions.canRead,
|
||||||
isDebugging,
|
isDebugging,
|
||||||
isDebugModeEnabled,
|
|
||||||
usageExceeded,
|
usageExceeded,
|
||||||
blocks,
|
blocks,
|
||||||
handleCancelDebug,
|
handleCancelDebug,
|
||||||
toggleDebugMode,
|
|
||||||
handleRunWorkflow,
|
handleRunWorkflow,
|
||||||
openConsolePanel,
|
openConsolePanel,
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { useExecutionStore } from '@/stores/execution/store'
|
|||||||
import { useConsoleStore } from '@/stores/panel/console/store'
|
import { useConsoleStore } from '@/stores/panel/console/store'
|
||||||
import { useVariablesStore } from '@/stores/panel/variables/store'
|
import { useVariablesStore } from '@/stores/panel/variables/store'
|
||||||
import { useEnvironmentStore } from '@/stores/settings/environment/store'
|
import { useEnvironmentStore } from '@/stores/settings/environment/store'
|
||||||
import { useGeneralStore } from '@/stores/settings/general/store'
|
|
||||||
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||||
import { mergeSubblockState } from '@/stores/workflows/utils'
|
import { mergeSubblockState } from '@/stores/workflows/utils'
|
||||||
import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/workflow/utils'
|
import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/workflow/utils'
|
||||||
@@ -100,7 +99,6 @@ export function useWorkflowExecution() {
|
|||||||
const { activeWorkflowId, workflows } = useWorkflowRegistry()
|
const { activeWorkflowId, workflows } = useWorkflowRegistry()
|
||||||
const { toggleConsole } = useConsoleStore()
|
const { toggleConsole } = useConsoleStore()
|
||||||
const { getAllVariables, loadWorkspaceEnvironment } = useEnvironmentStore()
|
const { getAllVariables, loadWorkspaceEnvironment } = useEnvironmentStore()
|
||||||
const { isDebugModeEnabled } = useGeneralStore()
|
|
||||||
const { getVariablesByWorkflowId, variables } = useVariablesStore()
|
const { getVariablesByWorkflowId, variables } = useVariablesStore()
|
||||||
const {
|
const {
|
||||||
isExecuting,
|
isExecuting,
|
||||||
@@ -145,11 +143,6 @@ export function useWorkflowExecution() {
|
|||||||
setExecutor(null)
|
setExecutor(null)
|
||||||
setPendingBlocks([])
|
setPendingBlocks([])
|
||||||
setActiveBlocks(new Set())
|
setActiveBlocks(new Set())
|
||||||
|
|
||||||
// Reset debug mode setting if it was enabled
|
|
||||||
if (isDebugModeEnabled) {
|
|
||||||
useGeneralStore.getState().toggleDebugMode()
|
|
||||||
}
|
|
||||||
}, [
|
}, [
|
||||||
setIsExecuting,
|
setIsExecuting,
|
||||||
setIsDebugging,
|
setIsDebugging,
|
||||||
@@ -157,7 +150,6 @@ export function useWorkflowExecution() {
|
|||||||
setExecutor,
|
setExecutor,
|
||||||
setPendingBlocks,
|
setPendingBlocks,
|
||||||
setActiveBlocks,
|
setActiveBlocks,
|
||||||
isDebugModeEnabled,
|
|
||||||
])
|
])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -626,11 +618,10 @@ export function useWorkflowExecution() {
|
|||||||
}
|
}
|
||||||
} else if (result && 'success' in result) {
|
} else if (result && 'success' in result) {
|
||||||
setExecutionResult(result)
|
setExecutionResult(result)
|
||||||
if (!isDebugModeEnabled) {
|
// Reset execution state after successful non-debug execution
|
||||||
setIsExecuting(false)
|
setIsExecuting(false)
|
||||||
setIsDebugging(false)
|
setIsDebugging(false)
|
||||||
setActiveBlocks(new Set())
|
setActiveBlocks(new Set())
|
||||||
}
|
|
||||||
|
|
||||||
if (isChatExecution) {
|
if (isChatExecution) {
|
||||||
if (!result.metadata) {
|
if (!result.metadata) {
|
||||||
@@ -659,7 +650,6 @@ export function useWorkflowExecution() {
|
|||||||
getAllVariables,
|
getAllVariables,
|
||||||
loadWorkspaceEnvironment,
|
loadWorkspaceEnvironment,
|
||||||
getVariablesByWorkflowId,
|
getVariablesByWorkflowId,
|
||||||
isDebugModeEnabled,
|
|
||||||
setIsExecuting,
|
setIsExecuting,
|
||||||
setIsDebugging,
|
setIsDebugging,
|
||||||
setDebugContext,
|
setDebugContext,
|
||||||
|
|||||||
@@ -252,8 +252,7 @@ const WorkflowContent = React.memo(() => {
|
|||||||
} = useCollaborativeWorkflow()
|
} = useCollaborativeWorkflow()
|
||||||
|
|
||||||
// Execution and debug mode state
|
// Execution and debug mode state
|
||||||
const { activeBlockIds, pendingBlocks } = useExecutionStore()
|
const { activeBlockIds, pendingBlocks, isDebugging } = useExecutionStore()
|
||||||
const { isDebugModeEnabled } = useGeneralStore()
|
|
||||||
const [dragStartParentId, setDragStartParentId] = useState<string | null>(null)
|
const [dragStartParentId, setDragStartParentId] = useState<string | null>(null)
|
||||||
|
|
||||||
// Helper function to validate workflow for nested subflows
|
// Helper function to validate workflow for nested subflows
|
||||||
@@ -1273,7 +1272,7 @@ const WorkflowContent = React.memo(() => {
|
|||||||
const position = block.position
|
const position = block.position
|
||||||
|
|
||||||
const isActive = activeBlockIds.has(block.id)
|
const isActive = activeBlockIds.has(block.id)
|
||||||
const isPending = isDebugModeEnabled && pendingBlocks.includes(block.id)
|
const isPending = isDebugging && pendingBlocks.includes(block.id)
|
||||||
|
|
||||||
// Create stable node object - React Flow will handle shallow comparison
|
// Create stable node object - React Flow will handle shallow comparison
|
||||||
nodeArray.push({
|
nodeArray.push({
|
||||||
@@ -1302,7 +1301,7 @@ const WorkflowContent = React.memo(() => {
|
|||||||
blocks,
|
blocks,
|
||||||
activeBlockIds,
|
activeBlockIds,
|
||||||
pendingBlocks,
|
pendingBlocks,
|
||||||
isDebugModeEnabled,
|
isDebugging,
|
||||||
nestedSubflowErrors,
|
nestedSubflowErrors,
|
||||||
getBlockConfig,
|
getBlockConfig,
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const setupHandlerMocks = () => {
|
|||||||
* Setup store mocks with configurable options
|
* Setup store mocks with configurable options
|
||||||
*/
|
*/
|
||||||
export const setupStoreMocks = (options?: {
|
export const setupStoreMocks = (options?: {
|
||||||
isDebugModeEnabled?: boolean
|
isDebugging?: boolean
|
||||||
consoleAddFn?: ReturnType<typeof vi.fn>
|
consoleAddFn?: ReturnType<typeof vi.fn>
|
||||||
consoleUpdateFn?: ReturnType<typeof vi.fn>
|
consoleUpdateFn?: ReturnType<typeof vi.fn>
|
||||||
}) => {
|
}) => {
|
||||||
@@ -66,15 +66,14 @@ export const setupStoreMocks = (options?: {
|
|||||||
|
|
||||||
vi.doMock('@/stores/settings/general/store', () => ({
|
vi.doMock('@/stores/settings/general/store', () => ({
|
||||||
useGeneralStore: {
|
useGeneralStore: {
|
||||||
getState: () => ({
|
getState: () => ({}),
|
||||||
isDebugModeEnabled: options?.isDebugModeEnabled ?? false,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
vi.doMock('@/stores/execution/store', () => ({
|
vi.doMock('@/stores/execution/store', () => ({
|
||||||
useExecutionStore: {
|
useExecutionStore: {
|
||||||
getState: () => ({
|
getState: () => ({
|
||||||
|
isDebugging: options?.isDebugging ?? false,
|
||||||
setIsExecuting: vi.fn(),
|
setIsExecuting: vi.fn(),
|
||||||
reset: vi.fn(),
|
reset: vi.fn(),
|
||||||
setActiveBlocks: vi.fn(),
|
setActiveBlocks: vi.fn(),
|
||||||
@@ -925,7 +924,7 @@ export const setupParallelTestMocks = (options?: {
|
|||||||
* Sets up all standard mocks for executor tests
|
* Sets up all standard mocks for executor tests
|
||||||
*/
|
*/
|
||||||
export const setupAllMocks = (options?: {
|
export const setupAllMocks = (options?: {
|
||||||
isDebugModeEnabled?: boolean
|
isDebugging?: boolean
|
||||||
consoleAddFn?: ReturnType<typeof vi.fn>
|
consoleAddFn?: ReturnType<typeof vi.fn>
|
||||||
consoleUpdateFn?: ReturnType<typeof vi.fn>
|
consoleUpdateFn?: ReturnType<typeof vi.fn>
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
@@ -386,11 +386,11 @@ describe('Executor', () => {
|
|||||||
* Debug mode tests
|
* Debug mode tests
|
||||||
*/
|
*/
|
||||||
describe('debug mode', () => {
|
describe('debug mode', () => {
|
||||||
it('should detect debug mode from settings', async () => {
|
it('should detect debug mode from execution store', async () => {
|
||||||
vi.resetModules()
|
vi.resetModules()
|
||||||
vi.clearAllMocks()
|
vi.clearAllMocks()
|
||||||
|
|
||||||
setupAllMocks({ isDebugModeEnabled: true })
|
setupAllMocks({ isDebugging: true })
|
||||||
|
|
||||||
const { Executor } = await import('@/executor/index')
|
const { Executor } = await import('@/executor/index')
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ describe('Executor', () => {
|
|||||||
vi.resetModules()
|
vi.resetModules()
|
||||||
vi.clearAllMocks()
|
vi.clearAllMocks()
|
||||||
|
|
||||||
setupAllMocks({ isDebugModeEnabled: false })
|
setupAllMocks({ isDebugging: false })
|
||||||
|
|
||||||
const { Executor } = await import('@/executor/index')
|
const { Executor } = await import('@/executor/index')
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import { VirtualBlockUtils } from '@/executor/utils/virtual-blocks'
|
|||||||
import type { SerializedBlock, SerializedWorkflow } from '@/serializer/types'
|
import type { SerializedBlock, SerializedWorkflow } from '@/serializer/types'
|
||||||
import { useExecutionStore } from '@/stores/execution/store'
|
import { useExecutionStore } from '@/stores/execution/store'
|
||||||
import { useConsoleStore } from '@/stores/panel/console/store'
|
import { useConsoleStore } from '@/stores/panel/console/store'
|
||||||
import { useGeneralStore } from '@/stores/settings/general/store'
|
|
||||||
|
|
||||||
const logger = createLogger('Executor')
|
const logger = createLogger('Executor')
|
||||||
|
|
||||||
@@ -217,7 +216,7 @@ export class Executor {
|
|||||||
new GenericBlockHandler(),
|
new GenericBlockHandler(),
|
||||||
]
|
]
|
||||||
|
|
||||||
this.isDebugging = useGeneralStore.getState().isDebugModeEnabled
|
this.isDebugging = useExecutionStore.getState().isDebugging
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export const useGeneralStore = create<GeneralStore>()(
|
|||||||
isAutoConnectEnabled: true,
|
isAutoConnectEnabled: true,
|
||||||
isAutoPanEnabled: true,
|
isAutoPanEnabled: true,
|
||||||
isConsoleExpandedByDefault: true,
|
isConsoleExpandedByDefault: true,
|
||||||
isDebugModeEnabled: false,
|
|
||||||
showFloatingControls: true,
|
showFloatingControls: true,
|
||||||
showTrainingControls: false,
|
showTrainingControls: false,
|
||||||
theme: 'system' as const, // Keep for compatibility but not used
|
theme: 'system' as const, // Keep for compatibility but not used
|
||||||
@@ -101,10 +100,6 @@ export const useGeneralStore = create<GeneralStore>()(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleDebugMode: () => {
|
|
||||||
set({ isDebugModeEnabled: !get().isDebugModeEnabled })
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleFloatingControls: async () => {
|
toggleFloatingControls: async () => {
|
||||||
if (get().isFloatingControlsLoading) return
|
if (get().isFloatingControlsLoading) return
|
||||||
const newValue = !get().showFloatingControls
|
const newValue = !get().showFloatingControls
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ export interface General {
|
|||||||
isAutoConnectEnabled: boolean
|
isAutoConnectEnabled: boolean
|
||||||
isAutoPanEnabled: boolean
|
isAutoPanEnabled: boolean
|
||||||
isConsoleExpandedByDefault: boolean
|
isConsoleExpandedByDefault: boolean
|
||||||
isDebugModeEnabled: boolean
|
|
||||||
showFloatingControls: boolean
|
showFloatingControls: boolean
|
||||||
showTrainingControls: boolean
|
showTrainingControls: boolean
|
||||||
theme: 'system' | 'light' | 'dark'
|
theme: 'system' | 'light' | 'dark'
|
||||||
@@ -24,7 +23,6 @@ export interface GeneralActions {
|
|||||||
toggleAutoConnect: () => Promise<void>
|
toggleAutoConnect: () => Promise<void>
|
||||||
toggleAutoPan: () => Promise<void>
|
toggleAutoPan: () => Promise<void>
|
||||||
toggleConsoleExpandedByDefault: () => Promise<void>
|
toggleConsoleExpandedByDefault: () => Promise<void>
|
||||||
toggleDebugMode: () => void
|
|
||||||
toggleFloatingControls: () => Promise<void>
|
toggleFloatingControls: () => Promise<void>
|
||||||
toggleTrainingControls: () => Promise<void>
|
toggleTrainingControls: () => Promise<void>
|
||||||
setTheme: (theme: 'system' | 'light' | 'dark') => Promise<void>
|
setTheme: (theme: 'system' | 'light' | 'dark') => Promise<void>
|
||||||
|
|||||||
Reference in New Issue
Block a user