fix(triggers-persistence): triggers persistence, deletion, updating configs + state management simplifcation#1783
Merged
icecrasher321 merged 2 commits intostagingfrom Nov 1, 2025
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Fixes trigger webhook persistence and collaborative editing synchronization. The PR introduces webhook deletion rollback for Gmail/Outlook configuration failures and adds collaborative state sync after successful saves.
Key Changes
- Webhook rollback: API now deletes webhook records from DB if Gmail/Outlook polling configuration fails, preventing orphaned records
- Collaborative sync: Trigger save now broadcasts webhook state to collaborators using
collaborativeSetSubblockValue() - State management refactor: Replaces computed
useMemowith subscribed Zustand selectors for better reactivity - Code cleanup: Extracts
resolveEffectiveTriggerId()helper and removes unusedisMountedtracking
Issues Found
- Critical bug in
trigger-save.tsx:231-234: Throwing error whensaveConfig()returns false will skip collaborative state updates on lines 239-247, causing state desync between local store and collaborators when the API successfully rolls back a failed webhook
Confidence Score: 2/5
- Critical bug in error handling will cause state desync in collaborative environments
- The webhook rollback logic is solid, but throwing on
saveConfig()failure skips the collaborative state sync that should propagate the deletion to other users. This creates a race condition where collaborators see stale webhook IDs while the DB has been rolled back. trigger-save.tsxlines 231-234 must be fixed before merging - the error handling logic will cause collaborative state desync
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/webhooks/route.ts | 4/5 | Adds webhook deletion rollback on Gmail/Outlook configuration failures - improves error handling and prevents orphaned DB records |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/trigger-save/trigger-save.tsx | 2/5 | Refactors state management and adds collaborative sync - but contains critical bug where throwing on saveConfig() failure skips state updates causing desync |
| apps/sim/hooks/use-webhook-management.ts | 4/5 | Extracts resolveEffectiveTriggerId function for reusability and simplifies loading logic - cleaner code with no functional changes |
Sequence Diagram
sequenceDiagram
participant User
participant TriggerSave
participant WebhookHook
participant API
participant DB
participant Collaborative
User->>TriggerSave: Click Save
TriggerSave->>TriggerSave: Aggregate config from subblocks
TriggerSave->>TriggerSave: Validate required fields
TriggerSave->>WebhookHook: saveConfig()
alt Create New Webhook
WebhookHook->>API: POST /api/webhooks
API->>API: Save webhook to DB
alt Provider is Gmail/Outlook
API->>API: configureGmailPolling() or configureOutlookPolling()
alt Configuration Fails
API->>DB: DELETE webhook (rollback)
API-->>WebhookHook: Error response
WebhookHook-->>TriggerSave: false
TriggerSave->>TriggerSave: Throw error (BUG: skips state sync)
end
end
API-->>WebhookHook: Success with webhook ID
WebhookHook->>WebhookHook: Update local state
WebhookHook-->>TriggerSave: true
else Update Existing Webhook
WebhookHook->>API: PATCH /api/webhooks/{id}
API-->>WebhookHook: Success
WebhookHook-->>TriggerSave: true
end
TriggerSave->>TriggerSave: Read saved values from store
TriggerSave->>Collaborative: collaborativeSetSubblockValue() x4
Collaborative->>Collaborative: Sync to other users
TriggerSave->>User: Show success message
3 files reviewed, 1 comment
...wId]/components/workflow-block/components/sub-block/components/trigger-save/trigger-save.tsx
Show resolved
Hide resolved
waleedlatif1
pushed a commit
that referenced
this pull request
Nov 12, 2025
…onfigs + state management simplifcation (#1783) * fix(triggers): configuration persistences issues * required fields validation staleness issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Collaborative edits of trigger config + persistence of webhook rows and cleanups associated with failures.
Type of Change
Testing
Tested with @waleedlatif1
Checklist