Skip to content

Commit 52d9f31

Browse files
waleedlatif1claude
andcommitted
fix(undo-redo): use consistent target state for toggle redo
The redo logic for BATCH_TOGGLE_ENABLED and BATCH_TOGGLE_LOCKED was incorrectly computing each block's new state as !previousStates[blockId]. However, the store's batchToggleEnabled/batchToggleLocked set ALL blocks to the SAME target state based on the first block's previous state. Now redo computes targetState = !previousStates[firstBlockId] and applies it to all blocks, matching the store's behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3fbcfc6 commit 52d9f31

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

apps/sim/hooks/use-undo-redo.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,10 +1447,12 @@ export function useUndoRedo() {
14471447
userId,
14481448
})
14491449

1450-
// Use setBlockEnabled to directly set to toggled state
1451-
// Redo sets to !previousStates (the state after the original toggle)
1450+
// Compute target state the same way batchToggleEnabled does:
1451+
// use !firstBlock.enabled, where firstBlock is blockIds[0]
1452+
const firstBlockId = blockIds[0]
1453+
const targetEnabled = !previousStates[firstBlockId]
14521454
validBlockIds.forEach((blockId) => {
1453-
useWorkflowStore.getState().setBlockEnabled(blockId, !previousStates[blockId])
1455+
useWorkflowStore.getState().setBlockEnabled(blockId, targetEnabled)
14541456
})
14551457
break
14561458
}
@@ -1505,10 +1507,12 @@ export function useUndoRedo() {
15051507
userId,
15061508
})
15071509

1508-
// Use setBlockLocked to directly set to toggled state
1509-
// Redo sets to !previousStates (the state after the original toggle)
1510+
// Compute target state the same way batchToggleLocked does:
1511+
// use !firstBlock.locked, where firstBlock is blockIds[0]
1512+
const firstBlockId = blockIds[0]
1513+
const targetLocked = !previousStates[firstBlockId]
15101514
validBlockIds.forEach((blockId) => {
1511-
useWorkflowStore.getState().setBlockLocked(blockId, !previousStates[blockId])
1515+
useWorkflowStore.getState().setBlockLocked(blockId, targetLocked)
15121516
})
15131517
break
15141518
}

0 commit comments

Comments
 (0)