Skip to content

engine: minimum cooldown between rule fires — prevent the same rule running twice in a row #17

Description

@hvardhan878

Problem

The action engine polls every 10 seconds. If a rule's condition stays true (e.g. a specific URL is open), the same rule can fire again immediately after the previous execution finishes. This leads to duplicate actions — sending the same email twice, adding the same CRM entry twice, etc.

What to build

A per-rule last fired timestamp + a configurable minimum gap (default: 5 minutes). The action engine should skip a rule if now - last_fired_at < cooldown.

Two settings:

  • Global default cooldown (Settings tab slider, default 5 min)
  • Per-rule override (optional — could be a future issue)

Acceptance criteria

  • rules table has a last_fired_at TEXT column (ISO timestamp, nullable) — add via safeAddColumn()
  • Action engine updates last_fired_at on every successful fire
  • Action engine skips rules where last_fired_at is within the cooldown window
  • Cooldown is configurable in Settings (stored as rule_cooldown_minutes in settings table)
  • Rule card in Behaviour tab shows "Last fired X ago" using the new column (already rendered if column exists)

Files to look at

  • src/main/db.tssafeAddColumn(), Rule interface, schema migrations at bottom
  • src/main/actionEngine.ts — rule dispatch logic
  • The column is already displayed in the rule card UI if present

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions