Skip to content

fix(start): fix start drag from toolbar - #1882

Merged
Sg312 merged 3 commits into
stagingfrom
fix/start-input-format
Nov 11, 2025
Merged

fix(start): fix start drag from toolbar#1882
Sg312 merged 3 commits into
stagingfrom
fix/start-input-format

Conversation

@Sg312

Copy link
Copy Markdown
Collaborator

Summary

Fix start drag from toolbar

Type of Change

  • Bug fix

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Nov 11, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedNov 11, 2025 4:27am

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Fixed start block initialization when dragging from toolbar by ensuring subblocks receive proper default values. The PR addresses three key issues:

  • Subblock initialization: Added logic to initialize input-format subblocks with a default entry structure (containing id, name, type, value, collapsed fields) and table subblocks with empty arrays
  • Trigger capability detection: Fixed hasTriggerCapability() to properly check trigger-mode subblocks for trigger category blocks, enabling the enableTriggerMode flag
  • Store seeding: Enhanced block creation in workflow/store.ts to seed the subblock store with initial values immediately upon block creation

The changes ensure that when users drag the Start block from the toolbar, it appears with properly initialized input format fields instead of null values.

Confidence Score: 3/5

  • Safe to merge with one cloning inconsistency that should be addressed to prevent potential shared reference bugs
  • The PR successfully fixes the start block drag initialization, but contains a critical cloning inconsistency in defaults.ts where shallow cloning is used instead of deep cloning. This mismatch between cloneDefaultValue and cloneInitialSubblockValue could lead to shared reference bugs for nested objects. The rest of the implementation is solid with proper error handling and comprehensive initialization logic.
  • apps/sim/lib/workflows/defaults.ts - cloning function needs to be updated to deep clone

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/lib/workflows/defaults.ts2/5Enhanced input-format initialization with default entry, but cloneDefaultValue uses shallow cloning which can cause shared reference bugs
apps/sim/stores/workflows/workflow/store.ts4/5Added proper deep cloning functions and subblock initialization logic with sub-block store seeding during block creation

Sequence Diagram

sequenceDiagram
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
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. apps/sim/lib/workflows/defaults.ts, line 20-22 (link)

    logic:cloneDefaultValue uses shallow cloning for objects, while cloneInitialSubblockValue in store.ts:35-43 uses deep cloning. This inconsistency can cause shared reference bugs for nested objects.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@Sg312
Sg312 merged commit cd48cd4 into stagingNov 11, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/start-input-format branch November 11, 2025 18:25
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
* Fix start block
* Fix webhook
* Remove comments
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
* Fix start block
* Fix webhook
* Remove comments
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Sg312