Skip to content

Commit 964fda9

Browse files
committed
fix(lock): prevent socket crash when locking agent blocks
1 parent eab01e0 commit 964fda9

File tree

2 files changed

+19
-0
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor
    • socket/handlers

2 files changed

+19
-0
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/editor.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,15 @@ export function Editor() {
618618
<div className='h-[1.25px] flex-1' style={DASHED_DIVIDER_STYLE} />
619619
</div>
620620
)}
621+
{hasAdvancedOnlyFields && !canEditBlock && displayAdvancedOptions && (
622+
<div className='flex items-center gap-[10px] px-[2px] pt-[14px] pb-[12px]'>
623+
<div className='h-[1.25px] flex-1' style={DASHED_DIVIDER_STYLE} />
624+
<span className='whitespace-nowrap font-medium text-[13px] text-[var(--text-secondary)]'>
625+
Additional fields
626+
</span>
627+
<div className='h-[1.25px] flex-1' style={DASHED_DIVIDER_STYLE} />
628+
</div>
629+
)}
621630

622631
{advancedOnlySubBlocks.map((subBlock, index) => {
623632
const stableKey = getSubBlockStableKey(

apps/sim/socket/handlers/subblocks.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ async function flushSubblockUpdate(
232232
}
233233

234234
let updateSuccessful = false
235+
let blockLocked = false
235236
await db.transaction(async (tx) => {
236237
const [block] = await tx
237238
.select({
@@ -250,6 +251,7 @@ async function flushSubblockUpdate(
250251
// Check if block is locked directly
251252
if (block.locked) {
252253
logger.info(`Skipping subblock update - block ${blockId} is locked`)
254+
blockLocked = true
253255
return
254256
}
255257

@@ -266,6 +268,7 @@ async function flushSubblockUpdate(
266268

267269
if (parentBlock?.locked) {
268270
logger.info(`Skipping subblock update - parent ${parentId} is locked`)
271+
blockLocked = true
269272
return
270273
}
271274
}
@@ -308,6 +311,13 @@ async function flushSubblockUpdate(
308311
serverTimestamp: Date.now(),
309312
})
310313
})
314+
} else if (blockLocked) {
315+
pending.opToSocket.forEach((socketId, opId) => {
316+
io.to(socketId).emit('operation-confirmed', {
317+
operationId: opId,
318+
serverTimestamp: Date.now(),
319+
})
320+
})
311321
} else {
312322
pending.opToSocket.forEach((socketId, opId) => {
313323
io.to(socketId).emit('operation-failed', {

0 commit comments

Comments
 (0)