Skip to content

Conversation

@Pbonmars-20031006
Copy link
Contributor

@Pbonmars-20031006 Pbonmars-20031006 commented Dec 18, 2025

Summary

The issue where the re rendering blocks specially when they go in and out of focus makes a call for GET api/webhooks irrespective of whether a webhookurl has been set for the workflow.

The fix was to make sure loadwebhookorgenerateurl function only gets called when useWebhookUrl is set true.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

Tested manually by looking at server logs.

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)

Screenshots/Videos

…enerateurl function when the useWebhookurl flag is true
@vercel
Copy link

vercel bot commented Dec 18, 2025

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 18, 2025 8:04pm

@Pbonmars-20031006 Pbonmars-20031006 changed the title fixing the useWbehookManangement call to only call the loadwebhookorg… improvement(useWebhookUrl): useWbehookManangement call to only call the loadwebhookorg… Dec 18, 2025
@Pbonmars-20031006 Pbonmars-20031006 changed the title improvement(useWebhookUrl): useWbehookManangement call to only call the loadwebhookorg… improvement(useWebhookUrl): GET api/webhook is called when useWebhookUrl:true Dec 18, 2025
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 18, 2025

Greptile Summary

Fixed unnecessary webhook API calls during block re-rendering by adding a useWebhookUrl flag to the useWebhookManagement hook. Previously, every block using this hook would trigger a GET /api/webhooks call on focus/blur events, even when the webhook URL wasn't needed.

Key changes:

  • Added optional useWebhookUrl parameter (defaults to false) to control when webhook data should be loaded
  • ShortInput component passes useWebhookUrl prop through to the hook (defaults to false)
  • TriggerSave component explicitly sets useWebhookUrl: true since it needs the webhook URL for display and management
  • Wrapped loadWebhookOrGenerateUrl() call in conditional check

Issue found:

  • The useEffect dependency array is missing useWebhookUrl, which could cause stale closures if the prop changes dynamically

Confidence Score: 4/5

  • This PR is safe to merge after fixing the missing dependency in the useEffect
  • The fix correctly addresses the performance issue by preventing unnecessary API calls. The logic is sound and component changes are minimal. However, missing useWebhookUrl from the dependency array is a React Hooks best practice violation that should be fixed to avoid potential bugs.
  • Pay attention to apps/sim/hooks/use-webhook-management.ts - the dependency array needs to be updated to include useWebhookUrl

Important Files Changed

Filename Overview
apps/sim/hooks/use-webhook-management.ts Added useWebhookUrl flag to conditionally load webhooks, preventing unnecessary API calls. Missing dependency in useEffect array.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/short-input/short-input.tsx Passes useWebhookUrl prop to useWebhookManagement hook, enabling conditional webhook loading behavior.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/trigger-save/trigger-save.tsx Sets useWebhookUrl: true to enable webhook URL storage in store, properly activating webhook loading.

Sequence Diagram

sequenceDiagram
    participant ShortInput
    participant TriggerSave
    participant useWebhookManagement
    participant API
    participant SubBlockStore

    Note over ShortInput,TriggerSave: Components using webhook management

    ShortInput->>useWebhookManagement: call hook with useWebhookUrl=false
    Note over useWebhookManagement: useWebhookUrl is false
    useWebhookManagement->>useWebhookManagement: Skip loadWebhookOrGenerateUrl()
    useWebhookManagement-->>ShortInput: Return webhook state (no API call)

    TriggerSave->>useWebhookManagement: call hook with useWebhookUrl=true
    Note over useWebhookManagement: useWebhookUrl is true
    useWebhookManagement->>SubBlockStore: Set loading state
    useWebhookManagement->>API: GET /api/webhooks?workflowId&blockId
    API-->>useWebhookManagement: Return webhook data
    useWebhookManagement->>SubBlockStore: Store webhookId, triggerPath, triggerConfig
    useWebhookManagement->>SubBlockStore: Mark as checked
    useWebhookManagement-->>TriggerSave: Return webhook state with URL
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

Copy link
Collaborator

@icecrasher321 icecrasher321 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the reasoning.

@Pbonmars-20031006 Pbonmars-20031006 merged commit 7575cd6 into staging Dec 18, 2025
10 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/SIM-514-useWebhookUrl-conditioning branch December 19, 2025 09:28
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.

3 participants