Skip to content

fix(workflows): exclude block locked from diff detection#4631

Merged
waleedlatif1 merged 1 commit into
stagingfrom
waleedlatif1/diff-locked-check
May 16, 2026
Merged

fix(workflows): exclude block locked from diff detection#4631
waleedlatif1 merged 1 commit into
stagingfrom
waleedlatif1/diff-locked-check

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Toggling a block's locked state is UI metadata and should not register as a workflow drift/diff
  • Stripped locked from hasBlockChanged, computeFieldDiff, the compare.ts blockFields list, and from extractBlockFieldsForComparison so it's also excluded from the normalized-stringify block equality check used by drift detection and hashing
  • Locked state still persists to the DB (via setBlockLockedupdateLastSaved and full-state serialization) — only the diff/comparison path ignores it

Type of Change

  • Bug fix

Testing

  • Updated existing locked tests in diff-engine.test.ts and compare.test.ts to assert locked toggles do NOT produce a diff
  • Added extractBlockFieldsForComparison tests in normalize.test.ts proving locked is stripped and two blocks differing only by locked normalize identically
  • Added a diff-engine test confirming real edits on a block whose locked state also changed still surface, with locked absent from changed_fields
  • All 219 tests pass

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)

Toggling a block's locked state is UI metadata and should not register
as a workflow drift/diff. Strip locked from hasBlockChanged,
computeFieldDiff, the compare.ts blockFields list, and from
extractBlockFieldsForComparison so it's also excluded from the
normalized stringify-based block equality check used by drift detection
and hashing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 16, 2026 2:14am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 16, 2026

PR Summary

Medium Risk
Adjusts workflow drift/diff detection to treat locked as UI-only metadata, which could change when diffs are reported and suppress prior alerts. Scope is limited and covered by updated/added unit tests around comparison, normalization, and diff-engine behavior.

Overview
Prevents toggling a block’s locked state from being treated as a workflow change/diff.

This removes locked from block field comparisons in both the client-side comparison path (generateWorkflowDiffSummary / normalization hashing) and the server-side diff engine (hasBlockChanged/computeFieldDiff), and updates tests to assert that only locked changes yield no edited blocks, no locked in changed_fields, and no diff-summary changes while still detecting real edits when locked changes alongside functional fields.

Reviewed by Cursor Bugbot for commit 261dda2. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 16, 2026

Greptile Summary

This PR excludes the block locked field from all workflow diff and comparison paths so that toggling a block's locked state is treated as UI metadata rather than a meaningful workflow change.

  • Removes locked from hasBlockChanged and computeFieldDiff.fieldsToCheck in diff-engine.ts, from blockFields in compare.ts, and strips it via destructuring in extractBlockFieldsForComparison in normalize.ts — covering every comparison entry point including the normalised-hash path used for drift detection.
  • Adds/updates tests in all three suites, including a combined test asserting that a real field edit alongside a locked toggle still surfaces the real edit (with locked absent from changed_fields).

Confidence Score: 5/5

Safe to merge — the change is a targeted, consistent exclusion of a UI-only field across every comparison entry point, with no risk to real-field change detection.

The exclusion of locked is applied symmetrically in all four places that compare block state: the hasBlockChanged gate, computeFieldDiff, the blockFields guard in generateWorkflowDiffSummary, and the extractBlockFieldsForComparison normalisation used for both the diff summary and the workflow hash. The combined test confirms genuine changes are still detected correctly.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/workflows/diff/diff-engine.ts Removes locked from hasBlockChanged and computeFieldDiff — both changes are consistent and leave no gap in the detection of real field edits.
apps/sim/lib/workflows/comparison/normalize.ts Strips locked via destructuring in extractBlockFieldsForComparison, which covers both the generateWorkflowDiffSummary path (compare.ts) and the normaliseWorkflowState hashing path.
apps/sim/lib/workflows/comparison/compare.ts Removes locked from the blockFields guard list in generateWorkflowDiffSummary; consistent with extractBlockFieldsForComparison now stripping it from the outer stringify check too.
apps/sim/lib/workflows/diff/diff-engine.test.ts Updated locked-state tests to assert no diff; new combined test verifies real edits still surface with locked absent from changed_fields.
apps/sim/lib/workflows/comparison/normalize.test.ts New extractBlockFieldsForComparison suite proves locked is stripped and two blocks differing only in locked normalise identically.
apps/sim/lib/workflows/comparison/compare.test.ts Updated existing locked test expectations to false and added a diff-summary test asserting no changes for locked-only toggle.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Block locked toggle] --> B{Diff detection path}
    B --> C[hasBlockChanged\ndiff-engine.ts]
    B --> D[extractBlockFieldsForComparison\nnormalize.ts]
    C -->|locked check removed| E[Block NOT in editedBlocks]
    D -->|locked stripped from blockRest| G[normalizedStringify comparison]
    G -->|outer guard does not fire| I[locked NOT in diff summary]
    D --> J[normalizeWorkflowState hashing]
    J -->|locked excluded from hash| K[Drift hash unchanged for locked-only toggle]
Loading

Reviews (1): Last reviewed commit: "fix(workflows): exclude block locked fro..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit ff23546 into staging May 16, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/diff-locked-check branch May 16, 2026 02:23
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