Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Preserve advanced mode and trigger mode in undo-redo logic.

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 Oct 7, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Oct 7, 2025 7:58pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 7, 2025 7:58pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This PR fixes a bug in the undo-redo system where block UI state properties were being lost during undo operations. The changes ensure that when blocks are restored through undo/redo operations, their visual and functional states (advanced mode, trigger mode, wide layout, horizontal handles, enabled state, and height) are properly preserved.

The fix operates at two levels: first, it enhances the serialization/deserialization system to capture and restore the advancedMode property alongside the existing triggerMode handling. Second, it modifies the undo-redo hook to pass preserved block properties when calling the workflow store's addBlock method during restoration operations.

This integration ensures that the workflow store's existing capability to preserve block properties through its optional blockProperties parameter is properly utilized by the undo-redo system. The fix maintains consistency with existing patterns in the codebase, particularly following the established approach for triggerMode preservation.

Important Files Changed

Changed Files
Filename Score Overview
apps/sim/hooks/use-undo-redo.ts 5/5 Enhanced undo-redo operations to preserve block UI state properties during restoration
apps/sim/serializer/index.ts 5/5 Added advancedMode serialization and deserialization to match triggerMode handling

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it addresses a specific UI state preservation bug
  • Score reflects well-structured changes that follow existing patterns and maintain backward compatibility
  • No files require special attention as both changes are straightforward enhancements to existing functionality

Sequence Diagram

sequenceDiagram
    participant User
    participant UndoRedoHook as "use-undo-redo.ts"
    participant WorkflowStore as "workflow store"
    participant SubBlockStore as "subblock store"
    participant UndoRedoStore as "undo-redo store"
    participant OperationQueue as "operation queue"

    User->>UndoRedoHook: "trigger undo/redo"
    UndoRedoHook->>UndoRedoStore: "undo/redo(activeWorkflowId, userId)"
    UndoRedoStore-->>UndoRedoHook: "return operation entry"
    
    alt Undo Operation
        UndoRedoHook->>UndoRedoHook: "process inverse operation"
        UndoRedoHook->>WorkflowStore: "addBlock with preserved modes"
        Note over WorkflowStore: "advancedMode: blockSnapshot.advancedMode"
        Note over WorkflowStore: "triggerMode: blockSnapshot.triggerMode"
        UndoRedoHook->>SubBlockStore: "setState with subblock values"
        UndoRedoHook->>OperationQueue: "addToQueue with operation payload"
    else Redo Operation  
        UndoRedoHook->>UndoRedoHook: "process forward operation"
        UndoRedoHook->>WorkflowStore: "addBlock with preserved modes"
        Note over WorkflowStore: "advancedMode: snap.advancedMode"
        Note over WorkflowStore: "triggerMode: snap.triggerMode"
        UndoRedoHook->>SubBlockStore: "setState with subblock values"
        UndoRedoHook->>OperationQueue: "addToQueue with operation payload"
    end
    
    WorkflowStore-->>User: "UI updates with restored block states"
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs October 7, 2025 19:49 Inactive
@icecrasher321 icecrasher321 merged commit a63a7b0 into staging Oct 7, 2025
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/undo-trigger-mode branch October 7, 2025 23:22
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