Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

  • Duplicate name should show error notif and not persist
  • Otherwise should update downstream var ref correctly

Type of Change

  • Bug fix

Testing

Tested manually

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
Copy link

vercel bot commented Dec 26, 2025

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 26, 2025 8:49pm

@icecrasher321
Copy link
Collaborator Author

@greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 26, 2025

Greptile Summary

Fixed block name validation and downstream variable reference updates. The changes ensure duplicate names are rejected with error notifications, and variable references are properly updated when block names change.

  • Duplicate name validation: Added upfront validation in collaborativeUpdateBlockName that checks for conflicting block names using normalized comparison and shows error notifications when conflicts are detected
  • Error handling UX: Modified editor to check the return value and keep rename mode open on error, allowing users to correct invalid names without re-entering rename mode
  • Payload field fix: Corrected subBlockId to subblockId in the operation payload to match socket handler expectations (line 1076 in use-collaborative-workflow.ts)
  • Performance optimization: Hoisted the updateReferences helper function outside the loop and only update blocks that actually have changes, reducing unnecessary object spreading

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The changes properly address the stated bug with good validation logic and error handling. The payload field name fix ensures compatibility with the socket handler. Minor deduction for the hook missing return type annotation in its dependencies array, though this doesn't affect functionality
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/editor.tsx Improved error handling by checking return value from collaborativeUpdateBlockName and keeping rename mode open on error
apps/sim/hooks/use-collaborative-workflow.ts Added duplicate name validation with notifications and fixed payload field name from subBlockId to subblockId for consistency
apps/sim/stores/workflows/workflow/store.ts Optimized subblock reference updates by hoisting helper function and only updating blocks with actual changes

Sequence Diagram

sequenceDiagram
    participant User
    participant Editor
    participant Hook as useCollaborativeWorkflow
    participant Store as WorkflowStore
    participant SubStore as SubBlockStore
    participant Queue as OperationQueue
    participant Socket

    User->>Editor: Rename block (editedName)
    Editor->>Editor: Trim name
    
    alt Name unchanged
        Editor->>Editor: Exit rename mode
    else Name changed
        Editor->>Hook: collaborativeUpdateBlockName(id, trimmedName)
        
        Hook->>Hook: Trim and normalize name
        
        alt Empty name
            Hook->>Hook: Show error notification
            Hook-->>Editor: {success: false, error}
            Editor->>Editor: Keep rename mode open
        else Duplicate name
            Hook->>Hook: Check for conflicting blocks
            Hook->>Hook: Show error notification
            Hook-->>Editor: {success: false, error}
            Editor->>Editor: Keep rename mode open
        else Valid name
            Hook->>Queue: executeQueuedOperation('update-name')
            Queue->>Store: updateBlockName(id, trimmedName)
            
            Store->>Store: Update block name
            Store->>Store: Build regex for old block name
            Store->>Store: Loop through all subblocks
            Store->>Store: Update references recursively
            Store->>SubStore: Update workflowValues
            Store-->>Hook: {success: true, changedSubblocks: [...]}
            
            alt Has changed subblocks
                loop For each changed subblock
                    Hook->>Queue: addToQueue('subblock-update')
                    Queue->>Socket: Emit subblock-update
                    Socket-->>Queue: operation-confirmed
                end
            end
            
            Hook-->>Editor: {success: true}
            Editor->>Editor: Exit rename mode
        end
    end
Loading

@icecrasher321 icecrasher321 merged commit 66b8434 into staging Dec 26, 2025
11 checks passed
Sign up for free to 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.

2 participants