Skip to content

fix(lock): prevent socket crash when locking agent blocks#3245

Merged
waleedlatif1 merged 1 commit intostagingfrom
fix/lock
Feb 18, 2026
Merged

fix(lock): prevent socket crash when locking agent blocks#3245
waleedlatif1 merged 1 commit intostagingfrom
fix/lock

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Confirm subblock updates on locked blocks instead of failing them — prevents socket offline mode
  • Show "Additional fields" divider on locked blocks so spacing matches unlocked view

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 Feb 18, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 18, 2026 8:27am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 18, 2026

Greptile Summary

Fixes a bug where editing subblocks on locked agent blocks caused the socket to enter offline mode. The root cause was that flushSubblockUpdate treated a locked-block early return the same as a "block not found" case — both fell into the else branch that emitted operation-failed with retryable: false, which triggered triggerOfflineMode() on the client after exhausting retries.

  • Socket handler (subblocks.ts): Introduces a blockLocked flag set during the database transaction when a block (or its parent) is locked. After the transaction, a new else if (blockLocked) branch emits operation-confirmed instead of operation-failed, acknowledging the operation without persisting changes.
  • Editor UI (editor.tsx): Adds a static "Additional fields" divider for locked blocks when advanced fields with values are displayed (!canEditBlock && displayAdvancedOptions), matching the spacing of the editable-block toggle divider.

Confidence Score: 4/5

  • This PR is safe to merge — it fixes a clear socket crash path with minimal, well-scoped changes.
  • The socket handler fix is logically sound: blockLocked and updateSuccessful are mutually exclusive flags with clear branching. The editor UI change uses mutually exclusive conditions (canEditBlock vs !canEditBlock) preventing double-render. The only reason this isn't a 5 is the lack of automated tests — the PR notes manual testing only, and the operation queue's offline-mode triggering path is critical enough to warrant test coverage.
  • No files require special attention — both changes are straightforward and low risk.

Important Files Changed

Filename Overview
apps/sim/socket/handlers/subblocks.ts Adds blockLocked flag to distinguish locked-block early returns from block-not-found, and emits operation-confirmed instead of operation-failed for locked blocks. This correctly prevents the client from entering offline mode when editing subblocks on locked agent blocks.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/editor.tsx Adds a static "Additional fields" divider for locked blocks when advanced fields are displayed, ensuring visual parity with the unlocked view. The conditions are mutually exclusive with the existing editable-block divider, so no double-render risk.

Sequence Diagram

sequenceDiagram
    participant Client as Client (Browser)
    participant Socket as Socket Server
    participant DB as Database

    Client->>Socket: subblock-update (locked block)
    Socket->>DB: BEGIN transaction
    DB-->>Socket: block.locked = true
    Note over Socket: Sets blockLocked = true, returns early
    Socket->>DB: ROLLBACK (no changes)

    alt Before fix
        Socket->>Client: operation-failed (retryable: false)
        Note over Client: triggerOfflineMode() → socket crashes
    else After fix
        Socket->>Client: operation-confirmed
        Note over Client: Operation acknowledged, no offline mode
    end
Loading

Last reviewed commit: 964fda9

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.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 11f3a14 into staging Feb 18, 2026
7 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/lock branch February 18, 2026 08:32
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.

1 participant

Comments