Uh oh!
There was an error while loading. Please reload this page.
fix(start): fix start drag from toolbar - #1882
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryFixed start block initialization when dragging from toolbar by ensuring subblocks receive proper default values. The PR addresses three key issues:
The changes ensure that when users drag the Start block from the toolbar, it appears with properly initialized input format fields instead of Confidence Score: 3/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Toolbar
participant CollabWorkflow as useCollaborativeWorkflow
participant WorkflowStore
participant SubBlockStore
participant BlockConfig
User->>Toolbar: Drag Start block from toolbar
Toolbar->>CollabWorkflow: addBlock(type='start_trigger', ...)
CollabWorkflow->>BlockConfig: Get block configuration
BlockConfig-->>CollabWorkflow: startTriggerBlock config
CollabWorkflow->>CollabWorkflow: Initialize subBlocks
alt subBlock.value is function
CollabWorkflow->>CollabWorkflow: subBlock.value({})
else subBlock.defaultValue exists
CollabWorkflow->>CollabWorkflow: Use defaultValue
else subBlock.type === 'input-format'
CollabWorkflow->>CollabWorkflow: Create default entry with UUID
else subBlock.type === 'table'
CollabWorkflow->>CollabWorkflow: Initialize as []
end
CollabWorkflow->>WorkflowStore: addBlock(id, type, name, position, ...)
WorkflowStore->>WorkflowStore: resolveInitialSubblockValue(config)
WorkflowStore->>WorkflowStore: cloneInitialSubblockValue(resolved)
WorkflowStore->>SubBlockStore: setValue(blockId, subBlockId, value)
SubBlockStore-->>WorkflowStore: Value stored
WorkflowStore-->>CollabWorkflow: Block added
CollabWorkflow-->>User: Start block rendered with defaults
|
There was a problem hiding this comment.
Additional Comments (1)
apps/sim/lib/workflows/defaults.ts, line 20-22 (link)logic:
cloneDefaultValueuses shallow cloning for objects, whilecloneInitialSubblockValueinstore.ts:35-43uses deep cloning. This inconsistency can cause shared reference bugs for nested objects.
4 files reviewed, 1 comment
Uh oh!
There was an error while loading. Please reload this page.
* Fix start block * Fix webhook * Remove comments
* Fix start block * Fix webhook * Remove comments
Summary
Fix start drag from toolbar
Type of Change
Testing
Manual
Checklist