Skip to content

fix(copilot): fix triggers unsave on edit - #1874

Merged
Sg312 merged 6 commits into
stagingfrom
fix/copilot-trigger-unsave
Nov 11, 2025
Merged

fix(copilot): fix triggers unsave on edit#1874
Sg312 merged 6 commits into
stagingfrom
fix/copilot-trigger-unsave

Conversation

@Sg312

@Sg312Sg312 commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator

Summary

Triggers used to unsave on edit, they shouldn't

Type of Change

  • Bug fix

Testing

Manual

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

vercelBot commented Nov 10, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedNov 10, 2025 11:18pm

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Fixed trigger metadata (webhookId, triggerPath, testUrl, testUrlExpiresAt) being incorrectly cleared when copilot edits workflows, by introducing centralized constants that categorize trigger-related subblocks and protecting runtime metadata from modification.

Key changes:

  • Defined TRIGGER_RUNTIME_SUBBLOCK_IDS in triggers/consts.ts to identify metadata that should never be modified by diff operations
  • Modified edit-workflow.ts to skip runtime trigger subblocks during copilot edits and added applyTriggerConfigToBlockSubblocks() to properly handle triggerConfig changes
  • Updated json-sanitizer.ts to exclude persisted trigger subblocks from sensitive data filtering (previously they were incorrectly marked as sensitive)
  • Removed hardcoded WEBHOOK_SUBBLOCK_FIELDS filtering from utils.ts and server-utils.ts that was preventing trigger metadata from persisting
  • Enhanced db-helpers.ts to restore existing webhooks after workflow saves (they were being deleted but not re-inserted)
  • Fixed minor typo: "un-deployed" → "undeployed" in UI components

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is well-architected and addresses a critical bug systematically. The centralized constants pattern is clean and maintainable. All changes are defensive (preventing overwrites) rather than introducing new logic. The webhook restoration logic ensures data integrity. No breaking changes or risky operations detected.
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/triggers/consts.ts5/5Added centralized constants for trigger subblock IDs categorized by persistence and runtime behavior
apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts5/5Protected runtime trigger metadata from copilot edits and added logic to apply triggerConfig changes to subblocks
apps/sim/stores/workflows/utils.ts5/5Removed hardcoded WEBHOOK_SUBBLOCK_FIELDS filtering that was incorrectly excluding trigger metadata
apps/sim/stores/workflows/server-utils.ts5/5Removed hardcoded WEBHOOK_SUBBLOCK_FIELDS filtering that was incorrectly excluding trigger metadata
apps/sim/lib/workflows/db-helpers.ts5/5Added webhook persistence logic to restore existing webhooks after workflow save operations

Sequence Diagram

sequenceDiagram
participant User
participant UI as Trigger UI
participant Copilot
participant EditWorkflow as edit-workflow.ts
participant Sanitizer as json-sanitizer.ts
participant DBHelpers as db-helpers.ts
participant Store as Workflow Store
Note over User,Store: BEFORE FIX: Trigger metadata lost on copilot edit
User->>UI: Configure trigger (webhookId, triggerPath)
UI->>Store: Save trigger metadata to subblocks
User->>Copilot: Edit workflow via copilot
Copilot->>EditWorkflow: Apply edit operations
Note over EditWorkflow: ❌ Overwrites ALL subblock values<br/>including webhookId, triggerPath
EditWorkflow->>Store: Update workflow state
Note over Store: ❌ Trigger metadata lost
Note over User,Store: AFTER FIX: Trigger metadata preserved
User->>UI: Configure trigger (webhookId, triggerPath)
UI->>Store: Save trigger metadata to subblocks
User->>Copilot: Edit workflow via copilot
Copilot->>EditWorkflow: Apply edit operations
Note over EditWorkflow: ✓ Skip TRIGGER_RUNTIME_SUBBLOCK_IDS<br/>(webhookId, triggerPath, testUrl, etc)
EditWorkflow->>Store: Update workflow state (preserving trigger metadata)
Store->>Sanitizer: Export workflow for training
Note over Sanitizer: ✓ Keep TRIGGER_PERSISTED_SUBBLOCK_IDS<br/>(not marked as sensitive)
Store->>DBHelpers: Save workflow to database
Note over DBHelpers: ✓ Restore existing webhooks<br/>for blocks that still exist
DBHelpers->>Store: Workflow saved with webhooks intact
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

9 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@Sg312
Sg312 merged commit 118c477 into stagingNov 11, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/copilot-trigger-unsave branch November 11, 2025 18:25
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
* Fix copilot trigger unsave
* Fix flushing
* Lint
* Fix test
* Fix some tests
* Fix lint
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
* Fix copilot trigger unsave
* Fix flushing
* Lint
* Fix test
* Fix some tests
* Fix lint
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto 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

@Sg312