Skip to content

Commit 9026952

Browse files
committed
more
1 parent 80e98dd commit 9026952

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,8 @@ export function useUndoRedo() {
13361336
addToQueue({
13371337
id: crypto.randomUUID(),
13381338
operation: {
1339-
operation: 'batch-remove-edges',
1340-
target: 'edges',
1339+
operation: EDGES_OPERATIONS.BATCH_REMOVE_EDGES,
1340+
target: OPERATION_TARGETS.EDGES,
13411341
payload: { edgeIds: affectedEdges.map((e) => e.id) },
13421342
},
13431343
workflowId: activeWorkflowId,
@@ -1358,8 +1358,8 @@ export function useUndoRedo() {
13581358
addToQueue({
13591359
id: crypto.randomUUID(),
13601360
operation: {
1361-
operation: 'batch-add-edges',
1362-
target: 'edges',
1361+
operation: EDGES_OPERATIONS.BATCH_ADD_EDGES,
1362+
target: OPERATION_TARGETS.EDGES,
13631363
payload: { edges: edgesToAdd },
13641364
},
13651365
workflowId: activeWorkflowId,
@@ -1374,8 +1374,8 @@ export function useUndoRedo() {
13741374
addToQueue({
13751375
id: opId,
13761376
operation: {
1377-
operation: 'batch-update-parent',
1378-
target: 'blocks',
1377+
operation: BLOCKS_OPERATIONS.BATCH_UPDATE_PARENT,
1378+
target: OPERATION_TARGETS.BLOCKS,
13791379
payload: {
13801380
updates: validUpdates.map((u) => ({
13811381
id: u.blockId,
@@ -1391,7 +1391,7 @@ export function useUndoRedo() {
13911391
logger.debug('Redid batch-update-parent', { updateCount: validUpdates.length })
13921392
break
13931393
}
1394-
case 'batch-toggle-enabled': {
1394+
case UNDO_REDO_OPERATIONS.BATCH_TOGGLE_ENABLED: {
13951395
const toggleOp = entry.operation as BatchToggleEnabledOperation
13961396
const { blockIds, previousStates } = toggleOp.data
13971397

@@ -1404,8 +1404,8 @@ export function useUndoRedo() {
14041404
addToQueue({
14051405
id: opId,
14061406
operation: {
1407-
operation: 'batch-toggle-enabled',
1408-
target: 'blocks',
1407+
operation: BLOCKS_OPERATIONS.BATCH_TOGGLE_ENABLED,
1408+
target: OPERATION_TARGETS.BLOCKS,
14091409
payload: { blockIds: validBlockIds, previousStates },
14101410
},
14111411
workflowId: activeWorkflowId,
@@ -1419,7 +1419,7 @@ export function useUndoRedo() {
14191419
})
14201420
break
14211421
}
1422-
case 'batch-toggle-handles': {
1422+
case UNDO_REDO_OPERATIONS.BATCH_TOGGLE_HANDLES: {
14231423
const toggleOp = entry.operation as BatchToggleHandlesOperation
14241424
const { blockIds, previousStates } = toggleOp.data
14251425

@@ -1432,8 +1432,8 @@ export function useUndoRedo() {
14321432
addToQueue({
14331433
id: opId,
14341434
operation: {
1435-
operation: 'batch-toggle-handles',
1436-
target: 'blocks',
1435+
operation: BLOCKS_OPERATIONS.BATCH_TOGGLE_HANDLES,
1436+
target: OPERATION_TARGETS.BLOCKS,
14371437
payload: { blockIds: validBlockIds, previousStates },
14381438
},
14391439
workflowId: activeWorkflowId,
@@ -1447,7 +1447,7 @@ export function useUndoRedo() {
14471447
})
14481448
break
14491449
}
1450-
case 'apply-diff': {
1450+
case UNDO_REDO_OPERATIONS.APPLY_DIFF: {
14511451
// Redo apply-diff means re-applying the proposed state with diff markers
14521452
const applyDiffOp = entry.operation as any
14531453
const { proposedState, diffAnalysis, baselineSnapshot } = applyDiffOp.data
@@ -1504,7 +1504,7 @@ export function useUndoRedo() {
15041504
logger.info('Redid apply-diff operation')
15051505
break
15061506
}
1507-
case 'accept-diff': {
1507+
case UNDO_REDO_OPERATIONS.ACCEPT_DIFF: {
15081508
// Redo accept-diff means re-accepting (stripping markers)
15091509
const acceptDiffOp = entry.operation as any
15101510
const { afterAccept } = acceptDiffOp.data
@@ -1558,7 +1558,7 @@ export function useUndoRedo() {
15581558
logger.info('Redid accept-diff operation - cleared diff view')
15591559
break
15601560
}
1561-
case 'reject-diff': {
1561+
case UNDO_REDO_OPERATIONS.REJECT_DIFF: {
15621562
// Redo reject-diff means re-rejecting (restoring baseline, clearing diff)
15631563
const rejectDiffOp = entry.operation as any
15641564
const { afterReject } = rejectDiffOp.data
@@ -1636,7 +1636,7 @@ export function useUndoRedo() {
16361636

16371637
const operation: any = {
16381638
id: crypto.randomUUID(),
1639-
type: 'apply-diff',
1639+
type: UNDO_REDO_OPERATIONS.APPLY_DIFF,
16401640
timestamp: Date.now(),
16411641
workflowId: activeWorkflowId,
16421642
userId,
@@ -1649,7 +1649,7 @@ export function useUndoRedo() {
16491649

16501650
const inverse: any = {
16511651
id: crypto.randomUUID(),
1652-
type: 'apply-diff',
1652+
type: UNDO_REDO_OPERATIONS.APPLY_DIFF,
16531653
timestamp: Date.now(),
16541654
workflowId: activeWorkflowId,
16551655
userId,
@@ -1680,7 +1680,7 @@ export function useUndoRedo() {
16801680

16811681
const operation: any = {
16821682
id: crypto.randomUUID(),
1683-
type: 'accept-diff',
1683+
type: UNDO_REDO_OPERATIONS.ACCEPT_DIFF,
16841684
timestamp: Date.now(),
16851685
workflowId: activeWorkflowId,
16861686
userId,
@@ -1694,7 +1694,7 @@ export function useUndoRedo() {
16941694

16951695
const inverse: any = {
16961696
id: crypto.randomUUID(),
1697-
type: 'accept-diff',
1697+
type: UNDO_REDO_OPERATIONS.ACCEPT_DIFF,
16981698
timestamp: Date.now(),
16991699
workflowId: activeWorkflowId,
17001700
userId,
@@ -1720,7 +1720,7 @@ export function useUndoRedo() {
17201720

17211721
const operation: any = {
17221722
id: crypto.randomUUID(),
1723-
type: 'reject-diff',
1723+
type: UNDO_REDO_OPERATIONS.REJECT_DIFF,
17241724
timestamp: Date.now(),
17251725
workflowId: activeWorkflowId,
17261726
userId,
@@ -1734,7 +1734,7 @@ export function useUndoRedo() {
17341734

17351735
const inverse: any = {
17361736
id: crypto.randomUUID(),
1737-
type: 'reject-diff',
1737+
type: UNDO_REDO_OPERATIONS.REJECT_DIFF,
17381738
timestamp: Date.now(),
17391739
workflowId: activeWorkflowId,
17401740
userId,

apps/sim/socket/handlers/operations.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
EDGES_OPERATIONS,
77
OPERATION_TARGETS,
88
VARIABLE_OPERATIONS,
9+
type VariableOperation,
910
WORKFLOW_OPERATIONS,
1011
} from '@/socket/constants'
1112
import { persistWorkflowOperation } from '@/socket/database/operations'
@@ -198,7 +199,9 @@ export function setupOperationsHandlers(
198199

199200
if (
200201
target === OPERATION_TARGETS.VARIABLE &&
201-
[VARIABLE_OPERATIONS.ADD, VARIABLE_OPERATIONS.REMOVE].includes(operation as any)
202+
([VARIABLE_OPERATIONS.ADD, VARIABLE_OPERATIONS.REMOVE] as VariableOperation[]).includes(
203+
operation as VariableOperation
204+
)
202205
) {
203206
await persistWorkflowOperation(workflowId, {
204207
operation,

0 commit comments

Comments
 (0)