fix(automations): pause (not skip) armed rows when the account flag is off

Marking a due row skipped/flag_disabled was terminal, so re-enabling the account
flag could never resume it (sweepable only sees pending/processing) — the delayed
action was lost, contradicting the banner that says rules resume when re-enabled.
Check the flag before claiming and return, leaving the row pending like the
instance kill switch does, so it fires once the feature is turned back on.
This commit is contained in:
Tanmay Deep Sharma
2026-07-15 16:18:55 +05:30
parent 7bb90d84cd
commit a921a38db9
@@ -5,6 +5,8 @@ class AutomationRules::ProcessPendingExecutionJob < ApplicationJob
def perform(pending_execution)
return if delayed_automations_disabled?
# Account flag off pauses (not skips): leave the row pending so re-enabling resumes it.
return unless pending_execution.account.feature_enabled?('delayed_automations')
# Atomic claim: a duplicate enqueue (overlapping sweep or stale reclaim) loses here and returns.
return unless pending_execution.claim!
@@ -28,7 +30,6 @@ class AutomationRules::ProcessPendingExecutionJob < ApplicationJob
def structural_skip_reason(pending_execution)
rule = pending_execution.automation_rule
return 'rule_inactive' if rule.nil? || !rule.active?
return 'flag_disabled' unless pending_execution.account.feature_enabled?('delayed_automations')
return 'conversation_gone' if pending_execution.conversation.nil?
nil