Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

  • Snapshot service should use same hasWorkflowChanges
  • hasWorkflowChanges needs to exclude subflow runtime derived fields

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 Jan 28, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 29, 2026 0:10am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 28, 2026

Greptile Overview

Greptile Summary

Consolidated workflow state normalization logic into a shared normalizeWorkflowState function to ensure consistency between snapshot hashing and change detection.

Key Changes

  • Extracted duplicated normalization logic from SnapshotService.normalizeStateForHashing and hasWorkflowChanged into shared normalizeWorkflowState function in normalize.ts
  • Added exclusion of subflow runtime derived fields (nodes, distribution) from block.data to prevent false positives when comparing parallel/loop blocks
  • Simplified hasWorkflowChanged from ~230 lines to ~120 lines by using the shared normalization function
  • Updated test cases to use subBlocks changes instead of outputs changes for meaningful change detection
  • Improved logging clarity in snapshot service

Impact

Ensures both snapshot deduplication and workflow change detection use identical normalization rules, eliminating potential inconsistencies where snapshots might be deduplicated but workflows show as changed (or vice versa).

Confidence Score: 5/5

  • Safe to merge - well-structured refactoring that consolidates duplicated logic
  • The PR successfully consolidates duplicated normalization logic into a shared function, improving maintainability and consistency. The changes are well-tested, and the only suggestion is to remove debug logging before production deployment.
  • No files require special attention - only minor style suggestion to remove debug logging in compare.ts

Important Files Changed

Filename Overview
apps/sim/lib/workflows/comparison/normalize.ts Extracted normalization logic into new normalizeWorkflowState function, added exclusion of subflow runtime derived fields (nodes, distribution) from block.data
apps/sim/lib/workflows/comparison/compare.ts Simplified hasWorkflowChanged to use shared normalizeWorkflowState function, removing ~200 lines of duplicated normalization logic
apps/sim/lib/logs/execution/snapshot/service.ts Removed local normalizeStateForHashing method in favor of shared normalizeWorkflowState function, improved logging clarity

Sequence Diagram

sequenceDiagram
    participant SS as SnapshotService
    participant NS as normalizeWorkflowState
    participant HWC as hasWorkflowChanged
    participant WS as WorkflowState

    Note over SS,WS: Snapshot Creation Flow
    SS->>SS: computeStateHash(state)
    SS->>NS: normalizeWorkflowState(state)
    NS->>NS: Filter runtime fields (nodes, distribution)
    NS->>NS: Exclude system/trigger subBlocks
    NS->>NS: Normalize edges, loops, parallels
    NS-->>SS: NormalizedWorkflowState
    SS->>SS: SHA-256 hash
    SS-->>SS: stateHash

    Note over SS,WS: Workflow Change Detection
    HWC->>NS: normalizeWorkflowState(currentState)
    NS-->>HWC: normalizedCurrent
    HWC->>NS: normalizeWorkflowState(deployedState)
    NS-->>HWC: normalizedDeployed
    HWC->>HWC: Compare stringified states
    HWC-->>HWC: hasChanged boolean
Loading

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.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321 icecrasher321 merged commit 9e40342 into staging Jan 29, 2026
12 checks passed
@icecrasher321 icecrasher321 deleted the improvement/snapshot-service branch January 29, 2026 00:29
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.

2 participants